feat(zones): add 'incoming' quarantine zone#30
Conversation
kb had only active|established|archive (SQLite CHECK). Downstream (mykb-curator) assumed an 'incoming' quarantine zone for unverified agent/LLM-proposed entries that never existed: passing --zone incoming wrote the JSONL line and then crashed on the CHECK constraint, splitting JSONL vs db. - types.ts: Zone gains Incoming='incoming' (lifecycle: incoming -> active -> established; archive out-of-circulation). - db.ts: SCHEMA_SQL CHECK includes 'incoming'. kb rebuild (which unlinks + recreates the db from JSONL) is the migration path for existing brains. - knowledge-store: persistEntry validates the zone is a known Zone BEFORE the JSONL append, so an invalid zone throws cleanly with no orphaned JSONL line (closes the split-brain hazard for any invalid zone, not just 'incoming'). - knowledge-store: verifyEntry on an entry currently in zone 'incoming' also moves it to 'active' (verifying falsifies the unverified predicate that placed it in incoming). Verify on any other zone stays provenance-only. - cli.ts / kb-load.ts: --zone help + tool enum list 'incoming'. kb add still defaults to 'active' — quarantine is opt-in via --zone incoming (operator authoring is trusted; the agent/curator path passes the flag explicitly). Design decisions recorded in kb (mykb area) J2N6eo8S + ei2k4oZF. Enables mykb-curator#2. Tests: +6 incoming-zone cases in knowledge-store.test.ts (accepts incoming, default stays active, verify(incoming)->active, verify non-incoming unchanged, invalid zone rejected pre-JSONL). Full suite 655/655, tsc + eslint + prettier clean.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR adds an "incoming" zone state to the knowledge base system. Entries can now be created in the incoming zone, which serves as a quarantine state before verification transitions them to active. The change updates the database schema, type definitions, CLI and tool schemas, adds zone validation logic, implements state transitions on verification, and includes comprehensive test coverage. ChangesIncoming Zone Feature
Sequence Diagram(s)sequenceDiagram
participant Client
participant persistEntry
participant verifyEntry
participant updateEntry
Client->>persistEntry: addFact(entry with zone)
persistEntry->>persistEntry: validate zone in Zone enum
alt zone is invalid
persistEntry-->>Client: throw EntryValidationError
else zone is valid
persistEntry->>updateEntry: appendEntry + dbUpsert
end
Client->>verifyEntry: verifyEntry(entryId)
verifyEntry->>verifyEntry: check if zone is Incoming
alt zone is Incoming
verifyEntry->>updateEntry: update zone to Active + provenance to Verified
else zone is not Incoming
verifyEntry->>updateEntry: update provenance to Verified only
end
updateEntry-->>Client: entry updated
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes the pyramid gap on PR #30: knowledge-store had the core coverage but nothing exercised the curator's actual path — ShellKBWriter shells `kb add ... --zone incoming` then a human `kb verify`s it. Adds CLI/integration tests via the real cli.js: --zone incoming persists incoming; no --zone still defaults active (J2N6eo8S); verify on incoming -> active + provenance verified (ei2k4oZF); an invalid zone exits 1 with NO orphan JSONL line. Full suite 659/659; tsc + eslint + prettier clean. Migration validated out-of-band on a copy of the real ~/.mykb (kb rebuild lossless 2907->2907, schema CHECK gains incoming, end-to-end add/ verify/invalid-guard all correct). Co-authored-by: Jason Viloria <jason.viloria@optiscangroup.com>
Why
kbhad onlyactive|established|archive(enforced by a SQLite CHECK). Downstream,mykb-curatorassumed anincomingquarantine zone for unverified LLM/agent-proposed entries that never existed —--zone incomingwrote the JSONL line and then crashed on the CHECK constraint, splitting JSONL vs db (mykb-curator#2; kb gotchavwpvk7lQ).What
types.ts:ZonegainsIncoming='incoming'(lifecycle: incoming → active → established; archive out-of-circulation).db.ts:SCHEMA_SQLCHECK includes'incoming'.kb rebuild(unlinks + recreates db from JSONL) is the migration path for existing brains.knowledge-store.persistEntry: validates the zone is a knownZonebefore the JSONL append → invalid zone throws cleanly, no orphaned JSONL line (closes the split-brain hazard for any invalid zone).knowledge-store.verifyEntry: on an entry currently in zoneincoming, also moves it toactive(verifying falsifies the unverified predicate that placed it there). Verify on other zones stays provenance-only.cli.ts/kb-load.ts:--zonehelp + tool enum listincoming.kb addstill defaults toactive— quarantine is opt-in via--zone incoming. Design decisions recorded in kb (mykbarea):J2N6eo8S(default stays active; opt-in),ei2k4oZF(verify(incoming)→active).Tests
+6 incoming-zone cases in
knowledge-store.test.ts(accepts incoming; default stays active; verify(incoming)→active; verify non-incoming unchanged; invalid zone rejected pre-JSONL). Full suite 655/655,tsc+eslint+prettierclean.Enables mykb-curator#2.
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes