Repository navigation
fix(j5): reject changed Crew proposal replay requests - #661
Conversation
Compare immutable original proposal fields before live validation and again after concurrent create/admit. Identical retries retain the original proposal after approval, decline, catalog changes and partial failures. Keep the existing stable ids and admission rules. Replay omits the optional live-validation playbook summary. Existing ambiguous or archived crew target selection still refuses visibly. Co-Authored-By: GPT-6.1-Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
tyler-barton-horizon
left a comment
There was a problem hiding this comment.
Non-blocking review. The replay ordering and the post-create/admit re-check look right to me, and the identical/mismatched/concurrent coverage is solid. A few simplification and consistency notes are inline; none of them block merging.
| ); | ||
| } else { | ||
| const stem = name.endsWith(".yaml") ? name.slice(0, -5) : name; | ||
| // Older rows can prove a workspace-local path, but cannot prove a library workspace. |
There was a problem hiding this comment.
Non-blocking: I don't think requestWorkspaceRoot adds anything to the comparison. PlaybookStore.definitionPathFor is just path.resolve(workspaceRoot, ".j5/playbooks", ${stem}.yaml), so a stored definitionPath already pins exactly one resolved workspace root (and stem). The legacy branch here, which recomputes the path and compares { path }, is therefore equivalent for new rows as well.
If that's right, you could drop the column, migration 040, the optional CrewPlaybookRef.requestWorkspaceRoot field and the two-shape playbook key in proposalRequest, and always compare the resolved path. Nothing "library" resolves elsewhere today, so the comment about a library workspace reads as hypothetical. If a non-local lookup is planned, it would help to say so here.
There was a problem hiding this comment.
The premise changed after merging current main through #660: PlaybookStore now resolves nonlocal libraries. Retained requestWorkspaceRoot and migration 040. The real PlaybookLibrary regression in f6c916d proves that two caller workspaces can select the same definitionPath, changed-workspace reuse must conflict, and identical replay survives a local override or removal of the library source. The normalized caller workspace preserves original intent without consulting a changed catalog. All 179 focused tests passed.
|
|
||
| export default Effect.gen(function* () { | ||
| const sql = yield* SqlClient.SqlClient; | ||
| yield* sql`ALTER TABLE j5_agent_crew_proposal ADD COLUMN playbook_request_workspace_root TEXT`; |
There was a problem hiding this comment.
Non-blocking: the PR description says "No new table or migration is added", but this adds migration 040. Can you update the description? It's also worth noting this next to the existing 039 / #638 overlap caveat, because 040 will have to be renumbered along with it when the stack is reconciled. (If the column turns out to be unnecessary, see the comment on CrewProposalService.ts, this file goes away.)
There was a problem hiding this comment.
Fixed the description. It explicitly names migration 040 (CrewPlaybookRequestWorkspace), explains the original request workspace needed for current nonlocal libraries, and states that this layer adds no table. The integration caveat covers inherited 039 and child 040.
| workspace?.type === "worktree" | ||
| ? { ...workspace, startFromOrigin: workspace.startFromOrigin ?? false } | ||
| : workspace?.type === "existing_worktree" | ||
| ? { ...workspace, worktreePath: workspace.worktreePath.replace(/[\\/]+$/, "") } |
There was a problem hiding this comment.
Non-blocking: this regex duplicates worktreePathKey in spawnWorkspace.ts:52, which the launcher already uses to match worktree paths. Exporting and reusing it would keep replay equality and launch-time matching from drifting apart if that normalization ever changes (for example, to also path.resolve).
There was a problem hiding this comment.
Fixed in the source published as f6c916d. Exported and reused the existing worktreePathKey from spawnWorkspace.ts so replay comparison and launch matching share normalization. Focused workspace/launcher tests pass as part of the 179-test run.
| ) { | ||
| if (requestDigest(proposalRequest(original)) !== requestDigest(proposalRequest(request))) | ||
| return yield* new CrewProposalRequestError({ | ||
| detail: `client_request_id is already bound to a different request for proposal ${original.id}${original.crewInstanceId === null ? "" : ` and crew ${original.crewInstanceId}`}.`, |
There was a problem hiding this comment.
Nit: this detail/nextStep copy repeats the wording of RequestReplayConflictError.message in RequestReplayService.ts. A shared helper or constant would keep the two replay-conflict messages from diverging, since agents see both.
There was a problem hiding this comment.
Fixed in the source published as f6c916d. Both conflict paths use requestReplayConflict(target) from RequestReplayService.ts. Regression assertions cover the exact agent-facing message; the 179 focused tests passed.
bryantderosier
left a comment
There was a problem hiding this comment.
Reconciled review from two independent reviewers: OpenAI GPT-6.1-Sol and Anthropic Claude Opus 5.5. No blocking code defect was confirmed in this incremental layer. Approving base 839b7b0 -> head e89bff4; both were rechecked before submission.
Integration advisory: this approval covers the reviewed stack base. #660 remains blocked by its separate review and must land first; recheck this layer after rebasing/retargeting. Migration 040 overlaps open #638's 040_Links (and inherited 039 overlaps that PR too). Coordinate migration IDs with whichever history lands first; see inline comment. The overlap with an unmerged branch is an integration constraint, not a runtime defect against this base.
Please refresh the PR description: it says no migration was added, but this head adds 040_CrewPlaybookRequestWorkspace. The validation section also cites older tips and does not describe the e89bff4 behavioral change.
Validation reported by reviewers: OpenAI ran 4 focused files / 68 passing tests and a pinned diff whitespace check; Anthropic ran 9 focused files / 111 passing tests and a passing server typecheck. These are separate runs with overlapping coverage, not an aggregate unique-test count. No live server/provider turns or browser testing occurred. No additional runtime findings survived reconciliation.
| [37, "PersonNames", Migration0037], | ||
| [38, "OpenLinkJoins", Migration0038], | ||
| [39, "RequestReplay", Migration0039], | ||
| [40, "CrewPlaybookRequestWorkspace", Migration0040], |
There was a problem hiding this comment.
Integration advisory, nonblocking against this base: migration ID 40 is also used by open #638 for 040_Links; inherited ID 39 overlaps its 039_PeopleAndLevels. The migration tracking table uses numeric IDs, so carrying both histories without reconciling numbering can skip required schema changes. Whichever branch lands second must reconcile its migration IDs against the merged history and rerun migration tests. Please also correct the PR body's statement that no migration was added.
There was a problem hiding this comment.
Documented both overlapping IDs and corrected the migration claim in the PR body. Current merged main ends at 038, so 039/040 have no present collision; #638 remains open with 039–043. Whichever workstream merges second must renumber against the actual merged history and rerun migration tests. Renumbering ahead now is unsafe because the migrator skips IDs at or below the latest applied migration. No speculative renumbering was made.
# Conflicts: # apps/server/src/j5/a2a/RequestReplayService.ts
|
@bryantderosier Addressed your review feedback. The description now explicitly names migration 040 and its purpose, records the current validation head, and documents the merge-order requirement for migrations 039/040 versus #638. Current head |
* fix(j5): reject changed spawn replay requests Co-Authored-By: GPT-6.1-Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(j5): verify spawn replay failures and concurrent retries Restore complete live-caller shell fixtures and assert injected failure causes. Keep identical and mismatched concurrent retries as distinct cases, and authorize persisted children before replaying create. Integration note: RequestReplay migration 039 conflicts with pending #638 migrations 039–042; reconcile numbering against main before publication. Co-Authored-By: GPT-6.1-Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(j5): address spawn replay review comments Keyless spawns no longer write replay rows nobody can retry. The replay service declares its interface inline, and check no longer returns an unused boolean. Both replay mode checks share one message; the early one stays because it is the only check an unbound legacy agent reaches. Replay rows record created_at, and the spawn tool description says that any change under a reused client_request_id is refused. * fix(j5): refuse bad spawn attachments before binding the key Duplicate attachment ids, attachment limits and non-pending references are refused before the client_request_id is bound, so a corrected list can be retried under the same key instead of being refused as a changed request. A replay-store SQL failure now tells the caller to retry the same key, keeping the inspect-target guidance for real conflicts. The agent tools doc states the whole-request binding. * fix(j5): reject changed Crew proposal replay requests (#661) * fix(j5): reject changed crew proposal replay requests Compare immutable original proposal fields before live validation and again after concurrent create/admit. Identical retries retain the original proposal after approval, decline, catalog changes and partial failures. Keep the existing stable ids and admission rules. Replay omits the optional live-validation playbook summary. Existing ambiguous or archived crew target selection still refuses visibly. Co-Authored-By: GPT-6.1-Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): replay crew proposals before playbook lookup * fix(j5): simplify crew proposal replay comparison * fix(j5): preserve replay workspace for playbook libraries * test(j5): verify crew replay against playbook libraries --------- Co-authored-by: GPT-6.1-Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * fix(j5): validate upload metadata before accepting spawns * refactor(j5): own direct spawn acceptance in domain service * fix(j5): complete replay recovery and canonical contracts * fix(j5): refuse cross-workspace legacy retries before binding --------- Co-authored-by: GPT-6.1-Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Reusing a Crew proposal or seat-addition request key with different arguments returned the first proposal as if it matched. Fixes #316's proposal replay bug.
What changed
Compare retries with the proposal's original stored request, independently of the person's approved roster. Normalize workspace defaults and playbook identity, exclude server-derived persona swaps, and check existing proposals before mutable catalog, playbook, seat-name and capacity validation. Check the stored row after create/admit too, so concurrent first attempts cannot silently return a different request. Replay and launch reuse the same worktree-path normalization; spawn and Crew conflicts share their error wording.
Migration 045 (
CrewPlaybookRequestWorkspace) adds the nullable original request workspace to proposal rows; this layer adds no table. Currentmainresolves playbooks from environment and configured folder libraries, so the selected definition path can be shared by different caller workspaces or change after a local override. New proposals store the normalized caller workspace and replay without re-resolving the live library. Older proposals retain the existing local-path comparison.This is layer 2, based on #660 (
fix/181-spawn-replay). Parent head7f39d8dc070197730ceb4505a45eaeead8876d13, including currentj5/mainat557750d3f9, is merged normally into this branch. Merge #660 first and retarget this PR toj5/mainafterward.Validation
Validated the source published as
12022e74cca17c033d15e20a224f9dc5f342681e:Live testing
No live server or provider turns were run. Verification uses handler/service tests with real SQLite persistence and temporary filesystem libraries, plus controlled launch fakes. No UI changes.
Limits
A pre-045 proposal that selected a nonlocal library path cannot prove its original caller workspace, so its replay is visibly refused; use a fresh request key for new work.
The stale
stop_agent/stop_crewreceipt behavior described in #316's comment is a separate mechanism and remains unchanged. Seat additions retain the existing visible refusal when an omitted Crew target becomes ambiguous or the Crew is no longer commanded. A replay does not recompute the optional fresh playbook-validation summary.#638 has merged into
j5/main, occupying migration IDs 039–043. This stack now preserves those IDs and uses 044 for parent replay storage and 045 for the original Crew playbook request workspace. Migration upgrade tests cover the merged schema; there is no remaining numbering overlap with #638.Checklist
Implemented with GPT-6.1-Sol in Codex; parent-layer fixes and prior review by Claude Opus 5.5 in Claude Code.