Skip to content

feat(core): Brought a worker's stale worktree forward before it drains. - #14

Closed
moetemp wants to merge 1 commit into
2026/08/opencode-temporalfrom
moe/worktree-freshness
Closed

moetemp wants to merge 1 commit into
2026/08/opencode-temporalfrom
moe/worktree-freshness

Conversation

@moetemp

@moetemp moetemp commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

This PR makes a worker whose project tree is behind the store rebuild it before a drain runs, and orders the snapshot packs by their chain.

A worktree was only rebuilt when the directory was missing, so a worker that had run an earlier step of a session served files from that step. The store's newest capture is the target now. What the rebuild may touch is bounded by a host-local note (snapshot/tip.ts) saying which state this host's tree is at: a tree is moved only when the note says this host is behind, so a host holding a capture that never shipped is left alone.

Packs are ordered by their parent chain rather than by time_created, because two hosts do not agree on the time, and a later pack written by a slower clock would otherwise read as the older one.

Tests: packages/core/test/snapshot-chain.test.ts and the materializer cases in packages/core/test/worktree-materialize.test.ts.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

…ed the packs by their chain.

A worker that ran an earlier step served files from that step: rebuilding only when the directory was missing left it behind the store. A host-local note says which state this host agreed to, so a tree is moved forward only from a state it built or captured, and a developer's own checkout is left alone. Packs are ordered by the chain they form rather than by a write clock hosts do not share, an empty directory counts as absent, and a failed rebuild removes only what the attempt itself created.
@moetemp
moetemp force-pushed the moe/worktree-freshness branch from 827a2fc to a497d3b Compare September 15, 2026 01:01
@moetemp
moetemp force-pushed the 2026/08/opencode-temporal branch from 1e2f3e7 to d04430c Compare September 15, 2026 01:01
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant