Repository navigation
feat(memory): persistence master switch + context injection toggles - #10213
Conversation
4306431 to
a09f3f1
Compare
a09f3f1 to
33d9c8e
Compare
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The switch's "no automatic memory writes" promise ships with a hole: the ops app's ledger sweep still writes episodic rows while persistence is off. WatchThe PR's own inventory register marks [DESIGN-REVIEWED] 5249a96 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the admitted hole: with persistence off, ops_mission_control's ledger sweep still writes episodic rows — the diff itself defers that to a maintainer ruling. Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: give operators a standing off switch for persistent memory and its context injection (#9959, #9909's disable half) — an ADDITION, defaults preserving current behavior.
[FIRST-PRINCIPLES-REVIEWED] 5249a96 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
33d9c8e to
eac9737
Compare
eac9737 to
f741f1b
Compare
|
Thanks — the Watch is legitimate and is now addressed by the second option you named. Pushed in Watch (write-side has no chokepoint) — fixed via the inventory ratchet. I did not take the store-layer backstop, deliberately: the storage layer cannot be the gate without taking away the right to forget, since explicit dashboard edits and deletions must keep working while the switch is off. An "explicit-write flag" would push that policy decision into every call site anyway, which is the same drift surface one layer down. So One detail worth flagging: the scan matches an attribute reference, not only a call. The offloading writers hand the bound method to a pool ( A gap the inventory surfaced, which I'd like a ruling on. Building the register turned up an automatic writer neither of us had counted: Suggestion (the |
f741f1b to
42137f4
Compare
42137f4 to
0528612
Compare
|
Backend is green on The three remaining reds are not from this diff:
Could a maintainer re-run those two lanes? I have no re-run permission on a fork PR. |
ca144d8 to
e98684f
Compare
|
Status on
Nothing left on this PR is mine. Both remaining blockers clear on their own — the shards once |
e98684f to
63fb62a
Compare
63fb62a to
58dd849
Compare
|
Green on Taking the GPT finding in Added
|
Add three memory.* config keys wired end to end: - persistence_enabled (the global switch, kirodotdev#9959): off stops every automatic persistent-memory writer -- POST /api/lessons (the learn_add MCP tool's enforcement point), kirocrew learn add, task-runner lesson extraction, and history consolidation (all three automatic entry points plus _consolidate itself, so the manual REST/CLI triggers are covered and no LLM turn is billed) -- and withholds the stored memory/lessons blocks from new-session context. Within-conversation context is untouched; reads and deletions stay available. - inject_memory / inject_lessons (kirodotdev#9909, injection half): withhold the corresponding context group on the main path. Enforcement intersects the caller-passed context_groups with the config-enabled set inside build_session_context, the one method all surfaces pass through, so no call site changes. The member-essentials builder and the post-compaction re-injection in build_message route through the same intersection, because each restores a block the session-start build gates. The [CONTEXT SCOPE] block stays keyed to the caller-passed scope: config withholding is the operator's standing choice, not the parent's. The CLI refusal sits ahead of the vector store, whose construction creates or migrates memory.db, so a refused write leaves nothing behind. Closes kirodotdev#9959 Refs kirodotdev#9909 (size caps await a maintainer ruling on config shape)
58dd849 to
5249a96
Compare
Problem / Motivation
Two open asks against the memory subsystem:
SWITCHABLE_CONTEXT_GROUPS/_group_included) already exists but is only reachable from subagent spawns — the dashboard/channel/cron paths never passcontext_groups.Why it matters
Users who cannot trust or audit accumulated memory today have no off switch short of deleting their store and hoping nothing re-writes it. Power users tuning context budgets have no lever at all — the blocks are unconditionally injected on every surface. Both issues were routed
needs-humanby the repo's triage pipeline with the note that the mechanism is nearly pure exposure.What changed (motivation → approach → change)
Goal: one coherent config surface covering both asks, rather than two competing switches.
Approach: intersect the operator's config with the caller-passed
context_groupsinsidebuild_session_context— the one method every surface (dashboard, hooks, Slack, Discord, generic channels, cron, heartbeat, monitor, task runner, eval, subagents) passes through — instead of threading a new parameter through the ten call sites that don't pass one. Subagent narrowing is preserved (intersection); the[CONTEXT SCOPE]block stays keyed to the caller-passed scope only, because "your parent withheld" describes per-spawn narrowing, not the operator's standing choice. Write-side enforcement sits at service boundaries rather than inside the storage layer, so the existingcapabilities.memory_writesgovernance gate (a per-surface policy mechanism on one MCP call site) is left intact and the two compose.Built:
memory.persistence_enabled(master, defaulttrue): off stops every automatic writer —POST /api/lessonsrefuses with403/code: persistence_disabled(the enforcement point behind thelearn_addMCP tool),kirocrew learn addrefuses with an actionable message, task-runner lesson extraction skips before its LLM call, and history consolidation pauses entirely (all three automatic entry points plus_consolidateitself, so the manual REST/CLI triggers are covered and no LLM turn is billed; the existingREFUSEDsentinel keeps offsets unadvanced). It also withholds the stored memory/lessons blocks from new-session context. Untouched by design: within-conversation context, reads, explicit deletions (the right to forget), and explicit dashboard edits.memory.inject_memory/memory.inject_lessons(defaulttrue): withhold the corresponding context block, durably via config.Out of scope, deliberately: the size-caps half of #9909 (two mutually exclusive config shapes proposed; awaiting a maintainer ruling), the "queue memories for review" mode from #9959 (overlaps the candidate-tier discussion in #9983 / #2149), and a Settings UI toggle (config.json +
kirocrew config setwork today).Tests
test/test_memory_context_toggles.py: presence/absence of each block with seeded content; config∩subagent intersection in both directions (config off beats an explicit full-scope parent; subagent narrowing survives config all-on); config withholding emits no[CONTEXT SCOPE]marker; consolidation gates (all three entry points schedule nothing when disabled, an enabled-path control test, and_consolidateitself returns theREFUSEDsentinel — covering the manual triggers);POST /api/lessons403 with the machine-readable code; CLI refusal with nothing written to either store.test/test_config_loader.py::TestMemoryPersistenceAndInjectionToggles: house-style default / override / junk-rejection tests for all three keys (_safe_boolsemantics).config-baseline.jsonregenerated; baseline drift and error-code ratchet tests green.Manual verification
Ran the gateway with an isolated data home; flipped each key in
config.json(picked up live via the fingerprint cache, no restart): withinject_lessons: falsea new session's context carries no[Learned corrections]/[USER PROFILE]block; withpersistence_enabled: false,learn_addreturns the refusal text,kirocrew learn addprints it, and no consolidation fires past the 30-message threshold ("consolidation skipped … persistence_enabled" in the log).Full local gate on this host: backend suite 94,494 passed with 21 failures, all of which reproduce identically on a clean
origin/maincheckout (host-environmental:test_symbols_manifest_contract.py×14, PTY terminal ×2, ksh installer, pptx provision, spawn-exec OverflowError, apps deps lock);isort/flake8/mypyclean; frontend cross-surface guard specs 6606/6607 (the one failure is a pre-existing flake that passes in isolation on both this branch and main).Related Issues
Closes #9959. Refs #9909 (size caps left for a follow-up pending a config-shape ruling — see my comment on the issue).
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
N/A — CLA text pending per the template placeholder; I agree to license this contribution under the repository's license (Apache-2.0).