feat: honest session receipt — attribution, stop-hook receipt, hygiene, forecast + goal.md decomposition - #55
Merged
Merged
Conversation
…eipt, hygiene, forecast, trust stats + goal.md decomposition - src/engine/activity.ts: ActivityEvent gains optional source/file/rawTokens/ storedTokens/kind (legacy lines parse); CAP 1000 behind a 300KB size gate; since(ts) with rotation-honest trimmed flag (only claims at CAP scale); session-aware trim via protectSince (ceiling 5000) - src/engine/receipt.ts (new): pure buildReceipt (consumed/avoided, top-5 sinks, hygiene offenders, integrity, plan-only labeled forecast, lifetime trust stats, honest-zero no-claims path) + session marker & hygiene helpers with bounded-CAS writes (newer-mtime-wins merge so a reset survives a race) - src/engine/onboard.ts: goalCheckboxes decomposes per-domain from goal clauses; no meaningful split -> ONE checkbox + coverage note (kills the 9x-duplicate goal.md) - hooks: sessionstart writes the session mark; pretooluse tracks repeat-reads + redirects (saved:0 by contract — knitbrain_read counts once); posttooluse records source:hook ledger events; stop emits the receipt as systemMessage through the adapters (claude/codex/vscode; cursor/gemini stay silent — their stop channels are behavioral contracts, not display surfaces) - mcp: capture/pendingLedger attribute optimize+read savings; context_meter returns the receipt mid-session; load_session marks hook-less hosts - proxy: records source:proxy ledger events; paths honor KNITBRAIN_PROJECT_DIR so helper processes land in the right project 560 tests, rm -rf dist && npm run verify EXIT=0
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.
What (Build 2 — THE RECEIPT, docs/LOOP-ENGINEERING.md Tier-1.2)
Savings were computed then thrown away — one invisible meter number. Now every optimization event is attributed and the session ends with an honest receipt.
{source, rawTokens, storedTokens, saved}into the ONE activity ledger (extended backward-compatibly; CAP 1000 behind a size gate; session-aware trim protection).systemMessage) via the Build-1 adapters on claude/codex/vscode; cursor/gemini stay silent by design (their stop channels are behavioral contracts) and get it viaknitbrain_context_meter, which now returns the receipt mid-session.KNITBRAIN_PROJECT_DIRoverride so helper processes (proxy) land state in the right project.Verification
rm -rf dist && npm run verifyEXIT=0 (560 tests). Live smoke on the built binary: seeded 3-door fixture session → claude Stop printed the receipt with exact sums, cursor stop printed nothing, honest-zero and rotation-disclaimer paths verified (smoke caught + fixed a trimmed-flag false positive unit tests missed).Not in this PR
No version bump, no publish — gated on explicit OK. After merge: bump 0.18.0 (package.json + src/version.ts), publish, then Build 1 regression + Build 2 fresh live tests, separately and combined.