Chat: Edit and Regenerate work on the session authority (bugfix) #476
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #476"
general
weight: 0.35
Giton22
Edit a prompt and Regenerate a reply (both
ChatSession.rewind) on a session-authority gateway. The legacy path sends what it sent before.1. Edit and Regenerate on a session-authority gateway
Before: on a gateway whose
gateway.readyhassession_authority: true(the gateway-hosted Webapp listener),prompt.submittakes a closed set of keys. The one request a rewind sent was refused, so Edit and Regenerate did nothing:Now, as Hermes Desktop does there (
splitRewindSubmitinapps/desktop/src/api/canonical-protocol.ts, v0.23.3):1.
session.mutatewithoperation: "rewind",payload: {target_message_id: <the prompt's row>}, arequest_id, and the session'sexpected_revisionandexpected_generation(the same fences branching uses since #469).2. A plain
prompt.submitwith the new text and no truncation keys.What happens when it doesn't go:
revision_conflict,stale_generation,session_busy, or a row the gateway can't place): nothing was written. The chat goes back as it was, says why, and reloads the transcript. A fence refusal's current revision and generation are kept for the next try. It is not sent again by itself, unlike a branch: what changed elsewhere may be turns the cut would throw away.Two more things were needed for a prompt sent in this session, both found against the real gateway:
prompt.submitthere answers before the prompt's row is written, with nouser_row_id, so the prompt had no row to cut at until the chat was opened again. It now goes with asubmission_idof its own and takes its row from its turn'smessage.complete(persisted_turn.user_row_id, matched bysubmission_id).prompt.submit"queued", one that starts a turn too. With a quick turn,message.startarrives before that reply is read, and the prompt stayed "Queued · sends after this task" for good, with no Edit or Regenerate. A prompt that starts a turn there is no longer marked queued; one sent mid-turn still is.2. The legacy path is unchanged
Off the session authority a rewind still sends one
prompt.submitwith exactlysession_id,text,truncate_before_row_id,confirm_truncateandconfirm_empty_truncate, as before. (A first version of this PR also sentconfirm_deep_truncatethere; that was taken out in review: no hermes-agent from v0.22.0 to v0.23.4 enforces it,DEEP_TRUNCATE_ENFORCED = False, and it is a separate change.)A session authority that answers
session.mutatewith -32601 has nothing to fall back to (itsprompt.submitrefuses the truncation keys): the chat stays as it was, no prompt goes, and it says the gateway can't cut a chat back. Every authority version in the supported window hassession.mutaterewindwithtarget_message_id.How it was tested
Unit tests (
ChatSessionTest): the authority rewind sendssession.mutatethen aprompt.submitwith onlysession_id,textandsubmission_id; each refusal; -32601; the prompt failing after the cut, refused or with no answer; a cut with no answer; the row frommessage.complete; the "queued" race. Edit, Regenerate and a cut at the first prompt are each tested in both modes, with the exact keys of each request. The CI command and:desktopApp:compileKotlinJvmpass locally.Raw JSON-RPC probes against local test gateways with a fake model:
| Gateway | Result |
|---|---|
| v0.23.3 Webapp listener (session authority) | Old request:
4001 invalid_paramsas above.session.mutaterewind: stale revision →revision_conflictand stale generation →stale_generation, both with the current fences; mid-turn →session_busy; a row that isn't a prompt →invalid_params, fieldtarget_message_id. None changed the stored rows. With the right fences the rows from the target on are gone, and the plainprompt.submitwrites the new prompt. |Version × mode matrix (supported window v0.22.0 to v0.23.4; Edit of an earlier prompt with a later turn, Regenerate of the last reply, Edit of the first prompt; the old request on the authority; a stale fence and a cut row):
| Version | Legacy (
hermes dashboard) | Session authority ||---|---|---|
| v0.22.0 | contract validator + live probe: pass | none in this version |
| v0.22.3 | contract validator + live probe: pass | contract validator + rewind payload validator: pass; not live (its authority listener is loopback-only with control-socket tickets, no Webapp listener) |
| v0.22.7 | contract validator + live probe: pass | contract validator + payload validator + live probe on the Webapp listener: pass |
| v0.23.4 | contract validator + live probe: pass | contract validator +
parse_mutation+ live probe on the Webapp listener: pass |In the app (Dev build on an emulator, signed in to the v0.23.3 Webapp listener), checking the gateway's stored rows after each step:
These app checks were made before review; the review changes (legacy request back to as before, the -32601 message) were checked by unit tests and the probes above, not again in the app.
Not proved in the app: the legacy path (probe and unit tests only), and the failure paths on the authority (refusals and a prompt failing after the cut), which are covered by unit tests and the probe's refusal shapes. The fake model makes no tool calls, so a rewind over a turn with tool steps wasn't tried on a device.
Overlap
#473 also edits
ChatSession.rewind(it wraps the body in the send lock). Here the request itself for the authority moved out intomutateRewind, and the changes insiderewindare a few lines around that call and in its error handling, so whichever merges second has a small conflict there.ROADMAP: "edit-and-resend as a
rewind" moved from the open session-authority item to the Regenerate/Edit item.Review follow-ups (rebased on master)
Two fixes from a fresh-context review, each with a test that fails without it:
8d5b71beA prompt edited or regenerated on the session authority now goes with asubmission_idit keeps, so its turn'smessage.completegives it its row even when the transcript can't be read afterwards, and theexecution_generationtheprompt.submitreply gives is kept for the next stop, approval or cut.4568610aIf that turn ends before theprompt.submitreply is read, the row it got is no longer wiped by the reply (which has nouser_row_idon the authority), as the send path already does.In the app on this head's code (Dev build on an emulator, local test gateways with a fake model, stored rows checked after each step):
| Gateway | master | this PR |
|---|---|---|
| v0.22.3 session authority (its gateway-hosted listener, bound to a reachable port for the test) | Regenerate:
invalid_params, nothing changes | Regenerate (reopened chat and same-session prompt), Edit of the first prompt, Regenerate right after an edit: all cut and resend || v0.23.4 session authority (Webapp listener) | Regenerate:
invalid_params| Regenerate, Edit of an earlier prompt with a later turn (confirm dialog, "discard 2 later messages"), Regenerate after it, and after another client cut the chat || v0.23.4 legacy (
hermes dashboard) | works | still works: Regenerate and Edit of an earlier prompt |Once on v0.22.3, the first Regenerate after reinstalling the app was refused as "changed somewhere else" and went through on the next tap. I couldn't make it happen again in 6 more tries (relaunches, a gateway restart, quick taps).
Version × mode probe on this head's requests (raw JSON-RPC, the exact params
rewindsends): v0.22.0 legacy; v0.22.3, v0.22.7 and v0.23.4 in both modes. All pass: on the authority the old one-request rewind is refused with 4001, stale revision and generation are refused with the current fences, a reply's row is refused (field: target_message_id), refusals leave the rows as they were,message.completenames the prompt's row bysubmission_id, and Edit of an earlier prompt, Regenerate of the last reply and Edit of the first prompt leave the expected rows. Off the authority the same three cuts work with the unchanged legacy keys.