Skip to content

fix(chat): persist undrained pending context across a close - #6813

Closed
rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:fix/persist-pending-context-across-close
Closed

rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:fix/persist-pending-context-across-close

Conversation

@rnoack1

@rnoack1 rnoack1 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

slot._pending_context is in-memory only. Nothing serializes it, and the close path pops the
slot from state._slots, so undrained background context is discarded silently.

A producer is told the write succeeded — POST /api/chat/slots/{slot}/context and .../note
both return 200 — and then the content disappears with no trace on any surface: no transcript
row, no log line, nothing a user could go and find. /note at least leaves its visible half
behind, so its content survives in the transcript. /context is context-only by design, so its
content is lost outright.

Reachable by ordinary use: an app or a scheduled job queues context, the user closes the tab
before sending their next message, and the queued content is gone. Reopening from History does
not recover it, because resume constructs a fresh slot with an empty queue.

Why it matters

It is silent loss of data the system acknowledged. The 200 is a promise the close quietly
breaks, and nothing downstream can detect it — the queue reads empty afterwards,
indistinguishable from never having been written.

The asymmetry inside the existing /note endpoint is the clearest evidence this is unintended
rather than a deliberate trade-off: that endpoint takes real care to make its visible half
durable (its docstring calls the visible line "permanent"), while the context half it writes in
the same call has no durable representation at all.

The same gap loses context across a gateway restart, not just a user-initiated close.

The four notice variants are not committed to this branch and are not attached to this PR: #10010 removed temp-screenshots/ from the tree and gitignores it. No reviewer has seen them render; regenerate any frame on demand with the commands below. Each frame is reproducible on demand from the committed harnesses, which assert the shipped titles and bodies read from en.manual.json and exit non-zero if the copy drifts:

  • website/scripts/capture-artifact-context-notice.mjs — the artifact notice's generic, stale-version and 429 variants
  • website/scripts/capture-papyrus-context-notice.mjs — the Papyrus co-author notice

Declared behaviour changes (riders)

Twelve behaviour changes ride along with the durability fix. Each is detailed under Declared
riders and accepted risks
near the end of this body; they are ALSO listed here because that
section sits past the 8 KB point at which some review tooling truncates a PR body, so a reader
limited to the first 8 KB would see no declaration at all.

  1. /context can now answer 429 context_not_queued. The per-slot queue used to evict its
    oldest entry, so the endpoint always answered 200; it now REFUSES instead, because eviction
    destroyed content the API had already acknowledged. A caller that treated 200 as
    unconditional must handle 429. /note does NOT answer this 429: it still writes its
    visible line and reports contextSkipped: true, so only the silent half is affected. (/note
    has its own unrelated, pre-existing 429, deferred_notes_full.)

  2. An entry posted with no maxAge now expires. DEFAULT_CONTEXT_TTL_SECS gives the queue
    a seven-day backstop where such an entry previously had no expiry of any kind. This is what
    stops a refusing queue staying refused forever.

  3. The artifact companion's context is now durable with a 1 h TTL, where it was previously
    ephemeral (memory-only, withheld from the metadata line). This is the change under test
    rather than a side effect, but it IS a changed default for that caller and is declared as
    one.

  4. A persisted linked_session_key is trust-checked at hydration. It was previously adopted
    verbatim at both hydration sites. An unprovable value now leaves the slot UNBOUND, so this
    rider's blast radius is CHANNEL ROUTING, disjoint from context durability. Known limit,
    measured rather than argued: a key carrying a literal _ exactly where the transcript stem
    has one is refused, because it is byte-identical to the impostor shape the gate exists to
    refuse. See test_a_legitimate_literal_underscore_key_is_refused_and_that_is_measured. The full measured refusal set is three classes, not one: a literal _ where the stem folds one (Discord crew_agent:direct:user_1, Webex room_abc:thread_def, WeCom), a + in a WhatsApp E.164 id, and an @ in an iMessage handle or a Teams thread id (19:meeting_abc123@thread.v2). Each hydrates its slot unbound, so that conversation's channel replies stop until its key is re-linked; entries are held rather than dropped, because merge_pending_context keeps the on-disk rows unconditionally.

  5. DEPRECATED: the app-kit "re-post your context on reconnect" recipe. A caller
    following it now DOUBLE-INJECTS, because queued context survives the close it used to be
    lost to, and nothing server-side detects the repost -- there is no idempotency key on
    /context. MIGRATION: drop the reconnect repost and rely on the queue surviving, or key
    the repost on the caller's own marker. The in-repo caller is adapted; an external one is
    not reachable from inside the gateway. docs/app-kit/api-reference.md states this.

  6. /context accepts an optional contextKey, and honours it. A POST naming a key an
    UNEXPIRED entry from the same source already carries is a no-op returning the ordinary
    { ok, pending }. It exists because the queue now survives a close, so a caller reposting
    after a reload would otherwise deliver the same content twice with no recovery until the TTL.
    Omit it and nothing is deduplicated. Declared in docs/app-kit/api-reference.md; the only
    in-repo consumer is the artifact companion, which keys on the artifact version.

  7. Papyrus's co-author context now carries maxAge 3600. It previously had no per-entry
    expiry, so a co-author session left idle over an hour now loses its document context where
    before it never expired. The agent re-reads the document on demand, so the recovery is a tool
    call rather than a lost turn -- but it IS a changed default for that surface.

  8. ephemeral keeps its true default, so an omitted flag stays MEMORY-ONLY. The pre-existing contract is unchanged: no caller that omits the flag begins writing to disk. Durability is opt-IN — a caller passes ephemeral: false to have an entry persisted to the session metadata line and re-seated after a close or a gateway restart, and only the literal boolean false opts in. Both in-repo callers pass it explicitly, so this rider changes no caller's behaviour. Declared in docs/app-kit/api-reference.md beside the options list.

  9. _disk_meta_key fixes a pre-existing "every save aborts after a rebind" defect. Neither
    cosmetic nor optional: without it the durable copy is not writable after a rebind, so the
    fix this PR exists for would not hold. Declared because it changes behaviour on a path this
    PR did not otherwise need to touch.

  10. No new message-count field, and neither notice auto-retracts. The slot projection exposes
    message counts, not roles, so a client has no user-turn signal to key a retraction on -- and
    keying on the total count lets the agent's OWN reply retract a notice the user has not answered.
    Both surfaces therefore clear only on an explicit dismiss or on a later successful share.
    Declared because it is the behaviour a reader would otherwise assume from rider 12's notices,
    and because it is the reason no field was added to a payload other surfaces read.

  11. Over-budget pending context now spills to a sidecar file beside the transcript, and a
    session delete can REFUSE.
    Entries that do not fit the metadata line are written to
    context-overflow/<stem>.jsonl rather than dropped, which is a new on-disk artifact with its
    own lifecycle: it is folded back on the reads that opt in, pruned after each commit, and
    removed with the transcript. delete_session now returns False when that file can be neither
    removed nor quarantined, because deleting the transcript while it survives leaves the deleted
    session's context hydratable by the next session at the same key. Declared because it adds a
    file to the sessions directory and a refusal path to an operation that previously always
    proceeded. The sidecar is NOT on the common path: a save with nothing over the budget and no
    existing spill writes no file at all, so the per-slot ceiling (~484 KB against a 5 MB line
    budget; eleven same-transcript holders, each filled to the ~484 KB per-slot persist cap through append_pending_context, are what reach the spill (budget // _MAX_PERSISTED_CONTEXT_BYTES + 1); three admitted holders total 1,444,602 bytes and spill nothing.

  12. Two new user-visible failure notices, across all 13 catalogs. A /context post that
    fails now SAYS so on the surface that made it: the artifact page renders
    chat_context_notice_title (first share failed) or chat_context_stale_notice_title (a
    refresh failed, so the agent holds an older version) with a dismiss control, and Papyrus
    renders the co-author equivalent. Each carries its own body, and the stale one promises the
    LATEST version rather than a first share. Required rather than optional: the repo's
    errors-use-error-notice rule mandates that a user-initiated failure reach an
    ErrorNotice rather than only a console line, and silent loss on this exact path is what
    this PR exists to end -- a durable queue that fails quietly would replace one silent loss
    with another. Declared because it adds prose to every catalog and a surface a first-time
    reader meets only on failure. Each notice stands until the user dismisses it or a later share
    succeeds; neither retracts on a turn, for the reason rider 10 gives.

What changed

Persist the live entries on the slot save; re-seat them on every restore path, all through one
restore_pending_context so they cannot drift.

All four hydration sites

A slot-owned key is hydrated in four places — the sites that hydrate channel_folder_filed:

Site Function
chat_persistence.py _rehydrate_slot_from_history (gateway restart, cron delivery)
chat_persistence.py _apply_recent_session (recent / foldered / pinned restore)
chat_handlers.py api_chat_slot_resume (History reopen)
channel_slots.py surface_channel_session (channel reconcile)

All four seat the key, because absence of a slot-owned key means "cleared". A site that
hydrates an empty queue makes the next forced save delete the stored copy — losing context
rather than merely failing to restore it. That reaches recent/foldered/pinned sessions and
reconciler-surfaced channel slots, which the Slack thread backfill shares this queue with.

This is also why the save writes the key on every save rather than only when closed: a
non-close save that omitted it would clear a copy an earlier close had written. Writing it
unconditionally also covers a crash between the enqueue and the next message.

Scope of the fix, stated plainly: durability is OPT-IN. /context defaults to
ephemeral: true, so an app or scheduled job that posts without ephemeral: false still keeps
memory-only entries and still loses them on a close. This change makes durability AVAILABLE and
makes the durable path lossless; it does not change what a caller that omits the flag gets.
Flipping that default is a retention decision, not part of this fix.

Concurrent drain vs. flush

The save runs in an executor thread while the drain runs on the event loop, so a flush can
export the queue, the loop can drain it, and the write would then persist entries already
handed to the model — with a crash before the next save re-injecting them.

The slot carries a generation counter that the drain bumps, captured before the export and
re-checked immediately before the metadata line is serialized. A mismatch deletes the key,
which is also the correct end state: a drained queue should clear the stored copy. Appends
deliberately do not bump it — persisting a subset is safe and self-correcting, persisting a
consumed entry is not.

Retirement is committed after proven delivery, never before the prompt

The drain bumps the generation but deliberately does NOT mark the slot dirty -- arming the periodic flush there would race the very window the generation check exists to close -- and the flush persists the
emptied queue. A turn that actually consumed queued context ALSO forces a durable save, from
inside the event-stream loop on the first delivery-confirming event
(event_confirms_delivery in src/kiro_crew/dashboard/chat_runner.py). The entries sit in
_ctx_inflight until that point, and the drain's orphan-recovery pass re-seats them if the
turn dies before any event confirms delivery, so retirement is carried by both: the flush for the
ordinary case, and that per-turn save for a turn whose entries must not survive delivery. An earlier revision instead forced an fsync'd durable save on every
context-consuming turn and awaited it before the drained text was prepended, with
shield/cancel/requeue handling around it.

That ordering was removed. Committing the emptied queue before delivery opens a window where a
crash between the commit and the prompt reaching the model leaves zero copies of content a
200 already acknowledged, which is the failure this change exists to prevent — the rebind
retirement's own comment calls a zero-copy outcome "strictly worse than a duplicate". Leaving
the retirement to the flush inverts the residual to at most one duplicate injection, which a
restart recovers from and a deletion does not. It MOVES that fsync rather than removing it: the durable retirement now runs inside the event-stream loop, on the first delivery-confirming event and only for a turn that actually consumed queued context, because a retirement committed before delivery is what re-injected content a crash had not delivered. It does remove ~120 lines of cancellation repair and a model-visible failure prepend.

Notice frames — all four variants, reproducible locally (none attached)

Captured by the two committed harnesses against the REAL built SPA with the real components; each
run asserts the notice's title and body before it writes a frame, so a frame cannot exist for a
variant that did not render.

The Papyrus frame shows the notice above the editor with the co-author panel open, carrying the
consequence, the remedy and the dismiss control. Fixture data only — no account, token or personal
identifier appears in any frame.

TTL arithmetic hardened at its own site

context_entry_expired computes injectedAt + maxAge, which a metadata line carrying
"maxAge": "60" turns into int + str. Untreated, that 500s the resume, and on the restart
path raises into a broad handler that pops the slot — so the whole tab silently fails to
restore.

Fixed inside context_entry_expired rather than only at the restore, so every caller is
protected: the drain, the per-source cap count, and the deferred-note promotion. A
present-but-invalid value reports EXPIRED rather than "never expires", so unparseable data is
pruned instead of made immortal — which also retires a NaN maxAge that previously compared as
non-expiring forever. The restore additionally skips such entries so garbage never occupies a
seat.

Choosing that site over a restore-only guard is deliberate: it is where the unsafe arithmetic
actually lives, and the boundary validators (_validate_max_age) only ever guarded the live
enqueue.

Cross-session authorization

A note stamps both halves, and the save is a late resolution point for the queued one. The
persist now applies the same _note_authorized_elsewhere filter this function already applies
to the message window, with the matching count-gated note_save_drop denial. Without it, a slot
rebound after the write copies one session's note content onto another's metadata line
silently — while the visible half of the same note is dropped and audited.

The restore drops foreign-authorized entries for the same reason. Unstamped entries are
untouched: /context and the Slack backfill share this queue and record no session.

Size bound

The live ceilings permit _MAX_PENDING_CONTEXT (50) entries of _MAX_CONTEXT_CONTENT (40 000)
chars — two million characters, reachable through the documented API with no tampering — and it
would all land on the session metadata line.

_maybe_rotate can only drop message lines. Once the metadata line alone exceeds
_SESSION_MAX_BYTES, its budget loop floors at one kept message, and since _maybe_rotate runs
from append, every subsequent message archives the rest of the transcript. The persisted
payload is now bounded well below that ceiling, and the bound is enforced at the DOOR rather than
at save time: append_pending_context REFUSES an entry that would not fit, and /context answers
429 context_not_queued. Nothing is truncated after acknowledgement -- an earlier revision dropped
oldest-first at export, which meant a caller could be told 200 and then lose its content with no
surface reporting it. A refusal is visible and retryable; silent truncation is neither.

Source label

source is validated on restore against the same rule the HTTP boundary applies: the drain
interpolates it into [Background context from "<source>"], so a crafted label could forge a
frame boundary and make injected content read as a separate trusted block. An unusable label is
removed and the content kept, letting the drain's own default name it.

Expiry

Wall-clock across the close. The restore routes through append_pending_context, so maxAge
and both per-slot ceilings are applied by the same code that governs a live enqueue. FIFO
eviction is GONE — this diff removes it, and a full queue now answers 429
context_not_queued instead of silently dropping the oldest already-acknowledged entry. An
entry with no maxAge is NOT exempt: DEFAULT_CONTEXT_TTL_SECS applies a queue-level
seven-day backstop, which is what bounds the refusal wedge below to that window instead of
leaving it indefinite.

Deliberately not changed

A context prefix that has been drained still does not appear in the transcript. That
exclusion is intentional — see the raw-message capture for the Slack mirror in _run_chat, and
the silent-consumption contract added in #4780 after an agent recited injected context verbatim
into a reply. Persisting the drained prefix would reintroduce exactly that.

There is a residual fidelity cost: a reopened session shows a user message whose reply was
shaped by text absent from the record. Addressing it collides with the silent-context promise,
so it is left out of scope rather than traded away here.

Not covered

slot._deferred_notes — a held note's context half awaiting end-of-turn promotion. It is a
turn-in-flight structure on a path the close already cancels, and folding it in would widen this
change past the data loss it fixes.

Also noted and not chased: _live_slot_resume_response matches by slot name, else by
effective_session_key, and its own comment documents a channel-key mismatch producing two tabs
for one conversation. In that state both would seat the same entries. I could not construct the
mismatch, so I can assert only that the dedup this relies on is documented as having a hole.

Compatibility: callers that re-post on reconnect

The queue is now durable, so a caller following the old "re-post it if it must survive a
restart" recipe supplies a second copy alongside the restored one and the model sees the content
twice. docs/app-kit/api-reference.md states the required change (drop the re-post for
/context and for the context half of /note).

Measured blast radius in this repo — three call sites use api.chatSlotContext:

Call site Regresses?
website/src/pages/ArtifactDetailPage.tsx (two sites) Yes. Guarded only by an in-memory injectedVersionRef, which a page reload clears, so a reload re-posts alongside the restored copy.
website/src/apps/papyrus/PapyrusPage.tsx No. Posts once against a freshly created slot, so no restored copy can exist.

Worth noting for callers: durability on /context and /note is opt-IN — ephemeral keeps its true default, so an omitted flag stays memory-only and a caller passes ephemeral: false to have an entry persisted. Only the literal boolean false opts in. This is declared in docs/app-kit/api-reference.md. Worth noting for callers: ephemeral: true now keeps an entry memory-only. It queues, drains
and expires like any other, but export_pending_context withholds it, so it never reaches the
metadata line and does not survive a close or a restart. It bounds the QUEUE's durability, not the
conversation's: once an ephemeral entry is actually injected, its content is in the transcript.

Tests

test/test_pending_context_survives_close.py — 264 tests (pytest --collect-only, the collected total rather than a grep) over a real ConversationLog, so
they exercise the actual metadata line rather than a mock of it.

  • All four hydration sites, with resume driven over HTTP — every other round trip reaches
    the restart path, so the resume call site needs its own coverage.
  • The drain-vs-flush race, hooking the export so the drain lands in the window the generation
    check exists to catch. Verified to fail when that check is disabled, on exactly the
    persisted-key assertion, with a guard asserting the drain really fired inside the save.
  • An append asserted not to invalidate a pending export, so the fix is not vacuous on a busy
    slot.
  • Malformed timing fields ("60", [1], True, NaN, Inf, bad injectedAt) asserted to leave
    the session resumable — a 200 from the endpoint and a restored tab — not merely to avoid
    raising.
  • A hostile source asserted not to forge a second frame in the rendered drain output.
  • Foreign-authorized entries asserted absent from both the persist and the restore, while
    unstamped entries survive.
  • The byte bound asserted against the payload and against the session cap, including that an
    over-budget entry is REFUSED at the door (and that a held note's context half is reserved, so
    later /context cannot squeeze out content already acknowledged).
  • source, maxAge and injectedAt asserted to round-trip, not just content.
  • Clearing after a drain, and an ordinary session's metadata line gaining no key at all (with a
    positive control on the same read so the absence cannot pass vacuously).

Regression: 5690 passed / 7 skipped across the channel, persistence, slot, restore, resume,
hydrate, metadata and rotation suites.

Gates: baselined black, isort, flake8 (zero new findings, verified by per-file
base-vs-HEAD counts), and mypy src/kiro_crew/ clean across 1167 files.

One existing stub in test_slack_mirror_context_leak.py gained the new counter field. That file
already documents the convention: the drain's requirements are satisfied at the stub rather than
guarded in the drain, because making the drain tolerate an incomplete slot would silently
disable the protection for every such caller.

Pattern harvest

Rule candidate: flag a request handler that answers 200 for caller-supplied content whose only storage is an in-process structure no persistence path writes.

That is precisely the shape of this defect. Two endpoints accepted background context, returned 200, and appended it to an in-memory queue; closing the tab dropped the slot and took the queue with it, so content the API had already acknowledged was gone with no error anywhere. Nothing connected "we told the caller 200" to "this survives an ordinary lifecycle event", which is why the loss was invisible at the call site and stayed invisible in tests.

A narrower and more mechanically checkable invariant fell out of the fix and is worth a rule of its own: for a metadata key whose absence is destructive — the slot-owned keys, where a save that omits the key deletes it — every save path must write that key unconditionally. A conditional write is indistinguishable from a delete, and the difference only shows up as data loss on some later read. That one is statically checkable: enumerate the slot-owned key set, then require each save site to assign every member of it.

Visual evidence

Opening the companion chat silently POSTs /api/chat/slots/<slot>/context so the agent knows
which artifact it is looking at. This PR gives that POST's failure its own surface. Both frames
are the REAL built SPA driven by website/scripts/capture-artifact-context-notice.mjs, which
asserts as well as photographs -- it exits non-zero unless the notice renders its own title and
carries no transport text.

The enqueue failed outright -- consequence and remedy, not the transport error:

The queue answered 429 context_not_queued. The notice copy does not vary by cause, so this
frame pins the refusal PATH rather than capacity-specific wording:

The FIRST injection failed -- the generic title, scoped apart from the resume-freshness wording:

The generic title with the CAPACITY message renders pixel-identical to the frame above -- the notice copy does not vary by cause -- so the capture harness asserts that combination without committing a duplicate frame.

Aggregate persistence budget at the handover union. Per-slot admission (pending_context_budget_room) bounds each queue against its own cap, but a rows-only save unions a DIFFERENT holder's queue onto the same metadata line, and neither side's admission saw the other. _maybe_rotate can only drop MESSAGE lines -- never the metadata one -- so a large enough union evicted real transcript rows. merge_pending_context now keeps entries in delivery order up to HALF the session byte budget, leaving the rest of the file for history.

Disposition for entries that do not fit: they are SHED FROM THE TAIL AND RECORDED by ctxId in a logger.warning naming the budget and the count. That is the difference from the size cap removed earlier in this PR, which skipped non-fitting entries silently so a caller told 200 could not learn its content was gone. The first entry is always kept, so a single oversized row cannot empty the queue. The bound is intrinsic to the union -- it takes no size parameter -- so all three call sites are covered and no caller can opt out.

Before this change both cases wrote to the page's SAVE-error channel, so the banner was titled
Save failed -- telling a user with a dirty draft their work had not been written -- and the
429 was rewritten by friendlyErrText into the tunnel rate-limit string, naming the wrong cause
and promising an automatic retry nothing performs.

Reproduce: cd website && node scripts/capture-artifact-context-notice.mjs

Release notes for the next changelog port

CHANGELOG.md is not writable from this PR — scripts/check_changelog_history.py requires the
file at head to carry ONLY shipped sections (draft_headings refuses an ## [Unreleased]) and
every released section is frozen append-only history. So the two operator-visible changes below
are staged here for the release-porting commit rather than added to the changelog directly.

  • /context can now answer 429 context_not_queued (/note does NOT -- it keeps writing its
    visible line and reports contextSkipped: true). The per-slot queue used to
    evict its oldest entry to make room, so the endpoint always answered 200. It now REFUSES instead,
    because eviction silently destroyed content the API had already acknowledged — the bug class this
    change exists to close. Callers that treated 200 as unconditional must handle 429 and retry.
    Known consequence, bounded: a slot holding entries with no maxAge that never takes another turn
    refuses every later post until the queue-level backstop ages them out, where eviction self-healed
    at once. A staleness horizon IS set here — DEFAULT_CONTEXT_TTL_SECS, seven days.
  • Persisted channel bindings are now trust-checked, and a refusal makes a thread go quiet. This
    rider's regression surface is CHANNEL ROUTING, which is disjoint from the context-durability fix
    it ships with, so it is called out separately. _rehydrate_slot_from_history and
    _apply_recent_session previously adopted a persisted linked_session_key unconditionally; they
    now adopt only a value that names the transcript being hydrated, since that field is
    agent-writable and decides where the slot ROUTES. If a legitimate spelling is ever refused the
    slot stays UNBOUND and answers from its own dashboard session, so a channel thread stops seeing
    replies with only a logger.warning and a SEL chat:adopt_persisted_binding deny event to
    explain it. Two spellings were refused in error during development, both from drift between
    ConversationLog._path and transcript_stems.
  • DEPRECATED: the app-kit "re-post your context on reconnect" recipe. A caller following it now
    DOUBLE-INJECTS, because queued context survives the close it used to be lost to. Nothing
    server-side detects a re-post — there is no idempotency key on /context — so this cannot be
    fixed for external callers from inside the gateway. Only the in-repo caller
    (website/src/pages/ArtifactDetailPage.tsx) is adapted, by holding an in-memory injection claim
    around the POST. External callers should key on their own idempotency marker instead of on the
    endpoint, as docs/app-kit/api-reference.md now states.

Declared riders and accepted risks

Operator note — the persisted-binding gate narrows previously unconditional adoption.
_rehydrate_slot_from_history and _apply_recent_session used to adopt a persisted
linked_session_key on sight; they now adopt only a value that names the transcript being
hydrated, because that field is agent-writable and decides where a slot ROUTES. The
tightening is deliberate, but it has an operational failure mode worth knowing before it
is met in the field: if a legitimate spelling is ever refused, the slot comes back UNBOUND
and answers from its own dashboard-only session, so a channel thread stops seeing replies
with only a logger.warning naming the accepted spellings to explain it. Both outcomes are
now recorded in the Security Event Log (chat:adopt_persisted_binding), so the decision is
auditable rather than inferable from a rotated log line. Two spellings were refused in
error during development, both from drift between ConversationLog._path and
transcript_stems; that agreement is pinned by
test_transcript_naming_is_closed_over_transcript_stems.

Recorded rationale — why the session metadata line, not a per-session sidecar. The
design review asked for this to be written down if the shape stays. A sidecar record with
its own lifecycle would indeed remove the "absence means cleared" coupling, the digest
compare-and-clear retirement, and the byte-budget interaction. It was not chosen because
the queue must be seated and cleared ATOMICALLY WITH the binding it belongs to: a slot's
linked_session_key, its transcript identity and its queue are read on the same hydration
and rewritten on the same save, and update_metadata_if already gives that one
compare-and-set. A sidecar splits it into two writes with no shared commit point, so a
crash between them yields a queue seated against a binding that no longer holds — the same
class of loss this PR closes, reintroduced at a different seam and harder to detect
because each file is individually well-formed. The coupling is real and is the price of
one atomic write; it is pinned by a census test rather than left to convention.

Accepted risk — a queue of no-maxAge entries can wedge a dormant slot. Capacity
is now enforced by REFUSAL rather than by evicting the oldest entry, and the queue is
only drained by a user turn. So a session that never takes another turn keeps its seats
occupied, and later /context and /note posts to it are refused with 429
indefinitely, where the previous FIFO eviction self-healed. This is a deliberate
trade: eviction silently destroyed content the API had already acknowledged with a 200,
which is the class of bug this PR exists to close, and a refusal is at least visible to
the caller. A staleness horizon IS set here: DEFAULT_CONTEXT_TTL_SECS, seven days,
applied inside context_entry_expired — the single expiry chokepoint — and only to entries
carrying a real timestamp, so an unstamped entry keeps its never-expires behaviour.

Consequence — pending_context is slot-owned, so absence means CLEARED. Every save
path must therefore write the key unconditionally, and every hydration path must seat
it, or an ordinary save deletes a copy an earlier close committed. That makes each save
and hydration site load-bearing rather than incidental; the census test
test_the_set_of_metadata_write_sites_is_pinned exists to fail when a new save path is
added without classifying it.

The four notice frames are reproduced by the committed harnesses (website/scripts/capture-artifact-context-notice.mjs, website/scripts/capture-papyrus-context-notice.mjs), which assert the shipped titles and bodies read from en.manual.json and exit non-zero if the copy drifts. They are neither committed to the tree nor attached to this PR: #10010 removed temp-screenshots/ and gitignores it. Run either harness to produce a frame locally.

@rnoack1
rnoack1 requested review from a team and iamwhatever August 29, 2026 17:45
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 8a4ecbf26b7b3a09067940eae1fbef37cb039249 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8a4ecbf

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🔴 BLOCK (blocking)

Design-level review of 8a4ecbf26b7b3a09067940eae1fbef37cb039249 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: BLOCK

Cannot evaluate: missing screenshot or recording of the new context-failure notices and the reshaped chat-panel layout at this revision.

Blockers

Missing rendered evidence for a reshaped user-visible surface.
The diff adds two dismissible failure notices (ErrorNotice mounted in ArtifactDetailPage.tsx and PapyrusPage.tsx, new strings in all 13 catalogs) and changes ArtifactChatPanel.tsx's default sizing from height: 'calc(100vh - 240px)', minHeight: 480 to flex-1 min-h-0 — a layout change that applies even when no notice mounts. The description states the frames "are not committed to this branch and are not attached to this PR", and the evidence list confirms: 0 images, 0 recordings downloaded. A capture harness that asserts copy is not rendered evidence; whether the notice placement and the flex conversion keep the composer visible cannot be judged from a surface never seen.
Fix: run the two committed capture harnesses and attach their frames to the PR description as user-attachments assets.
Clears when: the description carries downloaded github.com/user-attachments images (or a recording) of the artifact and Papyrus notices rendered at this revision.

Watch

The persisted-binding gate's measured refusal set silences whole channel key classes, not edge cases: every WhatsApp E.164 id carries +, every Teams thread id carries @, so those slots rehydrate unbound after a restart and the thread goes quiet with only a log line and a SEL event. The rider's blast radius is channel routing, disjoint from the durability fix by the PR's own words, so a field misfire forces reverting both together.
Clears when: the gate ships in its own PR, or the live spelling is persisted beside the stem (the fix its docstring already names) so exact compare replaces the fold heuristic.

The motivating scenario — "an app or a scheduled job queues context, the user closes the tab... gone" — still happens for every caller that omits ephemeral: false; the fix makes durability available, opt-in, and only the two in-repo callers opt in. The PR's own harvested rule (200 for content only an in-process structure holds) still flags this endpoint's default path after merge.
Clears when: a human confirms opt-in scope is the intended retention decision, or the default flip is tracked as a named follow-up.

Suggestions

Persist the live key spelling alongside the transcript stem so binding adoption is an exact comparison — it retires the separator-fold heuristic and its three refusal classes in one move.

[DESIGN-REVIEWED] 8a4ecbf

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of 8a4ecbf26b7b3a09067940eae1fbef37cb039249 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Two riders need a human's eyes: the 200→429 reversal deletes a FIFO pin on the PR's own derivation, and the spill sidecar's harm needs ~11 co-holders to exist.

Not justified as shipped

  1. 429-refusal — rides along: reverses the pin test_queue_is_fifo_evicted_at_the_shared_ceiling with no linked report of eviction loss, only derivation.
  2. 7-day TTL — rides along: derived from item 2, so it inherits item 2's premise.
  3. contextKey — rides along: permanent public field; 1 in-repo consumer (ArtifactDetailPage.tsx), grepped contextKey across website/ and src/.
  4. Artifact companion durable, 1 h TTL — rides along (declared changed default).
  5. Papyrus co-author durable, 1 h TTL — rides along (declared changed default).
  6. Binding trust gate — rides along: boundary-derived (agent-writable metadata deciding routing), measured refusal classes, tested heal.
  7. Overflow sidecar + refusable delete — oversized: see Watch.
  8. Failure notices ×13 locales — rides along: derived from item 2's new 429.
  9. Capture harnesses — rides along: dev tooling, no shipped surface.

What this change ships

Inventory (10 items, capped — more exist: `_disk_meta_key` rebind pairing, delivery-confirmed retirement, message-less-slot flushes fold under item 1) — 1 justified

Intent: content a producer posted and was told "accepted" (200) must not silently vanish when the tab closes or the gateway restarts — a FIX, with provenance (reproduction in the description, tests that fail on base).

  1. Queued background context now survives a close and a restart — justified
  2. A full /context queue answers 429 instead of silently evicting the oldest entry — rides along, rewritten pin
  3. Entries with no maxAge now expire after 7 days — rides along, declared
  4. /context accepts an idempotency contextKey — rides along, one in-repo consumer
  5. Artifact companion context becomes durable with a 1 h TTL — rides along, declared
  6. Papyrus co-author context becomes durable with a 1 h TTL — rides along, declared
  7. Persisted slot bindings are trust-checked at hydration, refused ones healed from the session map — rides along, declared
  8. Over-budget context spills to a new context-overflow/ sidecar, and session delete can now refuse — oversized
  9. Context-share failures now render their own dismissible notice in the chat column — rides along, declared
  10. Two screenshot-and-assert harnesses for the notices — rides along

Watch

  • The eviction→refusal reversal rests on derivation, not a report. The deleted pin recorded FIFO eviction as intended; the PR's reason ("eviction destroyed content the API had already acknowledged") is a first-principles argument, with no linked issue or observed caller loss — and the declared cost is real: callers treating 200 as unconditional now break, and the reconnect-repost recipe double-injects. Clears when: a human accepts the declared compat break, or a report of eviction-caused loss is linked.
  • The spill sidecar defends a ~11-holder tail at permanent cost. Counted: a slot's durable queue is capped at _MAX_PERSISTED_CONTEXT_BYTES ≈ 484 KB (state.py), the union budget is _SESSION_MAX_BYTES // 2 = 5 MB (_bounded_context_union), so the spill fires only when ~11 full-queue holders union onto one transcript key. The price is forever: a new on-disk format with quarantine lifecycle, and delete_session — previously infallible — can now refuse. Clears when: a realistic path to a >5 MB union is named, or the sidecar + delete-refusal is deferred per the subtraction below.

Subtractions

  • Defer the context-overflow sidecar and the delete-refusal arm (history.py CTX_OVERFLOW_*, _delete_session_locked) until a >5 MB multi-holder union is demonstrated; the existing non-final DEFER path plus the boundary 429 already bound every single-slot case.

[FIRST-PRINCIPLES-REVIEWED] 8a4ecbf

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed 8a4ecbf26b7b3a09067940eae1fbef37cb039249 via the fork AI-review pipeline; updated in place on each push.

Review details

The single candidate is a latency concern that its own author flags low-confidence, explicitly unable to establish whether restore_open_slots_async runs before the socket binds, the worst-case slot count, or whether the metadata read already ran off-loop on the base branch. That is exactly the "could/might, requires assuming code I did not open" case Step 1 drops. The candidate itself concedes the no-new-work-on-gateway-boot-path file-patterns cover dashboard/server.py, handlers/**, slack/gateway.py, and cli.py — not dashboard/chat_persistence.py — so no matched blocking rule applies either. It fails (a), (b), and (c).

I re-read the chat_persistence.py hunks (the folding reads, the binding-audit gate, the origin-preservation and generation-recheck logic, the delete-won guard's stem-set pairing). No concrete, grounded defect with a named trigger, call path, and observable wrong outcome reaches the 80 bar.

No findings.

[OPUS-REVIEWED] 8a4ecbf

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/persist-pending-context-across-close branch from b825b9a to 4cb86c6 Compare August 29, 2026 19:10
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/persist-pending-context-across-close branch from 4cb86c6 to de97fff Compare August 29, 2026 19:36
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/persist-pending-context-across-close branch from de97fff to 69bf44a Compare August 29, 2026 20:25
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/persist-pending-context-across-close branch from 69bf44a to bfbb1f6 Compare August 29, 2026 20:37
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — 🔴 BLOCK

UX-level review of 8a4ecbf26b7b3a09067940eae1fbef37cb039249 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: BLOCK

cannot evaluate: missing screenshots of every new notice — both artifact variants and the Papyrus notice exist only as uncommitted, unattached capture-harness output.

Evidence gaps

  • Artifact notice, generic variant — chat_context_notice_title ("Couldn't share this artifact with the agent") with body and dismiss control: no entry in the image list; close by attaching the capture-artifact-context-notice.mjs frame to the description.
  • Artifact notice, stale variant — chat_context_stale_notice_title ("Couldn't share the latest version with the agent"): same harness, second frame; not attached.
  • Papyrus co-author notice — context_notice_title ("Couldn't share this paper with the co-author") above CoAuthorPanel: attach the capture-papyrus-context-notice.mjs frame.
  • Chat-column layout change — ArtifactChatPanel moved from fixed calc(100vh - 240px) to flex-fill so the composer stays above the fold when the notice mounts, and the new mobile wrapper (isMobile ? 'flex-1 min-w-0'): no frame shows notice + panel together at desktop or narrow width.

The PR body concedes the predicate: the frames "are neither committed to the tree nor attached to this PR… No reviewer has seen them render." Reproducible-on-demand harnesses cannot substitute — attach the four frames and this lane can evaluate the rendered surface.

[UX-REVIEWED] 8a4ecbf

@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • PR #5933 is OVERLAPPING relative to this PR. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #5933: KEEP. Nearest code-near candidate by shared files and by both depending on update_metadata_if merge behaviour, but materially different scope and no measured interaction. Files: src/kiro_crew/dashboard/chat_persistence.py. The two independent directions used different labels; the matrix conservatively retains OVERLAPPING for coordination.
  • This PR is OVERLAPPING with PR #2783. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. Same attribute and same authorization seam, with a real semantic interaction (a refused app-slot binding is precisely the case 6813's queue filter and held-entry parking react to). Coordinate the two rather than resolving textually. Files: src/kiro_crew/dashboard/state.py, src/kiro_crew/dashboard/chat_persistence.py.
  • This PR is OVERLAPPING with PR #3248. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. Ancestor feature rather than competing work; nothing about it makes 6813 redundant. Files: src/kiro_crew/dashboard/chat_handlers.py.
  • This PR is OVERLAPPING with PR #4623. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. A direct same-line conflict on a guard both PRs widen for unrelated reasons; the composed condition should be written once rather than reconstructed by whoever rebases second. Files: src/kiro_crew/dashboard/chat_persistence.py.
  • This PR is OVERLAPPING with PR #6823. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. Independent goals that collide on the same /note handler block and the same api-reference section, and 6813 invalidates the durability premise 6823 records for visibleOnly. Land order and a single reconciled doc paragraph need to be agreed rather than resolved as a mechanical conflict. Files: src/kiro_crew/dashboard/chat_handlers.py, docs/app-kit/api-reference.md.
  • This PR is OVERLAPPING with PR #6831. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. Complementary halves of the same endpoint with no behavioural contradiction; only the adjacent api-reference text and the shared handler body need reconciling at merge time. Files: docs/app-kit/api-reference.md, src/kiro_crew/dashboard/chat_handlers.py.
  • This PR is OVERLAPPING with PR #6915. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. The merged refactor is the current home of the eviction policy 6813 removes; deleting the now-unused helper rather than leaving a dead body carrying the defective policy is the right disposition, and no other caller exists in main. Files: src/kiro_crew/dashboard/slot_buffers.py.
  • This PR is OVERLAPPING with PR #7212. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6813: KEEP. 7212's deferred-key set is derived from the frozenset 6813 extends, so landing both silently decides how pending_context behaves on a rows-only save; the census tests 6813 adds should be made to cover that third class explicitly. Files: src/kiro_crew/history.py, src/kiro_crew/dashboard/chat_persistence.py.
  • PR #7163 is OVERLAPPING relative to this PR. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #7163: REBASE. Adjacent work on the same deferred-note/pending-context structures with no conflicting semantics; 6813's budget accounting already tolerates a context-less entry. Files: src/kiro_crew/dashboard/state.py, src/kiro_crew/dashboard/slot_buffers.py.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@bolichen97

Copy link
Copy Markdown
Contributor

@rnoack1 A repo-wide audit flags five open PRs that overlap this one. Nothing on main or in any open PR implements this durability fix, so the ask is coordination, not a close. Audited at f575e7c; the head has moved since, but all shared files below are still in the current diff.

Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong.

@bolichen97

Copy link
Copy Markdown
Contributor

Maintainer review (agent-assisted, on behalf of @bolichen97), head c2970ed49 (you pushed f2d95e04c while this was being written; line anchors below refer to c2970ed49 — please re-check each against the new head). The core durability path is coherent — pending_context in SLOT_OWNED_META_KEYS (history.py:+180), written on every save and generation-rechecked at the write (chat_persistence.py:+3974-4041), re-seated at all four hydration sites. But the description contradicts the diff on load-bearing claims, and an owner question is unanswered, so this cannot merge as-is:

  • Blocking — body "Retirement is carried by the flush, not by a per-turn forced save" is false. chat_runner.py:+7993-8006 runs commit_drained_context + await save_slot_off_loop(state, slot) inside async for event in event_stream on every turn that drained context — an fsync'd save before the first token. Either remove the forced save and let the flush retire, or rewrite the section to describe the delivery-gated forced save (_ctx_inflight, orphan recovery, event_confirms_delivery at +396-412,+491-503,+520-620), which the body currently describes as the opposite design.
  • Blocking — body facts. "107 tests" vs 214 def test_ in test_pending_context_survives_close.py; the Expiry paragraph ("An entry with no maxAge never expires") contradicts rider 2 and docs/app-kit/api-reference.md:+551 (7-day backstop). Regenerate the body from the current diff.
  • Blocking — process. @bolichen97 asked on 2026-09-08 to settle the SLOT_OWNED_META_KEYS census-test branch with feat(dashboard): unlink PR/issue/Jira source links from a session #8072 and to coordinate with feat: mirror /note to the channel, closing the mid-send TOCTOU on its two send paths #6831/feat(chat): render zero-turn option action chips in the follow-up bar #6823/feat(chat): add transcript section markers #7163/fix: keep session tags stable while state syncs #8185; no response and no change addressing it.
  • docs/system-specs/modules/history.md not updated although history.py gains a new on-disk sidecar (sessions/context-overflow/<stem>.jsonl, 0600, 8 MiB/5000-entry ceiling, *.orphaned-<uuid> quarantine), new accessors, and delete_session now returns False when the sidecar cannot be unlinked or quarantined (+3500-3540). Same-commit spec update is required.
  • history.py:+3968-3970, +3781-3785 — corrupt sidecar lines are skipped with continue and no log, so a partially corrupt spill silently drops acknowledged entries — the exact silent-loss class this PR targets. Count and logger.warning.
  • chat_persistence.py:+4048-4070 — reconcile_ctx_overflow can raise CtxOverflowNotCleared after atomic_write committed; the enclosing except Exception: raise then reports the save as failed to a best_effort=False caller whose bytes are already on disk. Separate post-commit sidecar failures from pre-commit ones.
  • Undisclosed model-visible change: every restored entry is stamped restoredFromDisk: True and framed as UNTRUSTED (chat_runner.py:+362-369), so a trusted /note half that merely survived a close is downgraded relative to the same note drained live. Declare it as a rider or drop the second contract.
  • Files not accounted for in the body: website/scripts/capture-papyrus-context-notice.mjs, dashboard_persistence.py:+98-121, six modified existing test files.

Separately, riders 1 (429 context_not_queued), 4 (trust gate that can leave a channel thread unbound), 9 (durability is opt-in), 11 (delete refusal) and 12 (new ErrorNotices ×13 catalogs) are product decisions for @bolichen97 once the drift is fixed.

Auto-Merge disarmed.

@rnoack1

rnoack1 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Checked each of your three items at the current head 3b689c324e9f6788dd5d72d1b29455d2a818acb8 rather than re-fixing blind — two were already satisfied and one was real. Thanks for the third; it was the exact class this change exists to close.

Body facts — the count was stale, the expiry paragraph is not.

The "107 tests" figure predated several rounds. I replaced the claim with the collected total from pytest --collect-only (264) rather than a grep -c 'def test_', because the grep counts lines rather than collected tests and disagrees with itself depending on anchoring (211 anchored, 235 unanchored) — which is how the number drifted in the first place.

On Expiry: the wording you quoted is no longer in the body. It now states that an entry posted with no maxAge does expire, via the 7-day queue-level backstop, and separately that such an entry is not exempt from it — both consistent with the API reference. The only surviving use of "never expires" describes a present-but-invalid maxAge reporting EXPIRED instead of being treated as unbounded, which is the safe direction.

Corrupt sidecar lines — one of your two coordinates was real, and it is fixed.

The main reader already counted both drop shapes (unparseable, and parsed-but-not-an-object) and logged them at ERROR with the numerator, denominator and path.

The quarantined-holding reader did not: it dropped corrupt lines with a bare continue. That is the same agent-writable state on the same recovery path, so a partially corrupt holding silently discarded acknowledged entries. It now counts both shapes and reports them the same way, naming the holding and how many of how many lines were dropped.

The census-test branch and the cross-change coordination — not settled, and not mine to settle.

You asked on 2026-09-08 to reconcile the SLOT_OWNED_META_KEYS census-test branch against the other change and to coordinate with the four in-flight changes. That is a sequencing decision across work I do not own, so I have escalated it rather than guessing an ordering that would conflict with one of them. I have not touched the census test meanwhile.

Two of your concerns are decisions rather than defects, and are flagged for a human.

The channel-binding trust gate: I have since confirmed at source that a slot left unbound is not rebound by a later reconcile — the surfacing path returns early when the slot already exists, and the only binding assignment sits after that guard on the create path. So the "re-link to recover" framing in the body is not supported by the code, and the outage for keys carrying +, @ or a literal _ is persistent rather than transient. Whether to narrow the gate or drop it is a routing-security call I have not made unilaterally.

Whether durability should remain opt-in (ephemeral defaulting true) is the other open call.

Undrained /context and /note entries were in-memory only, so closing a tab
discarded content the API had acknowledged; they now round-trip via session metadata.
@rnoack1

rnoack1 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Requesting the allow-fork-workflow-change label so CI can run on this PR.

Current state: PR Readiness reports 4 workflow(s) awaiting maintainer approval; none has run yet, and only 5 checks have ever run on this head. No tests, lint, build or AI-review lane has executed, so there is no signal on the change itself — every push so far has produced the same held state rather than a verdict.

Why the guard fires: the only path under .github/ this PR touches is .github/black-baseline.txt, and only to DELETE lines — the entries for test files this PR reformats to be black-clean. No workflow file is added or modified. The deletions are a consequence of the reformat rather than an independent change, so dropping them is not a clean workaround: the files would be black-clean while still listed as exempt.

Precedent: the same label was applied on #7068 to clear this guard for a trusted .github/** path touch, which is the same situation here.

I do not have write access on this repository, so I cannot apply the label myself — hence the request. Happy to restructure the baseline change instead if you would prefer that to the label.

@chenmingwei23

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: chenmingwei23]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:

  • This change is 13,331 additions across 48 files touching the dashboard, the Papyrus app, and broad i18n — past the size where an automated drive-to-green session can safely reason about the whole surface.
  • It has a merge conflict with main (dirty) that spans that surface, plus Design Review and UX Review reds that are design-level, not mechanical.

When you've rebased and addressed the design/UX feedback (or split this into smaller reviewable PRs), the pipeline will re-assess on its next cycle.

@bolichen97

Copy link
Copy Markdown
Contributor

Consolidation: PR #12807 now carries this PR's core durability fix, so the rest should move onto it

@rnoack1, your split PRs overlap this one heavily, and this thread doesn't link them yet. Heads compared: this PR at 8a4ecbf26b, PR #12807 at 6e4cd44618 and PR #12666 at eed650a35a.

Overlap

Worth porting into PR #12807 (fixes to code both PRs share)

Only in this PR, not in either split

Suggested order

  1. Land PR fix(context): persist the queued background context across a close #12807 as the host, with the ports above, and PR fix(context): report a failed background-context injection instead of swallowing it #12666 alongside it.
  2. Stack whatever parts of the rest survive review on PR fix(context): persist the queued background context across a close #12807 as follow-ups:
    • the binding gate in its own PR, per the Design Review Watch
    • the sidecar deferred, per the First Principles subtraction

Please don't rebase this branch as-is. Its "HEAL AN UNBOUND SURVIVOR" branch (channel_slots.py:411-425) would override main's _rebind_unbound_channel_slot from merged PR #11696 (main channel_slots.py:451). Main's version also requires slot._channel_runtime_origin and calls note_crew_log_class / _sync_dashboard_slots.

From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.

Copy link
Copy Markdown
Contributor

PR triage (2026-10-05), checked against origin/main af1eb612da

Relationship: OVERLAPPING. Not a duplicate, and not superseded.

Breaking changes (already raised in the maintainer review above, so this is a comment, not a new request-changes):

  • /context can now return 429 context_not_queued where it used to always return 200 (chat_handlers.py).
  • DEFAULT_CONTEXT_TTL_SECS = 7d (state.py:2593), and Papyrus now sends maxAge 3600.
  • The reconnect-repost recipe now injects the context twice.
  • delete_session can now return False.
  • The persisted-binding gate (chat_utils.py:736) leaves WhatsApp +, Teams/iMessage @ and literal-_ keys unbound after restart.

No new P0 found.

Recommendation: CONTINUE-DEVELOPMENT on the split. Don't rebase this branch as-is. It is 2871 commits behind main, conflicts with it (dirty), and its "HEAL AN UNBOUND SURVIVOR" branch in channel_slots.py would override main's _rebind_unbound_channel_slot (channel_slots.py:454). Land #12807 and #12666 first, then stack the remaining riders (binding gate, sidecar, 429, contextKey reconciled with #11666) as separate PRs. Close this PR once those are carried over.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you @rnoack1 for this large and careful change.

Closing this because of a maintainer design decision. Its core cut, #12807, was closed on 2026-10-12: the gateway's pending-context queue is ephemeral by design (see #17025), like its siblings deferred_notes and queued_prompts. Persisting it across a close goes against that rule.

Your branch is kept. If that design changes, please reopen this or open a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants