Skip to content

Commit 91dc195

Browse files
committed
test(runtime): await the plugin registrations; the duplicate door asks the service with its door
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
1 parent 92adc8f commit 91dc195

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/service-knowledge': patch
3+
'@objectstack/metadata-core': patch
4+
---
5+
6+
fix(service-knowledge): a package duplicate that the knowledge service itself refuses is told the source cannot be copied and to duplicate the package again
7+
8+
Clause-②: yes (widening) — `@objectstack/service-knowledge`'s `KnowledgeService.admitAuthoredSource` takes an optional third input `options: { door?: 'save' | 'duplicate' }`; `@objectstack/metadata-core`'s `KnowledgeSourceSaveAdmitter.admitAuthoredSource` declares the same optional `options` input
9+
Metadata-protocol: none
10+
11+
- **`@objectstack/service-knowledge`.** `admitAuthoredSource(item, ctx, { door: 'duplicate' })` words every verdict for the package duplicate's caller: the source "cannot be copied", a verdict that could not be judged ends "Duplicate the package again.", and a field the caller may not query is fixed by removing it and duplicating the package again, or by someone who may query it duplicating the package. It never says "save the source" or "Nothing was written". The status, code, object and field are the same as at a save. With no `door`, or `door: 'save'`, every sentence is byte-identical to before.
12+
- **`@objectstack/metadata-core`.** `authoredKnowledgeSourceRefusal({ door: 'duplicate' })` hands the door on to the knowledge service's `admitAuthoredSource`, so the package duplicate's refusal says once, in its prefix, that nothing was copied. A save hands on no door: the service is asked with the item and the context alone, as before.

‎packages/runtime/src/domains/packages-knowledge-source-gate.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ describe('/packages — duplicate admits each knowledge source it copies for the
252252
expect(r.response?.body?.error?.message).toContain('nothing was copied');
253253
expect(r.response?.body?.error?.message).toContain(REFUSAL.message);
254254
expect(s.protocol.duplicatePackage).not.toHaveBeenCalled();
255-
// Judged as the caller, on the item the package holds.
256-
expect(s.admitAuthoredSource).toHaveBeenCalledWith(SOURCE_ITEM, caller.executionContext);
255+
// Judged as the caller, on the item the package holds, and asked for this door's wording.
256+
expect(s.admitAuthoredSource).toHaveBeenCalledWith(SOURCE_ITEM, caller.executionContext, { door: 'duplicate' });
257257
});
258258

259259
it('every source is asked about: the second one refused refuses the duplicate', async () => {
@@ -498,8 +498,8 @@ describe('/packages duplicate and /meta save on a real kernel running KnowledgeS
498498
},
499499
} as Plugin;
500500
const kernel = new ObjectKernel({ gracefulShutdown: false, skipSystemValidation: true });
501-
kernel.use(host);
502-
kernel.use(new KnowledgeServicePlugin({ enableEventSync: false }));
501+
await kernel.use(host);
502+
await kernel.use(new KnowledgeServicePlugin({ enableEventSync: false }));
503503
await kernel.bootstrap();
504504
const knowledge = kernel.getService<KnowledgeService>('knowledge');
505505
knowledge.registerAdapter('memory', { id: 'memory', upsert: async () => undefined, delete: async () => undefined, search: async () => [] });

0 commit comments

Comments
 (0)