feat(registry): component_hash_id — stable id system for workflow references
Problem: canonical_id is readable but mutable; if a component is renamed,
all workflows referencing it by canonical_id break.
Solution: dual-id system
- component_hash_id: cmp_{sha256(canonical_id).slice(0,8)}, derived deterministically,
never changes, safe for workflow references
- canonical_id: human-readable name, used for search and display
- idx:{canonical_id} KV key: reverse-lookup index for resolving canonical_id → hash_id
Changes:
- types.ts: SandboxResult.component_id → component_hash_id + canonical_id,
added 'data' to category enum
- submitComponent.ts: deriveHashId(), writes idx: reverse-lookup on submit
- queryComponents.ts: full rewrite — removed KBDB dependency, uses SUBMISSIONS_KV;
supports both cmp_* and canonical_id as query id; Phase 0 keyword search
with note to upgrade to Vectorize in Phase 2
- sandboxAcceptance.ts: updated field names, fixed TextDecoder TS type
- ensureTemplate.ts: removed KBDB dependency, now a KV health check
- tests: updated component_id → canonical_id
- CONTRIBUTING.md: explain hash_id derivation and dual-id workflow reference syntax
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,7 @@ describe('runSandboxAcceptance', () => {
|
||||
const wasm = makeMinimalWasm(10);
|
||||
const result = runSandboxAcceptance(wasm, BASE_CONTRACT);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.component_id).toBe('validate_json');
|
||||
expect(result.canonical_id).toBe('validate_json');
|
||||
expect(result.version).toBe('v1');
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('runSandboxAcceptance', () => {
|
||||
expect(result.failed_step).toBe('size_check');
|
||||
expect(result.reason).toContain('超過上限');
|
||||
expect(result.guide_anchor).toBeDefined();
|
||||
expect(result.component_id).toBe('validate_json');
|
||||
expect(result.canonical_id).toBe('validate_json');
|
||||
expect(result.version).toBe('v1');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user