feat(retrieval): bounded read-only history query path over synthetic corpus - #24
Merged
Merged
Conversation
…corpus Adds @journal/retrieval: query contracts (input, plan, tagged answer union) as the executable form of a rule-2 proposal for the contract v0.3 fold; a deterministic 30-day two-child synthetic corpus with pinned gaps, append-only corrections, conflicting authors, and confirmed events; a bounded NL->plan resolver with zone-aware windows; and a read-only executor returning cited answers with AnswerCoverage (T2) plus correction/conflict/gap notices. 14 hand-derived expected-answer fixtures, 22 bun tests: contract decoding, corpus validity, determinism, read-only discipline, superseded-event exclusion, and citation source navigation. Canonical promotion into packages/domain is intentionally not self-landed here. Co-authored-by: Gilbert Polanco <gilbertpolanco42@gmail.com>
Contributor
Author
Evidence receipt — merged |
Contributor
Author
Post-merge verification — independent reviewer verdict: PASS-WITH-NOTESIndependent review thread (todo_s2shMqeo); this thread did not merge — merge ownership stayed with the remember-retrieve lane. Verification ran against the merge commit; the lane receipt above covers the merger fields, this comment is the reviewer field. Criterion results (all verified at the SHAs above)
Notes for the coordinator
|
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human author: Gilbert Polanco (gilbertpolanco42@gmail.com)
Acceptance criteria
HistoryQueryInput,HistoryQueryPlan,HistoryQueryAnswer) exist as the executable form of a proposal inpackages/retrieval/src/queryContracts.ts; canonicalpackages/domainis NOT modified, and the contracts reuse canonicalEventFields.category+convexId()so a later promotion into the v0.3 fold derives identical validators.packages/retrieval/test/expectedAnswers.ts, derived from the corpus timeline, not from running the implementation (slot 03's fixture branch never existed remotely, so the brief's deterministic fallback applies).Why
Slots 15/17 (NL history queries, resumable context) are blocked on having a grounded query surface to target. The product needs caregivers to ask "when did Ada last nap?" and get an answer that cites its sources, discloses what it does not know, and never silently serves corrected-away data. This PR builds that surface as an executable proposal: the shape slots 15/17 will implement against, proven on a corpus engineered so every retrieval behavior in scope is hand-checkable.
What
New package
@journal/retrieval(workspace member, turbo-covered):queryContracts.ts— proposal schemas: half-openQueryWindow;AnswerCitation(entryId + eventIds + verbatim excerpt);AnswerCoverage(confirmed/inferred/total — the T2 confidence/coverage disclosure, routed as a rule-2 proposal, not self-landed);AnswerNoticeunion (correction / conflict / gap); taggedHistoryQueryAnswer(found / ambiguous / clarify / not-found); taggedHistoryQueryPlan(last-event / count-events / probe-events / day-summary);HistoryQueryInputwith household scope, pinned child, asker zone.corpus.ts— deterministic 30-day fallback corpus (Aug 14–Sep 12 2026, EDT household): two children, alternating breakfast authors, a pinned Aug 22–23 entry gap, an append-only nap correction (Aug 20), conflicting pasta authors (Aug 17), a shared-dinner ambiguity source (Aug 30), a caregiver-confirmed school event (Sep 5). Every record decodes through canonical@journal/domainschemas at generation time (fail-fast); two runs are byte-identical.resolve.ts— bounded compiler: four question forms, activity lexicon, pronoun handling (clarifies rather than guesses; honors a pinnedchildIdscope), zone-aware windows (today,yesterday,this week,last week,on <date>,between a and b,since <date>) with two-pass offset convergence (DST-safe).engine.ts— read-only executor: supersession filtering (superseded events are never served), correction/conflict/gap notices bounded to the answered slice, deterministic citation order, ambiguity candidates (latest match per child), andresolveEntrySourcefor citation → verbatim record navigation.Deliberately excluded: canonical domain changes (v0.3 fold thread owns promotion), any Convex/mobile wiring, and any NL layer beyond the bounded inventory — richer NL targets the same plan schema.
How to Review
packages/retrieval/README.md(invariants), thenqueryContracts.ts(the proposal), then the fixture file — each fixture's expected statement/citations/coverage is hand-derived and commented with the corpus arithmetic.test/expectedAnswers.tshq-14 encodes a trust invariant: a pronoun question under a Milo-scoped view returns honestnot-found— never Ada's naps.HistoryQueryAnswerBEFORE deep-equal; that ordering caught a real contract violation during development (explicitwindow: undefinedrejected byoptionalKey).Test Evidence
Local verification on the tested HEAD
4baacf2(rebased onto master652ace5, lockfile conflict resolved by regeneration — full gates re-run post-rebase per repo rule 5):pnpm typecheck— 9/9 tasks passpnpm test— 5/5 tasks, retrieval suite 22/22 testspnpm build— 5/5 tasksbun test ./security— 17/17 (fail-closed access cases unaffected)🔗 Obvious Project · 🧵 Obvious Thread