Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .claude/skills/verify/journeys/neo-publication-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Retrying the auto-filled send after the turn ends must retain its first stored
session and return created:false. Adapter not_found rejects an explicit id; an
unreachable/failed lookup returns session_lookup_failed and instructs a retry
with the unchanged requestId/session, never an invented replacement id.
Only an omitted session keeps a prior row's session or derives one. An explicit
`null` rejects as invalid_publication and an explicit `neo:` id as unknown_session,
even on a requestId with a stored session, and neither saves a row.

Keep observed.json and proof.log. On the test-first commit the helper fails:
the publish input does not yet accept session. Resources close in finally and
Expand Down
3 changes: 2 additions & 1 deletion .claude/skills/verify/journeys/publication-open-target.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ source shape (id, adapter, name, label, provider, link, optional daemon).

Check qualified and exact bare Codex IDs, local/Neo/Space sessions, Claude,
linkless/unsafe native links, ambiguous IDs, unavailable lookup, input injection,
and idempotent retries. Old `session` values stay unchanged. Both
and idempotent retries. An explicit Neo session is refused as unknown_session.
Old `session` values stay unchanged. Both
neo.publication.read and neo.conversation.read carry targets;
repeated sessions share a page-local lookup. No source metadata is persisted in
publication payloads. Require wrapper exit zero and resourcesClosed true.
Expand Down
4 changes: 2 additions & 2 deletions .claude/skills/verify/publication-open-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ try{
assert.equal(first.publication.sessionSource.link,'codex://threads/native-thread');
assert.equal(first.publication.session,draft.session);
const retry=await invoke('neo.publication.publish',draft);assert.equal(retry.created,false);assert.equal(retry.publication.publicationId,first.publication.publicationId);assert.deepEqual(retry.publication.sessionSource,first.publication.sessionSource);
const own=await invoke('neo.publication.publish',{...draft,requestId:crypto.randomUUID(),session:root});assert(own.accepted,JSON.stringify(own));assert.equal(own.publication.session,undefined);assert.equal(own.publication.sessionSource,undefined);
const own=await invoke('neo.publication.publish',{...draft,requestId:crypto.randomUUID(),session:root});assert.deepEqual(own,{accepted:false,reason:'unknown_session',detail:`Unknown session: ${root}`});
const bare=await invoke('neo.session.link',{session:'native-thread'});assert.equal(bare.adapter,'codex-desktop');assert.equal(bare.link,'codex://threads/native-thread');
for(const [session,adapter,link] of [['native-thread','codex-desktop','codex://threads/native-thread'],['codex-desktop:unsafe','codex-desktop',null],['codex-desktop:linkless','codex-desktop',null],['claude-desktop:native-session','claude-desktop','claude://claude.ai/epitaxy/native-session'],['local','hyperneo','/session/local'],['space-session','hyperneo','/session/space-session']] as const){
const result=await invoke('neo.publication.publish',{...draft,requestId:crypto.randomUUID(),session});assert(result.accepted,JSON.stringify(result));assert.equal(result.publication.sessionSource.adapter,adapter);assert.equal(result.publication.sessionSource.link,link);assert.equal(result.publication.session,session);
Expand All @@ -74,7 +74,7 @@ try{
reads.length=0;const page=await rpc(name,{conversationId,limit:100});assert.equal(page.ok,true);
const items=page.items as {role?:string;publication?:typeof first.publication;sessionSource?:{adapter:string}}[];
const publications=name==='neo.publication.read'?items:items.filter(item=>item.role==='neo').map(item=>item.publication!);
assert.equal(publications.length,9);
assert.equal(publications.length,8);
const current=publications.find(item=>item.publicationId===first.publication.publicationId)!;assert.equal(current.sessionSource.adapter,'codex-desktop');
assert(reads.filter(id=>id==='native-thread').length<=2,'repeated sessions share one resolution per page');
}
Expand Down
8 changes: 7 additions & 1 deletion .claude/skills/verify/publication-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ try {
})]);
app.sessionManager.getOperationRegistry = () => registry;
const invoke = createOperationMcpHandler(() => app.sessionManager.getOperationRegistry(), () => ({ sessionId: root, role: 'neo' }));
const publish = async (requestId: string, session?: string) => JSON.parse((await invoke({ name: 'neo.publication.publish', input: { requestId, text: 'Session update', details: 'This is the requested session.', session } })).content[0].text);
const publish = async (requestId: string, session?: string | null) => JSON.parse((await invoke({ name: 'neo.publication.publish', input: { requestId, text: 'Session update', details: 'This is the requested session.', session } })).content[0].text);
ws = new WebSocket(`ws://127.0.0.1:${app.server.port}/ws`, { headers: { authorization: `Bearer ${await readLocalCredential()}` } } as never);
await new Promise((resolve, reject) => { ws!.onopen = resolve; ws!.onerror = reject; });
const read = (name = 'neo.publication.read') => new Promise<{ ok: boolean; items: { session?: string; role?: string; publication?: { session?: string } }[] }>((resolve, reject) => {
Expand Down Expand Up @@ -103,6 +103,12 @@ try {
assert.equal((evidence.autoRetry as { accepted: boolean; created: boolean; publication: { session?: string } }).accepted, true);
assert.equal((evidence.autoRetry as { created: boolean }).created, false);
assert.equal((evidence.autoRetry as { publication: { session?: string } }).publication.session, worker);
const rows = (await read()).items.length;
evidence.nullRetry = await publish('source-proof', null);
assert.match((evidence.nullRetry as { reason: string }).reason, /^invalid_publication/);
evidence.neoRetry = await publish('source-proof', root);
assert.deepEqual(evidence.neoRetry, { accepted: false, reason: 'unknown_session', detail: `Unknown session: ${root}` });
assert.equal((await read()).items.length, rows);
evidence.final = await read();
const conversation = await read('neo.conversation.read');
evidence.conversation = conversation;
Expand Down
6 changes: 4 additions & 2 deletions packages/daemon/src/lib/neo/publication-operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ const createNeoPublisher = (runtime: NeoPublicationRuntime) =>
)
.pipe(
async (draft: Draft, proof: Proof, caller: OperationCaller) => {
const worker = workerSession(draft.session);
const worker = draft.session;
if (worker === null) return { reason: { accepted: false, reason: 'invalid_publication' } };
const prior =
worker === undefined
? runtime.publication(
Expand All @@ -267,7 +268,8 @@ const createNeoPublisher = (runtime: NeoPublicationRuntime) =>
: null;
if (prior) return { value: { ...proof, session: prior.session } };
const session = worker ?? workerSession(runtime.sourceSession(caller.sessionId!));
const status = session ? await runtime.lookupSession(session) : 'not_found';
const target = workerSession(session);
const status = target ? await runtime.lookupSession(target) : 'not_found';
return worker && status !== 'found'
? {
reason: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,27 +377,32 @@ describe('Neo publication without runtime input attribution', () => {
expect(ledger.list(conversationId)).toEqual([expect.objectContaining({ links })]);
});

test('session null is the same as no session', async () => {
test('session null is rejected as an invalid publication', async () => {
const handler = createOperationMcpHandler(createOperationRegistry([operation]), () => caller);
const reply = JSON.parse(
(await handler({ name: 'neo.publication.publish', input: { ...draft, session: null } }))
.content[0].text
);
expect(reply).toMatchObject({ accepted: true, created: true });
expect(ledger.list(conversationId)[0].session).toBeUndefined();
expect(reply.accepted).toBe(false);
expect(reply.reason).toStartWith('invalid_publication');
expect(ledger.list(conversationId)).toHaveLength(0);
});

test('Open never points at Neo: its own session is dropped, a worker is kept', async () => {
test('Open never points at Neo: its own session is rejected, a worker is kept', async () => {
const own = await publish({ ...draft, session: root.sessionId }, caller);
expect(own).toMatchObject({ accepted: true, created: true });
expect(ledger.list(conversationId)[0].session).toBeUndefined();
expect(own).toEqual({
accepted: false,
reason: 'unknown_session',
detail: `Unknown session: ${root.sessionId}`,
});
expect(ledger.list(conversationId)).toHaveLength(0);

sourceSession = root.sessionId;
await publish({ ...draft, requestId: 'send-two' }, caller);
expect(ledger.list(conversationId)[1].session).toBeUndefined();
expect(ledger.list(conversationId)[0].session).toBeUndefined();

await publish({ ...draft, requestId: 'send-three', session: 'worker' }, caller);
expect(ledger.list(conversationId)[2].session).toBe('worker');
expect(ledger.list(conversationId)[1].session).toBe('worker');
});

test('a stored Neo session is hidden from readers and left in the row', async () => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-types-baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"packages/daemon/tests/unit/1-core/operations/neo-project-tree.test.ts": 4,
"packages/daemon/tests/unit/1-core/operations/neo-prompt.test.ts": 1,
"packages/daemon/tests/unit/1-core/operations/neo-public-intake-wire.test.ts": 2,
"packages/daemon/tests/unit/1-core/operations/neo-publication-operation.test.ts": 11,
"packages/daemon/tests/unit/1-core/operations/neo-publication-operation.test.ts": 9,
"packages/daemon/tests/unit/1-core/operations/neo-publication-read.test.ts": 2,
"packages/daemon/tests/unit/1-core/operations/neo-publication-spoken.test.ts": 3,
"packages/daemon/tests/unit/1-core/operations/neo-reorganize.test.ts": 1,
Expand Down
Loading