feat(host): prompt ingestion as a local provider (ADR 0006)#44
Conversation
Treat the user's paste — the prompt's largest un-disciplined input — as a local, egress-free CGP provider. Intent passes through verbatim as query.goal; directory references become query.anchors; pasted evidence (logs, tables, code, notes) is deterministically segmented, content- addressed, and served as compact frames with the full bytes rehydratable via a [full] re-query. Host-side reference behavior (the ingestion-side dual of compose_context), so no wire, schema, or SPEC.md change — it uses only the representation fields ADR 0005 added. Honest by construction: token_cost and the inline content_digest are recomputed per representation served (B3), provenance is `derivation` (not `file`, F5-exempt), and verify is exact on immutable content. resolve:true is backed by a real, tested in-process rehydration path — the ADR reconciles this against ADR 0004's dead-flag removals. - contextgraph-host/src/ingest.rs (+ inline tests, sha256 KATs) - contextgraph-host/tests/prompt_ingest.rs — end-to-end via the real Host - docs/adr/0006-prompt-ingestion-as-a-local-provider.md - sha2 dependency (host crate only; types stays zero-dep beyond serde)
There was a problem hiding this comment.
Sorry @macanderson, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ingest wire-conformance test Verifying ADR 0006's "frames are wire-conformant" claim surfaced a real schema/serializer mismatch: the JSON Schema listed `provenance` and `relations` as globally required on a ContextFrame, but the reference serializer omits both when empty (skip_serializing_if=Vec::is_empty) and no frame-validity check requires either. Every ingest frame has no graph edges, so it failed schema validation. Prior schema coverage only validated hand-authored example transcripts, never Rust-serialized frames, so the mismatch sat unexercised. - schema: ContextFrame.required is now exactly id/kind/title/score/ token_cost; content stays governed per-representation by the existing allOf - contextgraph-conformance/tests/ingest_conformance.rs: validates real ingested frames (full/compact/reference) through check_frames, check_budget, representation_invariants, and the schema's required-key set + NDJSON envelope round-trip — the guard that catches serialized frames drifting from the schema - ADR 0006 + CHANGELOG updated to record the corrective schema fix Empirically confirmed: all three representations validate against schema/contextgraph-envelope.schema.json via jsonschema; existing examples still pass.
There was a problem hiding this comment.
Sorry @macanderson, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Filed the remaining follow-ups so nothing is left implicit:
Correction to the PR description's "Not in scope" note: this PR removed both |
What & why
The prompt's biggest un-disciplined input is the text a user pastes: a realistic turn mixes a log, a table, a directory reference, and the actual ask under one blob, and only the last is intent. Pasted whole it is re-sent verbatim every turn (no cache, no dedup), its cost is never accounted, nothing is content-addressed, and the model is handed material it must itself decide is mostly irrelevant.
This models the paste as a local, egress-free CGP provider — the ingestion-side dual of
compose_context. It's host-side reference behavior; no envelope shape orSPEC.mdchange, using only the representation fields ADR 0005 added.query.goal, verbatim (never rewritten — the one load-bearing UX guarantee)query.anchors(zero tokens; the graph provider resolves them)compactby default with the full bytes rehydratable via a[full]re-queryThe guarantee is not "zero wasted tokens" (relevance is only knowable downstream) but bounded default cost with lossless retrieval.
Honest by construction
token_costand the inlinecontent_digestare recomputed for the exact representation emitted (§B3) — never carried across a representation flipderivation, notfile, so it doesn't trip §F5 (a paste has no re-readable URI); the real hash lives incanonical_content_hashverifyis exact (valid / stale / gone), and the same paste dedups to one frameegress: false,LocalOnlyscope) ⇒ auto-permitted, no consent frictionresolve: truevs ADR 0004Serving compact/reference requires
resolve: true(representations_consistent). Unlike theupsert/subscribeflags ADR 0004 deleted,resolvehas a live consistency rule and a working, tested in-process rehydration path today (a[full]-preference re-query returns the full bytes from the store). The ADR spells this out; the wirecontext/resolvemethod remains a later phase.Wire conformance — and one corrective schema fix
Verifying "frames are wire-conformant" (not just Rust-invariant-conformant) surfaced a real, pre-existing schema/serializer mismatch: the JSON Schema listed
provenanceandrelationsas globallyrequiredon aContextFrame, but the reference serializer omits both when empty (skip_serializing_if = Vec::is_empty) and no frame-validity check requires either. Every ingest frame has no graph edges, so it failed schema validation. Prior schema coverage only validated hand-authored example transcripts — never Rust-serialized frames — so the mismatch sat unexercised.ContextFrame.requiredis now exactlyid/kind/title/score/token_cost(what the serializer always emits);contentstays governed per-representation by the existingallOf.jsonschema: all three representations validate againstschema/contextgraph-envelope.schema.json; existing examples still pass.Tests
contextgraph-host/src/ingest/tests.rs— segmentation, §B3 honesty across all three representations, representation invariants, SHA-256 known-answer vectors (incl. padding boundaries), content-addressed dedup, query budget/frame caps, verifycontextgraph-host/tests/prompt_ingest.rs— end-to-end through the realHost: fan-out, budget audit, byte-stablecompose,verify_framescontextgraph-conformance/tests/ingest_conformance.rs— real ingested frames (full/compact/reference) throughcheck_frames+check_budget+representation_invariants+ the schema's required-key set + NDJSON envelope round-trip (the guard that catches serialized frames drifting from the schema)cargo test --workspace,cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --all --check, andpython3 schema/validate-examples.pyall green. New direct dep:sha2(host crate only;contextgraph-typesstays zero-dep beyond serde).Not in scope (additive follow-ups)
Stack-trace parsing and richer tabular inference behind the existing
classifyseam; thecontext/resolvewire method; makingprovenancenon-required is left as-is (ingest frames always carry it).