feat(domain): family knowledge records — schema, invariants, Convex adapter, synthetic fixtures - #16
Conversation
…dapter, synthetic fixtures Implements the family-knowledge layer as a record type separate from logged events: source-attributed statements (statedBy/recordedBy/provenanceKind), kind-specific data (quote verbatim text + speaker, routine ordered steps), append-only supersession with validity windows, and conflict tolerance (multiple current items may share a topic and disagree — no automatic winner). - KnowledgeSchema (Effect v4, closed four-kind taxonomy: settling, routine, quote, preference — no medical kind; no invented conclusions) - assertKnowledgeInvariants: kind-specific data placement, normalized kebab topics, supersession windows, self-supersession, confidence/provenance consistency (1 = caregiver-confirmed; the model may never claim it), and mutually exclusive source attribution - knowledge table registered in the Convex schema via convexFields adapter (household/child/topic + supersession indexes) - six synthetic acceptance fixtures: nominal settling/routine/quote corpora, supersession chains, conflicting reports, and ten negative cases split by rejection layer (decode vs invariants) Relation to the Remember & Retrieve proposal (art_DUzlnxI9, v0.1): implements the shared core — separate record type, attribution, draft|published, append- only supersession — and extends it with topic slugs, kinds, confidence, and validity windows; the supersedes forward edge (matching Event lineage) vs their supersededById back-pointer is flagged for the v0.4 fold owner.
Independent review — verdict: fail (merge-blocked, rebase required) — code itself verified soundReviewed per the repo review→repair→merge workflow (acceptance criteria → full diff → independent verification at exact HEAD → checks). PR-owning thread keeps merge ownership; this review does not merge. Tested SHAs: PR head Acceptance criteria check (stated in body — all six verified against code + tests)
The four special checks
Blocking findings (2, same root cause)
Required repair (owner, per rule 5 — repairs invalidate prior evidence)Rebase — Independent reviewer thread (todo_CvG5gruV), verification only; no merge performed. |
673772c to
4a55019
Compare
Independent review — re-review after rebase: verdict pass-with-notes (updated from fail; prior round at
|
|
Replying to the independent review receipt — all points addressed on branch
Prior results per your special checks carry over by construction (no diff beyond the barrel union): Event.authorId remains untouched, scope stays confined to the ten family-knowledge files, and the module remains additive against the v0.3 fold. Awaiting your delta re-verification at |
|
Delta verdict: pass-with-notes at |
Evidence receipt — PR #16 |
…ess cases (#31) Write path (create + atomic append-only supersede) and bounded read path (listCurrent/listHistory) over the knowledge table, composed from the PR #16 canonical contract in packages/domain — no domain changes. Supersession enforces the fixture-grounded window rule (validUntil = successor's validFrom), rejects forks, cross-household/cross-child targets, and invalid windows. Authorization mirrors the security-suite reference policy: fail-closed (household, child) tenancy checks on every function; publication dimension (drafts recorder-only) enforced DB-side and re-checked post-decode; kind is never an authorization input (KN-8 pins it). Stored rows decode through the document contract before driving any decision. Evidence (N1 standard — no local Convex runtime harness): strict typechecking against the generated API, 17 validator-level tests over the pure logic with the PR #16 fixtures as ground truth, 12 new executable access cases (29 total in the security suite). Co-authored-by: Obvious <obvious@obvious.ai> Co-authored-by: Gilbert Polanco <gilbertpolanco42@gmail.com>
Acceptance criteria
packages/domain/src/knowledge.tsdefines a closed four-kind family-knowledge taxonomy (settling, routine, quote, preference) with source attribution, confidence, visibility, and validity windows — no medical kind, no invented conclusionsassertKnowledgeInvariantsenforces: kind-specific data placement (quote text/speaker on quotes only, ordered non-empty steps on routines only), normalized kebab-case topics, superseded⇒validUntil / current⇒no validUntil / never-inverted windows, no self-supersession, confidence 1 reserved for caregiver-confirmed (model-recorded items can never reach it), mutually exclusive source attribution (entry vs conversation vs manual), manual items carry no source spanknowledgetable registered via the testedconvexFieldsadapter, with household, child/topic, and supersession indexespnpm turbo run typecheck test buildgreen;bun test ./securitystill greenWhat this is
The family-knowledge layer as a record type separate from logged events: durable, source-attributed statements about the household that don't happen at a single time the way events do. Settling preferences, routines, verbatim child quotes, and changing preferences; append-only supersession with validity windows; and deliberate conflict tolerance — multiple current items may share a topic and disagree, because conflicting caregiver reports are a family reality, not a data error.
Deliberately scoped out (per the schema proposal): medical conclusions, automatic conflict winners, and audience data on the item itself — visibility is draft|published, and audience resolution stays with household/relationship grants.
Relation to the Remember & Retrieve contract proposal (art_DUzlnxI9 v0.1)
Implements the shared core (separate record type, attribution, draft|published, append-only supersession) and extends it with topic slugs, kinds, confidence, and validity windows. Two flagged deltas for contract-fold reconciliation: this schema uses a forward
supersedesedge (mirroring Event lineage) while the proposal uses asupersededByIdback-pointer; and it preservessourceQuotealongsidequoteText(verbatim words vs surrounding source wording).Verification evidence
673772c(branchfeat/family-knowledge-schema, based on32d1f00)bun test packages/domain/test/knowledge.test.ts)pnpm turbo run typecheck test— 9/9 tasks green on the working tree containing this commitbun test ./security— 17 pass / 0 fail at this SHAmastercommits; squash-merge will reconcile, or rebase on request before merge)Review notes
supersedesvssupersededById) and the statement-verbatim question are the two design points worth review attention; everything else follows the established domain/Convex adapter patterns from PRs feat(spike): prove Effect v4 canonical schema and adapters end-to-end (Entry + Event) #7–feat: scaffold pnpm + Turborepo monorepo with Effect v4 domain contracts #9.packages/domain/test/fixtures/knowledge/), disjoint from the evaluation corpus.