Skip to content

refactor(projects): resolve refresh ownership in state worker - #149392

Merged
steipete merged 31 commits into
mainfrom
codex/projects-refresh-registration65985-20260915
Sep 16, 2026
Merged

steipete merged 31 commits into
mainfrom
codex/projects-refresh-registration65985-20260915

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Managed clone refresh moves its saved-ownership lookup to the existing shared-state worker. The worker matches the saved identity under the original checkout lease; the host captures inputs before awaiting and checks live ownership before and after refresh transport. Stale refusal and registered-project no-op behavior remain intact.

Refresh also uses the canonical platform-aware environment snapshot before worker-context capture, preserving mixed-case Windows state-directory and supervisor settings. This six-file change follows landed #149386. The other three environment-capture fixes remain in #150010, which extends the same test file from two refresh cases to eight producer cases.

Source ecd22c71895e984ed6552aaabb885dd7d5eda5ca passed independent P0–P2 review. Both refresh cases fail with the original plain spread and pass with the fix; the existing stale-refresh control also passed with current canonical workers. The environment cases mock Windows semantics, not a Windows OS run.

Separately, artifact db3194e0 passed cold, display-name-only and reopened refresh through the actual source producer and canonical compiled workers, using three mocked transport calls. Samples were 432.53 ms cold, 3.76 ms display-name-only, 449.72 ms reopened, and 3.20 ms stale refusal. Host project-domain SQL counters stayed zero; native lease/bootstrap work remained. These are artifact-bound samples, not current-head benchmarks or whole-flow zero-SQL proof. Older 1b295847 samples used a 32-statement cache; current source uses 64.

Exact-head CI passed: run 35126409623. No new build/package/update claim is made for this source carry. The earlier refresh timeout and mock-server exit remain unattributed.

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 15, 2026 20:10
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 1:46 PM ET / 17:46 UTC (Revision 10).

ClawSweeper review

What this changes

Moves managed repository refresh ownership checks into the shared state worker and preserves Windows environment settings while capturing inputs before asynchronous work.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still performs refresh ownership lookup on the host. The previous Windows finding is resolved, and this review found no introduced blocking defect. Maintainer-authored work also remains protected from automatic closure.

Priority: P2
Reviewed head: ecd22c71895e984ed6552aaabb885dd7d5eda5ca

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused cutover with the prior defect repaired, useful regression coverage, and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER status exempts this internal refactor from ordinary contributor proof. The body distinguishes current source checks from historical worker runs with mocked transport; source tracing found no unresolved material authority change requiring additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER status exempts this internal refactor from ordinary contributor proof. The body distinguishes current source checks from historical worker runs with mocked transport; source tracing found no unresolved material authority change requiring additional final-effect proof.
Evidence reviewed 10 items Current main still needs the cutover: At the fetched main revision, resolveProjectCloneRefreshOwner still executes its registry query and lease check synchronously on the host.
Captured inputs and final host check: Refresh captures project identity, environment, database path, signal, timeout, and token before awaiting; after worker resolution it checks live lease ownership before calling the existing Git refresh owner.
Worker preserves the ownership predicate: The new handler checks checkout scope and repository key, obtains live transaction admission, and matches the existing registry identity. The kernel still compares ID, root, source, and origin; display-name changes do not invalidate ownership.
Findings None None.
Security None None.

How this fits together

Projects manages repositories used to create session worktrees. When a selected branch needs refreshing, the registry and checkout lease determine whether Git may fetch into the managed repository.

flowchart TD
  A[Session requests repository branch] --> B[Capture project and environment]
  B --> C[Acquire checkout lease]
  C --> D[State worker checks saved identity]
  D --> E{Identity and lease valid?}
  E -->|No| F[Refuse refresh]
  E -->|Yes| G[Recheck ownership and refresh Git refs]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +41, Tests +168. Total +209 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 82 41 +41
Tests 1 168 0 +168
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 250 41 +209

Review metrics

Metric Value Why it matters
Production versus test growth Production +41 net lines; tests +168 net lines Production growth captures stable inputs and integrates the existing worker; test growth covers the two Windows environment regression cases.

Technical review

Best possible solution:

Keep refresh on the existing shared-state worker while preserving the original checkout lease, registry identity predicate, and captured environment through Git completion.

Do we have a high-confidence way to reproduce the issue?

Not applicable to the primary internal refactor. The prior Windows defect has focused before/after coverage reported in the body and a source-verified repair; this review did not run tests.

Is this the best way to solve the issue?

Yes. The patch extends the established worker and lease-admission owners, removes the host refresh query, and preserves stored data and public contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b2a9dc036c3e.

Labels

Label justifications:

  • P2: This is a bounded Projects worker cutover with a focused environment-preservation repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER status exempts this internal refactor from ordinary contributor proof. The body distinguishes current source checks from historical worker runs with mocked transport; source tracing found no unresolved material authority change requiring additional final-effect proof.

Evidence

What I checked:

  • Current main still needs the cutover: At the fetched main revision, resolveProjectCloneRefreshOwner still executes its registry query and lease check synchronously on the host. (src/projects/project-registry.ts:162, b2a9dc036c3e)
  • Captured inputs and final host check: Refresh captures project identity, environment, database path, signal, timeout, and token before awaiting; after worker resolution it checks live lease ownership before calling the existing Git refresh owner. (src/projects/project-clone.ts:182, ecd22c71895e)
  • Worker preserves the ownership predicate: The new handler checks checkout scope and repository key, obtains live transaction admission, and matches the existing registry identity. The kernel still compares ID, root, source, and origin; display-name changes do not invalidate ownership. (src/state/openclaw-state.worker.ts:453, ecd22c71895e)
  • Lease identity is not standalone authority: Worker admission requires the original live lease object and matching database path. Its grant checks current scope, exact identity, and expiry, and retains operations through settlement; refresh continues to pass the lease cancellation signal to Git. (src/state/openclaw-state-lease-worker-owner.ts:178, ecd22c71895e)
  • Previous Windows finding resolved: The current producer uses cloneEnvWithPlatformSemantics. Both new cases exercise caller mutation across the awaited checkout boundary with plain and precloned Windows-style environments. The captured body reports before/after failures and passes; these are mocked platform semantics, not a Windows OS run. (src/projects/project-environment.test.ts:95, ecd22c71895e)
  • Existing forbidden-outcome coverage: Existing tests verify that removal and operator re-registration prevent fetching a new commit or publishing its remote ref, and that persisted lease loss cancels an in-flight Git transport. These tests were inspected, not executed during this review. (src/projects/project-registry.test.ts:540, ecd22c71895e)

Likely related people:

  • unknown: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-15T23:28:30.312Z sha ce976b9 :: blocked before merge. :: none
  • reviewed 2026-09-16T00:13:52.437Z sha ce976b9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T04:37:31.724Z sha 5525f91 :: blocked before merge. :: none
  • reviewed 2026-09-16T07:34:37.645Z sha d1b20bb :: blocked before merge. :: none
  • reviewed 2026-09-16T08:22:27.925Z sha e205248 :: blocked before merge. :: none
  • reviewed 2026-09-16T10:54:02.163Z sha 5abf79e :: blocked before merge. :: none
  • reviewed 2026-09-16T13:03:59.156Z sha a50058e :: blocked before merge. :: [P1] Preserve Windows environment semantics when capturing refresh inputs
  • reviewed 2026-09-16T17:16:52.862Z sha ecd22c7 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft September 15, 2026 22:52
@steipete
steipete force-pushed the codex/projects-registration-7e73-successor-20260915 branch from 65985f7 to d4388c2 Compare September 15, 2026 22:52
@steipete
steipete force-pushed the codex/projects-refresh-registration65985-20260915 branch from b514eda to ce976b9 Compare September 15, 2026 22:52
@steipete
steipete marked this pull request as ready for review September 15, 2026 22:53
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 16, 2026
@steipete
steipete marked this pull request as draft September 16, 2026 15:45
@steipete
steipete changed the base branch from codex/projects-registration-7e73-successor-20260915 to main September 16, 2026 15:46
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: XL and removed size: S labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 17:05
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed gateway Gateway runtime commands Command implementations size: XL labels Sep 16, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 16, 2026
@steipete
steipete merged commit 70b587b into main Sep 16, 2026
274 checks passed
@steipete
steipete deleted the codex/projects-refresh-registration65985-20260915 branch September 16, 2026 18:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…aw#149392)

* refactor(projects): move registry removal to the state worker

* refactor(projects): move project listing to shared state worker

* refactor(projects): register checkouts through shared state worker

* refactor(projects): resolve refresh ownership in state worker

* fix(projects): preserve Windows environment during refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant