fix(opencode): persist RGR implementation leases #260

Merged
jwilger merged 2 commits from fix/rgr-persistent-state-store into main 2026-05-18 18:40:16 -07:00
Owner

Why:

  • Parent and implementer sessions need a durable guardrail handoff when subagent session IDs are not known in advance or plugin processes restart.
  • Issue #28 exposed that prompt/return-value claim tokens are too brittle for RGR delegated implementation work.

What:

  • Store delegated implementation lease events in a worktree-local SQLite state DB under ignored .opencode/state/.
  • Support tokenless lease claims for eligible delegated work.
  • Use UUID lease IDs, reconcile claimed leases back to parent sessions, and scope parent locking by cycle ID so stale claims do not poison later cycles.
  • Add regression coverage for cross-instance, process-restart, parent-lock, SQLite/gitignore, and stale-cycle flows.
  • Document that .opencode/state/ is guardrail-owned state and must not be edited or committed.

Validation:

  • just opencode-test
Why: - Parent and implementer sessions need a durable guardrail handoff when subagent session IDs are not known in advance or plugin processes restart. - Issue #28 exposed that prompt/return-value claim tokens are too brittle for RGR delegated implementation work. What: - Store delegated implementation lease events in a worktree-local SQLite state DB under ignored `.opencode/state/`. - Support tokenless lease claims for eligible delegated work. - Use UUID lease IDs, reconcile claimed leases back to parent sessions, and scope parent locking by cycle ID so stale claims do not poison later cycles. - Add regression coverage for cross-instance, process-restart, parent-lock, SQLite/gitignore, and stale-cycle flows. - Document that `.opencode/state/` is guardrail-owned state and must not be edited or committed. Validation: - `just opencode-test`
fix(opencode): persist RGR implementation leases
All checks were successful
CI / Classify changed paths (pull_request) Successful in 3s
CI / Format check (pull_request) Has been skipped
CI / Clippy (pull_request) Has been skipped
CI / Test (pull_request) Has been skipped
CI / Dependency policy (pull_request) Has been skipped
CI / Build (pull_request) Has been skipped
CI / Request auto_review semantic review (pull_request) Successful in 1s
CI / opencode plugin tests (pull_request) Successful in 9s
CI / Build PR artifacts (no token) (pull_request) Has been skipped
auto_review auto_review: 2 warnings
48862ddebe
Why:
- Parent and implementer sessions need a durable guardrail handoff when subagent session IDs are not known in advance or plugin processes restart.

What:
- Store delegated implementation lease events in a worktree-local SQLite state DB under ignored .opencode/state/.
- Support tokenless lease claims, UUID lease IDs, parent claim reconciliation, and cycle-scoped stale-claim protection.
- Add RGR regression coverage for cross-instance, restart, parent-lock, and stale-cycle flows.

Validation:
- just opencode-test
auto-review approved these changes 2026-05-18 18:08:56 -07:00
Dismissed
auto-review left a comment

This PR introduces a persistent state mechanism for RGR implementation leases using SQLite, allowing tokenless lease claims across plugin instances. The changes appear well-structured, but ensure that all optional parameters and new functionalities are correctly handled across the codebase.

Walkthrough

  • .gitignore: Added .opencode/state/ to ensure state data is not committed.
  • auto-review-discipline.ts: Introduced cycleID for RGR cycles and made claimToken optional for lease claims.
  • shared.ts: Added SQLite-backed persistence for implementation leases, allowing tokenless claims and ensuring state is correctly managed across sessions.
This PR introduces a persistent state mechanism for RGR implementation leases using SQLite, allowing tokenless lease claims across plugin instances. The changes appear well-structured, but ensure that all optional parameters and new functionalities are correctly handled across the codebase. ## Walkthrough - **.gitignore**: Added `.opencode/state/` to ensure state data is not committed. - **auto-review-discipline.ts**: Introduced `cycleID` for RGR cycles and made `claimToken` optional for lease claims. - **shared.ts**: Added SQLite-backed persistence for implementation leases, allowing tokenless claims and ensuring state is correctly managed across sessions.
Owner

🟡 Warning: Lines 399–400: The claimToken argument is now optional. Ensure that all calling code handles the case where this argument is not provided.

🟡 **Warning:** **Lines 399–400:** The `claimToken` argument is now optional. Ensure that all calling code handles the case where this argument is not provided.
Author
Owner

@auto-review Addressed in e473f44. The public claim API is no longer optional-token based: rgr_claim_implementation_lease has an empty argument schema, task delegation no longer returns claimToken, and explicit claimToken input is rejected so callers cannot depend on token plumbing.

@auto-review Addressed in e473f44. The public claim API is no longer optional-token based: `rgr_claim_implementation_lease` has an empty argument schema, task delegation no longer returns `claimToken`, and explicit `claimToken` input is rejected so callers cannot depend on token plumbing.
jwilger marked this conversation as resolved
Owner

🟡 Warning: Lines 137–150: The claimDelegatedImplementationEditLease function now supports tokenless claims. Ensure that this change is compatible with existing workflows and does not introduce security risks.

🟡 **Warning:** **Lines 137–150:** The `claimDelegatedImplementationEditLease` function now supports tokenless claims. Ensure that this change is compatible with existing workflows and does not introduce security risks.
Author
Owner

@auto-review Addressed in e473f44. Tokenless claiming is now the supported workflow against the worktree-local SQLite state. The internal UUID remains only a persisted lease identity in the central state store, not a prompt-visible/API claim token.

@auto-review Addressed in e473f44. Tokenless claiming is now the supported workflow against the worktree-local SQLite state. The internal UUID remains only a persisted lease identity in the central state store, not a prompt-visible/API claim token.
jwilger marked this conversation as resolved
fix(opencode): remove RGR claim token API
All checks were successful
CI / Build PR artifacts (no token) (pull_request) Has been skipped
auto_review auto_review: 2 warnings
CI / Classify changed paths (pull_request) Successful in 3s
CI / Test (pull_request) Has been skipped
CI / Request auto_review semantic review (pull_request) Successful in 1s
CI / opencode plugin tests (pull_request) Successful in 8s
CI / Format check (pull_request) Has been skipped
CI / Clippy (pull_request) Has been skipped
CI / Dependency policy (pull_request) Has been skipped
CI / Build (pull_request) Has been skipped
e473f446ee
Why:
- Delegated RGR implementation leases now use central worktree state, so exposing claim tokens keeps a deprecated and confusing API surface.

What:
- Remove claimToken from public lease-claim schema and task delegation output.
- Reject explicit claimToken input and scope tokenless claims to the worktree state DB.
- Update RGR tests for the tokenless central-state contract.

Validation:
- just opencode-test
jwilger dismissed auto-review's review 2026-05-18 18:27:14 -07:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

auto-review left a comment

The PR removes the use of claimToken for delegated implementation leases, opting for a tokenless approach. This change simplifies the lease claiming process and enhances robustness against stale claims. The updates appear safe to merge, but ensure all dependent code and documentation are aligned with these changes.

Walkthrough

Δ since 48862dd:

  • auto-review-discipline-rgr.test.ts:
    • Added tests to ensure claimToken is neither exposed nor accepted for delegated implementation leases.
  • auto-review-discipline.ts:
    • Removed claimToken from rgr_claim_implementation_lease tool arguments.
  • shared.ts:
    • Updated recordDelegatedImplementationEditLease to no longer return a token.
    • Modified claimDelegatedImplementationEditLease to read from persisted leases when a worktree is provided.
The PR removes the use of `claimToken` for delegated implementation leases, opting for a tokenless approach. This change simplifies the lease claiming process and enhances robustness against stale claims. The updates appear safe to merge, but ensure all dependent code and documentation are aligned with these changes. ## Walkthrough ### Δ since 48862dd: - **auto-review-discipline-rgr.test.ts**: - Added tests to ensure `claimToken` is neither exposed nor accepted for delegated implementation leases. - **auto-review-discipline.ts**: - Removed `claimToken` from `rgr_claim_implementation_lease` tool arguments. - **shared.ts**: - Updated `recordDelegatedImplementationEditLease` to no longer return a token. - Modified `claimDelegatedImplementationEditLease` to read from persisted leases when a worktree is provided.
Owner

🟡 Warning: The rgr_claim_implementation_lease tool no longer accepts a claimToken argument. Ensure that all calling code and documentation are updated to reflect this change.

🟡 **Warning:** The `rgr_claim_implementation_lease` tool no longer accepts a `claimToken` argument. Ensure that all calling code and documentation are updated to reflect this change.
Author
Owner

@auto-review Addressed. I removed the claimToken argument from rgr_claim_implementation_lease, updated the tests and call sites to use tokenless claims, and kept an explicit rejection test for legacy token input.

@auto-review Addressed. I removed the `claimToken` argument from `rgr_claim_implementation_lease`, updated the tests and call sites to use tokenless claims, and kept an explicit rejection test for legacy token input.
jwilger marked this conversation as resolved
@ -2,2 +4,4 @@
import path from "node:path";
import { DatabaseSync } from "node:sqlite";
export type RgrStage =
Owner

🟡 Warning: The function recordDelegatedImplementationEditLease no longer returns a token. Ensure that any code relying on this return value is updated accordingly.

🟡 **Warning:** The function `recordDelegatedImplementationEditLease` no longer returns a token. Ensure that any code relying on this return value is updated accordingly.
Author
Owner

@auto-review Addressed. recordDelegatedImplementationEditLease no longer returns a token, and the only caller now records the lease in central state without reading a return value. Tests cover that delegation output does not expose claimToken.

@auto-review Addressed. `recordDelegatedImplementationEditLease` no longer returns a token, and the only caller now records the lease in central state without reading a return value. Tests cover that delegation output does not expose `claimToken`.
jwilger marked this conversation as resolved
jwilger left a comment

Addressed review feedback by removing the public claimToken API surface in favor of central tokenless state-machine claims.

Addressed review feedback by removing the public claimToken API surface in favor of central tokenless state-machine claims.
Author
Owner

@auto-review Addressed. The public lease-claim contract is now tokenless: rgr_claim_implementation_lease no longer declares or accepts claimToken, and explicit claimToken input is rejected with a central-state error. Delegation also no longer returns a claim token.

@auto-review Addressed. The public lease-claim contract is now tokenless: `rgr_claim_implementation_lease` no longer declares or accepts `claimToken`, and explicit `claimToken` input is rejected with a central-state error. Delegation also no longer returns a claim token.
jwilger marked this conversation as resolved
Author
Owner

@auto-review Addressed. Tokenless claiming now uses the worktree-local SQLite state as the authority. The internal UUID lease id remains only as a persisted implementation detail, not a prompt/API token, and tokenless claims are scoped to the worktree state DB to avoid cross-test/session ambiguity.

@auto-review Addressed. Tokenless claiming now uses the worktree-local SQLite state as the authority. The internal UUID lease id remains only as a persisted implementation detail, not a prompt/API token, and tokenless claims are scoped to the worktree state DB to avoid cross-test/session ambiguity.
jwilger marked this conversation as resolved
jwilger deleted branch fix/rgr-persistent-state-store 2026-05-18 18:40:16 -07:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Slipstream/auto_review!260
No description provided.