Skip to content

fix(store): keep the keep-in-full marks across a pipeline rebuild and a restart - #1101

Merged
amiddavid merged 4 commits into
mainfrom
fix/1097-keep-marks-survive-rebuild
Nov 11, 2026
Merged

amiddavid merged 4 commits into
mainfrom
fix/1097-keep-marks-survive-rebuild

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change (needs the owner's yes before merge)

  • Who it affects: hosted tenants whose config changes, and any host after a restart, on a thread with an earlier expand.
  • Old: dedup compacts the expanded outputs again, and the warm cache is rewritten.
  • New: the outputs stay in full, and the cache is read.
  • How to turn it off: there is no switch. store.enabled: false removes all marks, but it also turns off every reversible offload. On a local install, --session-state=false stops the restart half only.
  • A fresh thread is not changed.
  • The dashboard's one-time expand charge also reads this mark (KeptVerbatim). After a restart a repair no longer charges the row a second time. This is the intended direction (charge once per session).

Summary

What we found

  • The marks live only in the Store.
  • A config change builds a new Store. A restart empties it.
  • isKeptVerbatim then answers no, and dedup compacts the output again.

What changed

  • Rebuild: proxy/tenancy.go copies the cg:keep: marks from the old Store to the new one. It does this only when the old and new pipelines have the same components in the same order.
  • Different components: nothing is copied. This behaves as before.
  • Restart: cg:keep: is now a metadata session-state key. The disk copy writes it. LoadSession reads it back.
  • Carried over: only the marks. Frozen decisions and stashed originals stay behind, as before.
  • New helper: store.CarryPrefix and Memory.EntriesWithPrefix. It fails open: an error or a panic copies nothing.
  • dedup on a fresh thread is not changed. Option B (expand.fixed_restore) is not used.

Data dependence

  • The key holds a session id and a content hash. The value is one byte. No content.
  • Off (store.enabled: false): nothing is stored. No marks, as today.
  • Metadata only: the mark is stored in memory, and on disk with --session-state-metadata-only.
  • Everything: the same as metadata only. This feature adds no content at any level.
  • docs/data-dependence.md has the new key in the session state row. docs: one file per data-dependence row, built into docs/data-dependence.md (#1088) #1090 is not on main, so I edited that file.

How it was tested

  • TestKeepMarksSurviveARebuildWithTheSameComponents (proxy): a rebuild with the same components keeps the mark.
  • TestKeepMarksDoNotSurviveARebuildWithDifferentComponents (proxy): a different set starts clean, as before.
  • TestDedupKeepsAnExpandedOutputAfterTheMarkIsCarriedToANewStore and ...AfterARestart (offload): dedup reports kept_verbatim_after_expand. The restart test uses a real disk copy at metadata only. A fresh store still compacts.
  • Mutation checks (each test fails when the fix is reverted):
    • Remove the carry call: the same-components test fails ("the keep mark was lost in the rebuild").
    • Remove the component-set check: the different-components test fails.
    • Remove KeptPrefix from the metadata prefixes: the restart test fails.
  • go vet ./... is clean. Race tests pass on ./store/..., ./components/all/..., ./components/offload/... and ./proxy/... (in two halves).
  • TestStateTTLAppliesOnlyToStateKeys used cg:keep: as its "not a state key" example. It now uses cg:other:.
  • No live API run.

Technical notes

  • The mark is not pinned. Pinning is a separate eviction decision.
  • A restored mark takes the state lifetime (24 h in memory with the disk copy), as other state keys do.
  • On a hosted proxy the session-state table is off, so only the rebuild half applies there.
  • A copied mark gets a fresh lifetime in the new Store.
  • Race (round 1): a second request can publish the rebuild first. The first request then carries its marks into the published tenancy. TestKeepMarksSurviveTwoConcurrentRebuilds forces this order. Without the fix it fails.
  • Open window: a mark written to the old Store after the copy is not carried. The window is milliseconds.
  • The carry decides on component names only. A change of expand.fixed_restore also carries the marks. That is the safe direction.

Fixes #1097.

Assisted-By: Claude Opus 5.5 [email protected]

… a restart

A tenant config change rebuilt the pipeline with a new Store, and a restart
emptied the Store. Both lost the cg:keep: marks, so dedup compacted an
expanded output again and the warm cache was rewritten.

- A rebuild with the same components copies the cg:keep: marks to the new
  Store (store.CarryPrefix).
- cg:keep: is now a metadata session-state key: the disk copy writes it and
  LoadSession reads it back after a restart.

Fixes #1097

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 cda198149 blocking

Verdict: blocking

Findings

  1. proxy/tenancy.go:641 — a concurrent request can still publish a rebuild that lost the marks.
    • What fails: a tenant config changes while the tenant has two requests in flight. Request A
      sees the old cache entry, captures prev, removes the entry, and starts a slow build.
      Request B arrives during A's build, finds the cache empty, so its prev stays nil, and it
      builds too. If B publishes first, A takes the c.config == cfgDoc branch at line 642 and
      returns B's tenancy, which carries no marks. The agent's expanded output is then compacted
      again and the warm cache is rewritten — the exact bug #1097 fixes, back through a race.
    • Proof: prev is set only under the first lock, and only when the cache still holds the old
      config (line 622). B enters tenancy() after s.cache.remove (line 623) and before A's
      s.cache.put (line 647), so B never sees the old entry. The second lock keeps whichever
      tenancy was published first (lines 641-644). B can finish first: A pays the cold build
      (tree-sitter parsers, tokenizer tables, per the comment at line 629), while B's build reuses
      warm package-level caches. The file's own comment at line 608 calls one agent with two turns
      in flight "not a rare interleaving".
    • Fix: carry into the tenancy that is actually returned. In the c.config == cfgDoc branch,
      run carryKeepMarks(prev, c.t) before return c.t, nil. This is idempotent and safe:
      Memory.Put holds its own lock, and the expand path already writes marks into a published
      store concurrently.

Non-blocking

  • components/offload/dedup_test.go (restart test): d1 is never closed. Its flusher goroutine
    and db handle live until the test binary ends, and t.TempDir cleanup unlinks the db file while
    d1 still holds it. Harmless on darwin and linux. A defer d1.Close() after the flush would be
    cleaner.
  • Accounting rides along, unnamed in the PR body. KeptVerbatim also gates the dashboard's
    one-time expand charge (proxy/proxy.go:1876). With the mark surviving, a repair after a restart
    no longer re-charges the row. This looks like the intended direction (charge once per session),
    but it is a second behavior change on the same mark. Worth one line in the PR description.
  • carryKeepMarks compares only Pipe.Names(). A change to expand.fixed_restore or
    cache.tail_breakpoint also keeps the names equal, so marks are carried. Carrying is the safe
    direction there (content stays in full), so I do not count it a defect. Saying so in the comment
    would help the next reader.
  • Process, per CLAUDE.md: the PR changes behavior with no off switch, and it adds a key to the
    session-state row in docs/data-dependence.md. The PR body names both at the top. The row's
    "Decided by" (David Amid, 2026-10-29) predates this key, so the owner's yes is still needed
    before merge.

What I checked

  • Read the full diff (8 files) and the code around every change: proxy/tenancy.go (rebuild and
    publish path, carryKeepMarks), store/store.go (KeptPrefix, EntriesWithPrefix,
    CarryPrefix, Put/putLocked, ttlFor), store/disk.go (metadataPrefixes,
    StatePrefixes, loadSession, boundaryOK, DeleteSessionState), and
    components/offload/state.go (keptKey, MarkKeptVerbatim, KeptVerbatim, isKeptVerbatim).
  • Verified the restart half end to end: KeptPrefix is in metadataPrefixes, so it is a state
    key; the metadata-only disk allows it; loadSession matches cg:keep:<session>:<ck> and
    boundaryOK accepts the : separator; apply.loadSessionState runs before the pipeline reads
    the store; session delete purges the marks through StatePrefixes.
  • Verified the carried-mark shape claim in state.go: keptKey always embeds a session since #175
    and MarkKeptVerbatim refuses an empty session, so CarryPrefix cannot pick up a pre-#175
    cross-session key.
  • Verified store.Nop does not implement PrefixCopier, so a failed build's store carries
    nothing, and CarryPrefix recovers from a panic and returns 0 (fail open).
  • Verified the new tests reference existing helpers (dedupFor, tool, newHostedFixture,
    config.LoadBytes/Build/NewStore, tenant.Patch.ConfigYAML) and that
    modernc.org/sqlite is already a dependency.
  • Checked the two edited store tests: cg:keep: had to become cg:other: because the key is now
    a state key and disk-written; the change is consistent.
  • Checked docs/data-dependence.md against the code: the new metadata key, the hosted-proxy
    in-memory copy, and the "nothing new written to disk there" claim all match the code.
  • Checked lifetimes: without a state db, StateTTLSeconds stays 0 and marks keep the base TTL,
    as before; with the state db they take 24 h, like other state keys.
  • No live tests were run; this is a read-only review, as instructed.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 cda198149 blocking

Verdict: blocking

Findings

  1. proxy/tenancy.go:635 — a rebuild that races a second rebuild still loses all keep marks
    • What fails: a config change lands. Request A enters tenancy, removes the cache entry (line 624) and starts a slow build with prev set. Request B arrives during A's build: the cache is empty, so B gets no prev and builds a store with no marks. If B publishes first, A's second lock (line 643) returns B's tenancy and discards A's tn, the only one that received the carried marks. The tenant's live store then has no cg:keep: marks, so dedup re-compacts expanded outputs and the warm cache is rewritten — the exact cost this PR exists to stop.
    • Proof: trace of tenancy (proxy/tenancy.go:594-648). A: cache hit with a different config → prev = c.t (622), cache.remove (624), unlock, build, carryKeepMarks(prev, tn) (635). B, after the remove and before A's put: cache.get misses, prev stays nil, builds, puts first. A: second lock, c.config == cfgDoc → return c.t, nil (643); A's tn (marks inside) is never used. The build window is not small: the code itself says a build can be slow (tree-sitter parsers, tokenizer tables), and a config change lands mid-session while an agent runs parallel requests (main agent plus subagents).
    • Fix: at the second lock, when returning the already-published c.t, run carryKeepMarks(prev, c.t) before returning (the copy is idempotent — Put of the same keys). The same call after s.cache.put (647) covers the other order. Note the narrower sibling race too: a mark Put on the old store after EntriesWithPrefix returned is not carried. That window is milliseconds, so it may be acceptable as is — say so in the PR if you keep it.

Non-blocking

  • store.CarryPrefix (store/store.go:1325-1332) counts n++ per key even when to is store.Nop (a rebuild into store.enabled: false). The log line "kept the keep-in-full marks" then reports marks that were not kept. Cosmetic: only the log is wrong.
  • LoadSession's range plus boundaryOK (store/disk.go:328-366, 374) loads keep marks of sessions whose scoped id extends another with ":" (tenant:base where base may hold ":"). Harmless: KeptVerbatim looks up the whole key, so no cross-session exemption; only extra memory rows. Same pre-existing shape as cg:tdf:.
  • The mark stays unpinned (evictable under store pressure). The PR and store docs declare this as a separate decision, so it is consistent — noting it so it is a conscious choice.
  • The keep mark's memory lifetime changes from the base TTL (2.8 h) to the state TTL (24 h with the disk copy). The PR declares this behavior change at the top, as the repo rules require. The row's Decided-by (David Amid) still needs to confirm before merge.

What I checked

  • The full diff 202087de..cda19814: all 8 files, line by line.
  • store/store.go: KeptPrefix, PrefixCopier, EntriesWithPrefix (locking, expiry, payload copies), CarryPrefix (nil guards, panic recovery, fail-open).
  • store/disk.go: metadataPrefixes/StatePrefixes/allowed/prefixes — the mark is written and read back at metadata-only and at full level; LoadSession and boundaryOK for the cg:keep:<session>:<ck> shape; DeleteSessionState covers the new prefix; the retention sweep.
  • components/offload/state.go: keptKey builds the same string as before (store.KeptPrefix is the literal it replaced), so no key migration; MarkKeptVerbatim/KeptVerbatim/isKeptVerbatim/skipReduce stay session-scoped and whole-key.
  • proxy/tenancy.go: the whole tenancy path — fast path, rebuild path, second-lock resolution, Forget (a re-registered id cannot inherit marks: the cache entry is gone, so no prev), the LRU eviction path (prev nil, marks lost — same as before this PR, and unchanged by it), invalid-config builds (Nop store, Names() mismatch or non-copier → no carry), observe-mode stores (live store carries no marks there; the chain survives a sync→observe→sync sequence).
  • cmd/context-guru-proxy/main.go: hosted mode has no session-state disk (stateDB nil, warning logged), so tenant marks never reach a shared dashboard database; the local reloadLocal (proxy/adaptapply.go:273) keeps the same store, so the local rebuild path needs no carry.
  • Session scoping (session.Scoped): keep keys are tenant-namespaced on the shared disk, and safeExplicit bounds the id charset.
  • The three new tests and the two edited ones: helpers exist, imports resolve, Disk.Flush exists, the mutation checks claimed in the PR body are the right ones for each test.
  • docs/data-dependence.md: the session-state row now names cg:keep: with its key shape and value size, at all three storage levels, and the hosted carry-over is described accurately.
  • No tests were run (live tests not approved).

Request A removes the old tenancy and builds. Request B arrives after the
remove, has no previous tenancy, and publishes first. A then returned B's
tenancy, which held no marks. A now carries its marks into the published
one. The copy is idempotent.

Also: CarryPrefix copies nothing into a store that keeps nothing, the
restart test closes its first disk, and a comment says the component names
alone decide the carry.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 fixes, in the new head.

  • Race (both reviewers, blocking): fixed. In the c.config == cfgDoc branch, carryKeepMarks(prev, c.t) runs before the return. The copy is idempotent. TestKeepMarksSurviveTwoConcurrentRebuilds blocks request A inside its build, lets B publish first, then checks A's result. Without the fix, it fails.
  • Mark written after the copy: not fixed. The window is milliseconds. It is now stated in the PR body.
  • d1 never closed: fixed (defer d1.Close()).
  • Dashboard charge: one line added to the PR body.
  • Names-only compare: comment added, and a line in the PR body.
  • CarryPrefix counts into store.Nop: fixed. It returns 0 when the destination keeps nothing.
  • LoadSession range, unpinned mark, 24 h lifetime: no change. They are as declared in the PR.
  • Owner's yes: still needed before merge.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 23d8b5e7cfe7 approve

Verdict: approve

Findings

None. Every round-1 finding is fixed or answered, and the new commits add no defect I can show.

Round 1, revisited

  • My finding 1 (the rebuild race, also reviewer 1's finding 1): fixed. carryKeepMarks(prev, c.t) now runs in the c.config == cfgDoc branch before the return (proxy/tenancy.go:643-648). I traced every interleaving: at most one request per config generation holds prev (the mutex serializes the first lock, and only the winner of the old entry removes it), and whichever prev-holder reaches the second lock carries into the entry that is published, in both publish orders. A third request that arrives later returns that same entry, so it needs no carry of its own. The copy is idempotent (Put of the same keys), and Put into a published store is what the expand path already does. No deadlock: the store locks are per-method and never wrap a call back into TenantSource.
  • The test covers the raced order. TestKeepMarksSurviveTwoConcurrentRebuilds blocks request A inside its build (builder call 2), lets B publish, then asserts A returns B's tenancy and the mark is in it. The interleaving is forced by the channels, so it is not flaky. Without the fix, A returns B's mark-less store and the test fails.
  • Mark written after the copy: rejected by the author, reason accepted. Only a request still holding the old tenancy can write to the old store, so the window is one in-flight request. It is now stated in the PR body ("Open window"). The reason is right.
  • CarryPrefix into store.Nop: fixed. It now returns 0 when to.Persists() is false (store/store.go:1326). Nop is the only Persists() == false store, so no real destination is excluded.
  • d1 never closed: fixed (defer d1.Close() in the restart test).
  • Dashboard charge and names-only compare: answered. Both are now in the PR body (lines 8 and 60) and in the carryKeepMarks comment. Agree with reviewer 1 that the carrying direction is the safe one.
  • LoadSession range, unpinned mark, 24 h lifetime: unchanged, as declared. I raised these as notes in round 1 and they still hold as declared behavior, not defects.
  • Owner's yes: still needed before merge. The behavior change has no off switch and the session-state row gains a key. The PR names both at the top. That confirmation is the owner's step, not a code defect.

Non-blocking

  • The second-lock carryKeepMarks runs the store scan while s.mu is held, so other tenants' tenancy calls wait for it. It runs only when the race actually happened, and the scan is one pass over one tenant's store. Acceptable as is.
  • The merge with main (#1090) was resolved the right way: the hand edit on docs/data-dependence.md became an edit of docs/data-dependence/features/session-state-table.md, and the generated page carries the same row text. The row file's fields and body match the page line byte for byte, so the drift test should pass. I could not run the generator (live tests not approved).

What I checked

  • Last review: round 1, cda1981, 2026-11-11T18:17:16Z.
  • New commits read: 4 — ad987b06 (fix: carry when a second rebuild publishes first), 9966adf0 (main's #1090, data-dependence row files, brought in by the merge), d5af7696 (merge of main), 23d8b5e7 (docs: move the keep-mark change into the row file).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review: the author's round-1-fixes comment (each claim checked against the code, see above); the fix commit (every hunk read, plus the code around it); the docs commit; the merge resolution (confirmed by diffing cda1981..HEAD: state.go, disk.go and disk_test.go are untouched since round 1, and the only deltas are the fix hunks and the docs move).
  • The race fix in proxy/tenancy.go:640-648: read with the whole tenancy path again, all publish orders, the invalid-config and observe-mode cases, and the lock-ordering question.
  • to.Persists() in store.CarryPrefix: checked both implementations (Nop false, Memory true, store/store.go:436, 679).
  • TestKeepMarksSurviveTwoConcurrentRebuilds: read in full, traced the channel ordering for determinism and the failure mode without the fix.
  • The docs row file and the generated page: compared the row's fields and body against the page's session-state line; both carry the cg:keep: text from round 1 unchanged.
  • The updated PR body: the new lines 8, 59-60 answer reviewer 1's notes and my sibling-race note.
  • No tests were run (live tests not approved).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 23d8b5e7cfe7 approve

Verdict: approve

Findings

None.

Earlier findings

  • My round-1 finding (the publish race, proxy/tenancy.go:641): fixed. carryKeepMarks(prev, c.t)
    now runs in the c.config == cfgDoc branch before the return (proxy/tenancy.go:647). I checked
    the fix myself: the copy is idempotent, the names check still guards a component-set change, and
    no lock inversion exists (both stores take only their own mutex; neither calls back into
    TenantSource). TestKeepMarksSurviveTwoConcurrentRebuilds forces the exact interleaving —
    request A blocks inside its build, request B publishes first — and it is deterministic, because
    the main goroutine blocks on entered before it starts B. Without the fix, the mark assertion
    fails. All four return paths out of the second lock now end in a tenancy that holds the marks:
    A publishes its own build (carry at line 635), or A carries into B's build (line 647), or A
    replaces a different-config entry and publishes its own, or A had no prev and there was
    nothing to carry.
  • Reviewer 2's round-1 finding (the same race): fixed by the same commit. I verified it
    independently, as above. I add no new proof.
  • Reviewer 2's sibling race (a mark written to the old store after the copy): rejected by the
    author, and I accept the reason.
    The window is the copy itself, and the PR body now states it
    under "Open window". A lost mark there costs one re-expand of one output, and only around a
    config change. The restart half still covers it on a host with the session-state table.
  • My non-blocking items: all addressed. d1 is closed (defer d1.Close()). The dashboard
    charge is named in the PR body. The names-only decision is now a code comment and a PR body
    line.
  • Reviewer 2's non-blocking CarryPrefix count into store.Nop: fixed. CarryPrefix returns
    0 when to.Persists() is false (store/store.go:1326). Memory.Persists() is always true, with
    or without a disk, so the hosted in-memory carry still happens. Only the Nop destination is
    skipped, so the log line no longer over-counts.
  • Reviewer 2's remaining non-blocking items (LoadSession range, unpinned mark, 24 h lifetime):
    rejected as declared.
    All three are stated in the PR body and the row file. I checked each in
    round 1 and agree they are conscious choices, not defects.

Non-blocking

  • Owner's yes, per CLAUDE.md: the behavior change has no switch, and the session-state row
    gains the cg:keep: key. The PR names both at the top. The row's "Decided by" (David Amid)
    predates this key. The author also lists this as open. It is a merge gate, not a code defect.

What I checked

  • Last review: round 1, cda1981, 2026-11-11T18:15:28Z
  • New commits read: 4 — ad987b06 fix(proxy): carry the keep marks when a second rebuild
    publishes first; 9966adf0 docs: one file per data-dependence row (#1090, from main);
    d5af7696 merge of origin/main; 23d8b5e7 docs: move the keep-mark data-dependence change
    into its row file.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-1 review (18:17:16Z, same race as mine plus
    four non-blocking notes — all dispositioned above); the author's fix-summary comment
    (18:31:40Z — each claim checked against the code, all true); the four new commits.
  • The fix commit ad987b06: read the full diff and the final code around each change
    (proxy/tenancy.go 592-677, store/store.go CarryPrefix, Persists semantics at
    store/store.go:679, the new test, d1.Close()).
  • The merge d5af7696: diffed it against both parents. It changes no PR code file; the PR's
    proxy/store/offload changes reach HEAD unchanged. The main side is #1090's docs restructure,
    which carried its own two approving reviews.
  • The docs commit 23d8b5e7: the row file docs/data-dependence/features/session-state-table.md
    now holds the cg:keep: text, and the generated page matches it cell for cell
    (docs/data-dependence.md:229). At the merge the page held the text but the row file did not —
    a drift state — and this commit closes it, so the drift test has current input. The PR's whole
    docs delta vs main is that one row, in both places, in sync.
  • Re-checked the fix for new defects: repeated carries by racing requests are idempotent; the
    carry under s.mu is bounded (one store scan) and lock-safe; c.t can never be prev itself
    in that branch; the new test's build-call numbering (1 = first build, 2 = blocked A, 3 = B) is
    forced by the channel ordering, not by scheduling.
  • No live tests were run; this is a read-only review, as instructed.

@amiddavid
amiddavid merged commit 55d8b49 into main Nov 11, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 11, 2026
amiddavid added a commit that referenced this pull request Nov 12, 2026
…start (#1119)

A hosted proxy now keeps each tenant's metadata session state across a
restart, the same as a local install: dedup's keep-in-full marks
(cg:keep:) and the other metadata keys survive. Fixes #1104, which
#1101 left open for hosted.

- TenantSource.SetSessionState attaches one shared store.Disk to every
  tenant store, on the dashboard database's session_state table.
- DiskOptions.Hosted forces metadata-only and refuses the 2 namespaces
  with no session id in the key (cg:swx:, cg:xres:), so they stay in
  memory per tenant. Every key written starts with the tenant id.
- A tenant's own store.state_ttl_seconds wins; 24 h only when unset.
- PurgeTenant deletes the tenant's session_state rows
  (store.DeleteTenantState, matching "<ns><tenant>:" so t1 never hits
  t10); a quota trim keeps other tenants' rows.

Behavior changes (owner approved, David Amid):
1. Hosted tenants after a restart, on a thread with earlier state:
   their metadata state now survives (old: lost, so expanded outputs
   were compacted again and the warm cache was rewritten). Owner,
   2026-11-12: "1104 b 2 which means there is no reason to have
   anything different here between local and hosted".
2. A tenant purge now also deletes that tenant's state rows, including
   its cg:sum: summary row (old: it survived the purge). Owner,
   2026-11-12: "1 yes".
How to turn it off: --session-state=false; store.enabled: false.

Data dependence changes: hosted now writes the session_state table at
metadata level (no content; cg:swx:/cg:xres: excluded); "everything"
is not available on hosted. Confirmed by the owner (decision above).
Row: docs/data-dependence/features/session-state-table.md.

Fixes #1104.

Reviews: 2 offload review rounds (GLM). Round 2: both approve at
24174cc. After it: aaa92fc removes one blank line (gofmt).

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

dedup's keep-in-full marks are lost on a tenant config rebuild or a restart, so a warm thread rewrites its cache

1 participant