From 6e9a398cdcbebe5b56f6588b008814298c4ba6e7 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 15 Jul 2026 11:03:14 -0600 Subject: [PATCH] refactor(contract): remove knowledge candidate schema versions --- README.md | 2 +- package.json | 7 ++++--- pnpm-lock.yaml | 22 +++++++++++----------- src/file-transaction.ts | 4 ---- src/kb-improvement.ts | 7 ------- tests/agent-candidate.test.ts | 6 ++++-- tests/file-transaction.test.ts | 1 + 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 28f96c6..2f31388 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,7 @@ console.log(promoted.promoted) Calling it again with the same `runId` resumes interrupted work. `withKnowledgeImprovementCandidate` materializes the measured bytes in an isolated temporary directory for the callback, checks them again afterward, and removes the directory. `promoteKnowledgeCandidate` applies only the frozen bytes identified by the approved candidate reference, and refuses if the live base changed. -The current release intentionally accepts only its strict run-state format; incomplete runs created by 1.x must be completed or restarted before upgrading. +The current release accepts one strict run-state format; incomplete runs created before 3.0 must be completed or restarted before upgrading. The exact candidate workflow requires Linux; other knowledge, retrieval, and evaluation APIs remain cross-platform. If a required phase is missing its hook, the loop throws. diff --git a/package.json b/package.json index a739a66..04caff6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tangle-network/agent-knowledge", - "version": "2.0.1", + "version": "3.0.0", "description": "Source-grounded, eval-gated knowledge growth primitives for agents.", "homepage": "https://github.com/tangle-network/agent-knowledge#readme", "repository": { @@ -68,8 +68,8 @@ "format": "biome format --write src tests" }, "dependencies": { - "@tangle-network/agent-eval": "^0.119.1", - "@tangle-network/agent-interface": "^0.26.1", + "@tangle-network/agent-eval": "^0.121.0", + "@tangle-network/agent-interface": "^0.28.0", "proper-lockfile": "4.1.2", "zod": "^4.3.6" }, @@ -88,6 +88,7 @@ "minimumReleaseAge": 4320, "minimumReleaseAgeExclude": [ "@tangle-network/agent-eval", + "@tangle-network/agent-interface", "@tangle-network/sandbox" ], "overrides": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58d0ce4..a328ecd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,11 +13,11 @@ importers: .: dependencies: '@tangle-network/agent-eval': - specifier: ^0.119.1 - version: 0.119.1(typescript@5.9.3) + specifier: ^0.121.0 + version: 0.121.0(typescript@5.9.3) '@tangle-network/agent-interface': - specifier: ^0.26.1 - version: 0.26.1 + specifier: ^0.28.0 + version: 0.28.0 proper-lockfile: specifier: 4.1.2 version: 4.1.2 @@ -633,8 +633,8 @@ packages: '@tangle-network/agent-core@0.4.11': resolution: {integrity: sha512-5B1IjrJ8xDR7w8Hv/MSk2ixul6NEJQ5Ftzo+z6l7ipeFpc0yaf1+Kkml4HDUEmGW/rqdrNpBf9/MpT7i/SY0PA==} - '@tangle-network/agent-eval@0.119.1': - resolution: {integrity: sha512-BkxjITX5FnEjCpZH7iYCmS6puE3iMkSZf5kKZVYQxxQZx/VYj6QBj01vhCdRSKbVSjJkh610A/G0m676yIQ9jw==} + '@tangle-network/agent-eval@0.121.0': + resolution: {integrity: sha512-rBfwbK984Ro3Yeml2rVfJYojw1R9R1awRI0IIAf15V5jOrT7X4yHJYW8l73Qk3jHwdyISRLjB8jFmzdj3G14yQ==} engines: {node: '>=20'} hasBin: true @@ -647,8 +647,8 @@ packages: '@tangle-network/agent-interface@0.26.0': resolution: {integrity: sha512-/z4HavFr/9AbaHxi/13bFP9iSUt8oitZbw4wS9g9KAt2TeN2ec5/A2C106udWkKIETZLnu465TfU+K4KDVNkKw==} - '@tangle-network/agent-interface@0.26.1': - resolution: {integrity: sha512-NnQIWtudBHt1P6UXeLMAXUUUxjbYlMLuO3x7yGUGuGWkGcJ0EK0Gpv6aI81g+uqpsV1aHQ4gYfDTCVpdNICUeA==} + '@tangle-network/agent-interface@0.28.0': + resolution: {integrity: sha512-OFI0HPVviHOV1SWG7s6sQMMAkofQkWDrhtUHZUlNAO48WOhT7RllskgS/qaWegOZWZlROoKY3NHg1nHopNgg+A==} '@tangle-network/sandbox@0.9.7': resolution: {integrity: sha512-9pCwJ5MlF7RUpp0AQKQDFyR0yu+E0udEhWkqhrlb/RuoJxlt72zVPuzO4FnMb1MZTkfjStmomC3k5xQyqi1YSA==} @@ -1528,13 +1528,13 @@ snapshots: '@tangle-network/agent-interface': 0.26.0 zod: 4.4.3 - '@tangle-network/agent-eval@0.119.1(typescript@5.9.3)': + '@tangle-network/agent-eval@0.121.0(typescript@5.9.3)': dependencies: '@asteasolutions/zod-to-openapi': 8.5.0(zod@4.4.3) '@ax-llm/ax': 23.0.0(zod@4.4.3) '@hono/node-server': 2.0.1(hono@4.12.30) '@tangle-network/agent-core': 0.4.11 - '@tangle-network/agent-interface': 0.26.1 + '@tangle-network/agent-interface': 0.28.0 '@tangle-network/tcloud': 0.4.14(typescript@5.9.3)(zod@4.4.3) hono: 4.12.30 zod: 4.4.3 @@ -1560,7 +1560,7 @@ snapshots: '@noble/hashes': 1.8.0 zod: 4.4.3 - '@tangle-network/agent-interface@0.26.1': + '@tangle-network/agent-interface@0.28.0': dependencies: '@noble/hashes': 1.8.0 zod: 4.4.3 diff --git a/src/file-transaction.ts b/src/file-transaction.ts index 361440c..f1bb67a 100644 --- a/src/file-transaction.ts +++ b/src/file-transaction.ts @@ -31,7 +31,6 @@ const transactionEntrySchema = z .strict() const transactionSchema = z .object({ - schemaVersion: z.literal(1), kind: z.literal('knowledge-file-transaction'), transactionId: z.string().uuid(), purpose: z.string().min(1), @@ -41,7 +40,6 @@ const transactionSchema = z .strict() const transactionDirectionSchema = z .object({ - schemaVersion: z.literal(1), transactionId: z.string().uuid(), direction: z.literal('rollback'), }) @@ -158,7 +156,6 @@ export async function prepareKnowledgeFileTransaction(input: { } } const transaction = transactionSchema.parse({ - schemaVersion: 1, kind: 'knowledge-file-transaction', transactionId: randomUUID(), purpose: input.purpose, @@ -397,7 +394,6 @@ export async function rollbackKnowledgeFileTransaction(input: { const direction = await readTransactionDirection(transactionDir, transaction) if (direction !== 'rollback') { await writeJsonDurable(join(transactionDir, 'direction.json'), { - schemaVersion: 1, transactionId: transaction.transactionId, direction: 'rollback', }) diff --git a/src/kb-improvement.ts b/src/kb-improvement.ts index af38885..931919b 100644 --- a/src/kb-improvement.ts +++ b/src/kb-improvement.ts @@ -131,7 +131,6 @@ export interface KnowledgeImprovementCandidateRecord { } export interface KnowledgeImprovementRunState { - schemaVersion: 1 runId: string root: string goal: string @@ -243,7 +242,6 @@ const candidateRecordSchema = z export const KnowledgeImprovementRunStateSchema = z .object({ - schemaVersion: z.literal(1), runId: runIdSchema, root: z.string().min(1), goal: z.string().min(1), @@ -351,7 +349,6 @@ export const KnowledgeImprovementRunStateSchema = z export const KnowledgeImprovementEvidenceSchema = z .object({ - schemaVersion: z.literal(1), kind: z.literal('knowledge-improvement-evidence'), runId: runIdSchema, candidateId: safePathSegmentSchema, @@ -373,7 +370,6 @@ export type KnowledgeImprovementEvidence = z.infer { fromAgentCandidateKnowledgeRef({ ...shared, candidateHash: 'sha256:bad' }), ).toThrow() }) + + it('rejects obsolete schema markers', () => { + expect(() => fromAgentCandidateKnowledgeRef({ ...sharedCandidate, schemaVersion: 1 })).toThrow() + }) }) diff --git a/tests/file-transaction.test.ts b/tests/file-transaction.test.ts index c2a2052..2a21f32 100644 --- a/tests/file-transaction.test.ts +++ b/tests/file-transaction.test.ts @@ -55,6 +55,7 @@ describe('knowledge file transactions', () => { ], }) expect(prepared).not.toBeNull() + expect(prepared).not.toHaveProperty('schemaVersion') await expect( applyKnowledgeFileTransaction({