Run-report sink: cross-project agent decision intelligence¶
Date: 2026-08-21
Status: Draft spec — not yet scheduled
Companion: docs/spikes/2026-08-21-cross-project-memory.md@4a387c0b (the personal memory
architecture this plugs into), docs/plans/2026-07-23-context-memory.md@4a387c0b (lessons v0 +
Phase 4 distiller constraints this must stay consistent with).
Problem¶
kew records rich per-run evidence (RunRecords, audit chain events, review verdicts, cost/cache metrics), but it is trapped per-repo and per-store. An operator running kew across several repos has no way to ask cross-project decision questions — "which model handles docs PRs well", "what did runs shaped like this cost", "how did this failure mode resolve last time" — without hand-mining each repo's run_store. The evidence exists; the corpus doesn't.
Shape¶
Every kew-orchestrated run, in every repo, exports one small markdown run report to
a single machine-level sink. The sink is plain files; retrieval stays out of scope
(any indexer — Basic Memory, grep, a future kew intel query — can sit on top).
Config¶
[run_reports]
enabled = false # default OFF; no behavior change until opted in
sink_path = "~/.local/share/kew/runs" # machine-level; overridable
- Per-machine setting (user-level config), honored by every repo's dispatch. A repo-level
kew.tomlmay override or disable (e.g. a client repo whose exhaust must stay local). - Reports land at
<sink_path>/<repo-slug>/<run-id>.md. Repo slug from the origin URL (fallback: directory name).
Report format (the contract)¶
Markdown with YAML frontmatter. Frontmatter carries ONLY kew-authored structured fields — the same D8/D9 discipline as the lessons distiller: no transcript text, no agent prose, no comment bodies.
---
run_id: ...
repo: kew
issue: 1234
task_labels: [feature, medium] # from the issue at dispatch time
model: ...
route: ... # routing decision + reason code if recorded
cost_usd: ...
cache_hit_rate: ...
bounces: 2 # corrective re-dispatches
review_verdict: clean|findings|failed
outcome: merged|closed|abandoned|in-flight
evidence: ["gh:pr#1240", "chain:evt..."] # attested event IDs, lessons-style
schema: 1
exported_at: ...
---
Body: a short mechanical rendering of the same fields plus the timeline of attested events. Nothing in the report is generated by an LLM.
- Missing fields are omitted, not fabricated — RunRecords are known to be under-populated (branch/complexity gaps, 2026-07-01 dogfood finding). Consumers must tolerate sparse frontmatter; the exporter must not block a run on export failure (write is best-effort, logged, never fatal to the run).
schema:version so the format can evolve additively.
Provenance and safety¶
- Every report cites chain-attested event IDs; a consumer can verify a claim against
kew audit verify. - Reports are untrusted-data when injected into any future prompt (same framing as lessons corpus fencing).
- No secrets by construction: frontmatter fields are an allowlist, not a dump.
- The sink is the operator's own exhaust on their own machine. Nothing leaves the machine.
Scope boundary¶
- In scope (this spec): the write side — config key, exporter, report format. One human reading their own machine's exhaust; aligns with evidence/docs-truth ethos. Additive: no schema migration, one post-run write.
- Out of scope (not scheduled): everything that turns the
corpus into intelligence — semantic retrieval (
kew intel query), the promotion ladder (report patterns → distilled lessons), routing feedback (scorecard consumes the corpus), fleet/multi-operator aggregation.
Implementation sketch (single sized issue)¶
[run_reports]config section (user-level + repo override), default off. (Amended at implementation: named[run_reports], not[reports]—[report]already carries evidence-pack branding and the near-collision invited config typos.)- Exporter: on run terminal state (and on outcome transitions like merge detection,
where kew already observes them), render frontmatter from RunRecord + audit events,
write atomically to the sink. Best-effort; failures log and never fail the run.
(Amended at implementation: two export points — the end of the dispatch terminal
tail, after the completion audit event and runner evidence land, and an idempotent
re-export from
sync_outcomesonce the PR's fate settles, which is whereoutcome: mergedbecomes true. Runs reaped as orphans are documented as not exported; the run store stays the system of record.) - Tests: report rendering from a fixture RunRecord (sparse and full), sink path resolution/override, export-failure-is-non-fatal.
- Docs: one page under docs/ describing the format as a stable contract.
Out of scope here: any retrieval/index/RAG feature, backfill of historical runs
(possible later as kew reports backfill, separate issue if wanted).
Sizing¶
medium — touches config, a new small module, and the run terminal path, but no
schema change and no new surface beyond a file write.