You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6c15c41
Browse filesBrowse the repository at this point in the historyBrowse files
Address Copilot round 10 on F2d: own the review version too
- recordAlreadyFixed takes the review version the publish read and
refuses a result obtained before a review change.
- Each opening and refresh stores the plan's review version it owns;
its confirmation still records the PR but moves the task only when
both the state version and the review version are unchanged.
Recovery treats a lost opening as current only under both.
- Design doc: adoption happens in step 3, not in the update; the owned
versions are the state and review versions.
- AGENTS.md: an in-flight action owns every version counter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ For features with background jobs, polling, retries, cancellation, or shutdown:
9
9
- Define the lifecycle states and ownership before implementation: pending, running, completed, failed, cancelled, stale, and closing.
10
10
- Treat persisted state, in-memory jobs, subprocesses, HTTP requests, and rendered UI as separate state holders. Define how each transitions and settles.
11
11
- Never apply a background response without proving it is still current. Use a generation, attempt ID, version, or guarded merge so older polling responses cannot overwrite newer actions.
12
+
- When the local state has more than one version counter (for example a task's state version and its plan's review version), an in-flight action owns all of them, and applying its response requires every one to be unchanged. One counter does not cover writes that advance only another.
12
13
- A current response may still move a record only along a transition allowed from the state the action was guarded for. Derive the new status from that state as well as the response; a response alone must never move a record out of a state that waits for a person.
13
14
- Do not release a concurrency slot when cancellation is requested. Keep the job tracked until its underlying invocation or subprocess has terminated.
14
15
- Do not let a retry replace a locally active job, even when its persisted lease has expired or wall-clock time changes.
Copy file name to clipboardExpand all lines: docs/implementation/pull-request-opening.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,9 +56,9 @@ Only one publish runs per task at a time; a second one is refused. A publish who
56
56
4.**Check.** Run the check. Record the result, and any status change, in one transaction. That transaction refuses if the task changed during the check.
57
57
5.**Push.** When the task already has an open PR, the refresh is recorded first (the push moves that PR's head), then the push runs; otherwise the push runs straight after the check's transaction with no await in between. Push the task head to `codeboost/issue-<issue>-<task slug>-<hash>`. The slug is readable but can collide. The hash is 16 hex characters of SHA-256 over the exact task identity, so two tasks never share a branch.
58
58
6.**Re-read.** Right before the GitHub call, the Store confirms that the latest check is clear and that nothing changed since that check: same task state version, same review version (approvals, choices and notes), same snapshot, same head.
59
-
7.**Open or reuse.** Open a new PR (a draft opening that GitHub creates as ready fails, keeping the opening owned; recovery then turns it into a draft), or update the open earlier PR (found in step 3 with the markers of every earlier opening, abandoned ones included; an abandoned opening's PR is adopted in the same transaction that records the update) and mark it ready (or a draft). An update is recorded before it starts. If its confirmation is lost, the next publish drops the record in step 1 and repeats the update after a new check; the update is idempotent. Record the result.
59
+
7.**Open or reuse.** Open a new PR (a draft opening that GitHub creates as ready fails, keeping the opening owned; recovery then turns it into a draft), or update the open earlier PR (found in step 3 with the markers of every earlier opening, abandoned ones included; an abandoned opening's PR was already adopted in step 3, and an update only ever starts on an opened record) and mark it ready (or a draft). An update is recorded before it starts. If its confirmation is lost, the next publish drops the record in step 1 and repeats the update after a new check; the update is idempotent. Record the result.
60
60
61
-
Each opening or refresh owns the task state version at the moment it passed step 6. The PR is always recorded. The status changes only when the task still has that version. Every status change, admission and context change increases the version. So a response that arrives after the task changed never moves it.
61
+
Each opening or refresh owns the task state version and the plan's review version at the moment it passed step 6. The PR is always recorded. The status changes only when the task still has both (review input such as approvals, choices and notes changes only the review version). Every status change, admission and context change increases the version. So a response that arrives after the task changed never moves it.
62
62
63
63
| Task during the GitHub call | PR | Status after |
if(this.#get("SELECT 1 FROM task_pull_requests WHERE plan_key=? AND state='opening'",key))thrownewGuardRefusal('A pull request is already being opened; recover it first.');
this.#run(`INSERT INTO task_pull_requests (opening_id,plan_key,repository,base,head_branch,head_sha,draft,owner_version,state,number,url,created_at,updated_at)
this.#run(`INSERT INTO task_pull_requests (opening_id,plan_key,repository,base,head_branch,head_sha,draft,owner_version,owner_review_version,state,number,url,created_at,updated_at)
this.#run('UPDATE task_pull_requests SET refresh_head=?, refresh_draft=?, refresh_version=?, refresh_review_version=?, updated_at=? WHERE opening_id=?',
if(this.#run("UPDATE task_pull_requests SET refresh_head=NULL, refresh_draft=NULL, refresh_version=NULL, updated_at=? WHERE plan_key=? AND opening_id=? AND refresh_head IS NOT NULL",
1016
+
if(this.#run("UPDATE task_pull_requests SET refresh_head=NULL, refresh_draft=NULL, refresh_version=NULL, refresh_review_version=NULL, updated_at=? WHERE plan_key=? AND opening_id=? AND refresh_head IS NOT NULL",
1013
1017
newDate().toISOString(),key,openingId).changes!==1)thrownewGuardRefusal('No update of this pull request is in flight.');
1014
1018
this.#touch(key);
1015
1019
});
@@ -1030,7 +1034,7 @@ export class Store {
1030
1034
constkey=identityKey(identity);
1031
1035
returnthis.#confirmPullRequest(key,pr,()=>
1032
1036
this.#get("SELECT * FROM task_pull_requests WHERE plan_key=? AND opening_id=? AND state='opening'",key,openingId),
1033
-
row=>({head: row.head_shaasstring,owned: row.owner_versionasnumber}),openingId,'No pull request is being opened with this ID.');
1037
+
row=>({head: row.head_shaasstring,owned: row.owner_versionasnumber,ownedReview: row.owner_review_versionasnumber}),openingId,'No pull request is being opened with this ID.');
1034
1038
}
1035
1039
/** A refresh of the task's open PR landed, for the head and state version beginRefresh recorded. Same status rule. */
this.#get("SELECT * FROM task_pull_requests WHERE plan_key=? AND opening_id=? AND state='opened' AND number=? AND refresh_head=? AND refresh_version=?",
()=>({head: refresh.head,owned: refresh.stateVersion}),openingId,'No update of this pull request is in flight.');
1046
+
row=>({head: refresh.head,owned: refresh.stateVersion,ownedReview: row.refresh_review_versionasnumber}),openingId,'No update of this pull request is in flight.');
0 commit comments