Repository navigation
fix(push): keep a teammate's update when pushing from a stale worktree (#812) - #819
Conversation
|
90b4330 to
ec864d9
Compare
|
Re: the [P1 blocking] review of Fixed in ec864d9. After the pre-push sync, and only when the team repo was refreshed, push stores the revision it synced the unedited copies to as
Covered by the e2e test "compares the next push with the revision the last push synced, and leaves pull's record alone" in |
The earlier finding is resolved for repeated pushes where the checkout record remains and every relevant file synchronizes successfully. The PR description includes sufficient real-CLI testing. |
ec864d9 to
c7b845b
Compare
|
Re: the two [P1 blocking] findings on ec864d9 (#819 (comment)) Both fixed in c7b845b.
|
The earlier forced-full-sync record-loss finding is resolved by retaining |
c7b845b to
789e597
Compare
|
Re: the [P1 blocking] finding on c7b845b (#819 (comment)) Fixed in 789e597. The scenario takes a chain of preconditions (sync, edit, a push at a new revision, undo to exactly the earlier synced copy, then a new teammate version before any pull). The fix closes the whole class anyway. The single Tests: the e2e "still syncs a copy undone to the version an earlier push synced it to" follows your steps and fails on c7b845b at |
The previously reported workspace-wide baseline and forced-full-sync findings are resolved. The PR description includes sufficient real-CLI testing. |
789e597 to
9eb8af6
Compare
|
Re: the two [P1 blocking] findings on 789e597 (#819 (comment)) Both fixed in 9eb8af6.
|
The previously reported baseline accumulation, forced-sync retention, unrecorded-checkout recording, and partial-sync recording findings are resolved. The PR description includes sufficient real-CLI testing. |
9eb8af6 to
dd2abe2
Compare
|
Re: the two [P1 blocking] findings on 9eb8af6 (#819 (comment))
|
The previously reported save-failure and project baseline-retention issues are resolved. The PR description includes sufficient real-CLI testing. |
|
Re: the three [P1 blocking] findings on dd2abe2 (#819 (comment)) No code change for these; all three are out of #812's scope and are now listed in the PR notes with file:line.
|
|
Follow-ups: the unrecorded-checkout fallback, which only exists in this branch, is being fixed in this PR (push will refuse until the checkout pulls). #823 tracks what already happens on |
dd2abe2 to
a796390
Compare
|
Update on the checkout-without-entry finding (#819 (comment), #819 (comment)). My earlier replies called it transitional and a follow-up. As of a796390 it is fixed in this PR. A project-scope checkout with no Test: the e2e "refuses to push a team rule from a checkout no pull has recorded, until it pulls" in |
The other previously reported project-worktree baseline retention and state-save failures are resolved. The PR description includes sufficient real-CLI testing. |
a796390 to
a9587f8
Compare
|
Re: the four [P1 blocking] findings on a796390 (#819 (comment))
|
|
Findings
The PR description includes sufficient real-CLI testing. The previously reported unsafe pull instruction is resolved: it now explicitly tells users to back up edited files first. |
|
Re: #819 (comment) These three repeat the previous pass and are answered in #819 (comment):
No code change for these. |
Tencent#812) Before scanning, push syncs each rule and skill the member never edited to the team repo's version, and "never edited" meant equal to the version at the project's shared lastPullRev. state.json is shared by every worktree, so a pull in another checkout moved that revision past the copy a stale worktree still held: the unedited copy read as an edit, and push offered it as modified, ready to send the teammate's change back as the old version. Push now compares with the revision this checkout last synced, from its lastPullByWorkspace entry (checkoutKey is exported from pull.ts), and falls back to the shared lastPullRev for a checkout with no entry. For that entry to survive, a pull at a new team revision no longer drops the other checkouts' records: a checkout recorded at an older revision already misses the fast path. When the pull finds lastPullRev cleared, it resets the other records to an empty rev (FORCED_FULL_SYNC_REV), which matches no revision, so a forced full sync reaches every checkout, single-repo mode included, while each record keeps its push bases. Each full sync keeps only the records of checkouts `git worktree list` still reports, and keeps them all when the list comes back empty, so a removed or re-created worktree's entry does not pile up. The sync itself moves the unedited copies to the team repo's revision, so push then adds that revision to the entry's pushBaseRevs (newest first, the 20 newest kept) and the next push compares with them; otherwise a copy synced to R2 read as an edit against R1 once a teammate published R3. Push leaves the entry's rev alone, since the pull fast path reads it and the checkout still lacks that revision's docs and agents; the next pull rewrites the entry without pushBaseRevs. The sync accepts a copy at any of pushBaseRevs or rev (a skill only when all its files are at one of them), so a copy it left alone as edited is synced again once the member undoes the edit, back to whichever version a sync gave it. The base is recorded even when the sync stops partway, which now warns, since the copies it did not reach still match an older base; a revision push cannot save stops the push before the scan. A checkout with no entry (a new worktree, or one last pulled by an older CLI) can only sync against the shared lastPullRev, which may be another checkout's or cleared: when the scan lists a team rule or skill as modified, push stops before creating a branch and asks for a pull there, warning that the pull replaces those files. A rule this machine placed does not count, and config-only pushes and new resources go through.
a9587f8 to
a52ed70
Compare
|
Re: #819 (comment)
|
|
Findings
The previously reported cleared-revision unrecorded-checkout issue is resolved: the refusal guard now applies independently of |
|
Re: #819 (comment) Both findings are the two already answered in #819 (comment): user scope ( |
…eamai copy (Tencent#823) Item 4, user scope: push compared HOME's rules and skills with the shared lastPullRev only, because the per-checkout push bases of Tencent#819 were keyed for project scope alone. After a push synced HOME's unedited copy to a teammate's R2, the next push compared it with R1 and offered it back over the teammate's R3. A user-scope pull now records HOME under checkoutKey(HOME) in the user state.json, and push reads and extends it like a project checkout's. The user-scope fast path still reads the shared fields, and an install with no record yet keeps comparing with lastPullRev without the unrecorded-checkout refusal: HOME is the scope's only checkout, so that revision is its own. Item 19, inherited user scope: a project pull with inheritUserScope rewrites HOME's skills, rules and agents under lastInheritedPullRev without moving the user scope's push bases, so the next user-scope push offered a teammate's newer update back the same way. That pull now adds its revision to HOME's pushBaseRevs, creating the record from lastPullRev if there is none, and leaves the record's rev, lastPullRev and the fast paths alone. Item 10, single-repo: the active tree's .teamai/rules and .teamai/skills are push sources, and on a branch behind the default branch they hold older team versions nobody edited, which push listed as modified. The isPastVersionOf guard that held only placed rules now covers every .teamai/rules copy, and .teamai/skills gets the same guard: a skill is skipped with a warning when every team file whose copy differs is an older version of it. A team file missing locally is a teammate's addition when the member's branch never added it, and the member's deletion otherwise; member-only files are ignored, as the equality check already ignores them. The checkout-base resolution that push and the agents scan each repeated (key, record, checkoutBaseRevs, lastPullRev fallback) is now one exported helper, resolveCheckoutBases, next to checkoutBaseRevs in pull.ts; pull uses the same key for its record.
…eamai copy (#823) (#835) * fix(push): stop reverting a teammate's update from HOME or a stale .teamai copy (#823) Item 4, user scope: push compared HOME's rules and skills with the shared lastPullRev only, because the per-checkout push bases of #819 were keyed for project scope alone. After a push synced HOME's unedited copy to a teammate's R2, the next push compared it with R1 and offered it back over the teammate's R3. A user-scope pull now records HOME under checkoutKey(HOME) in the user state.json, and push reads and extends it like a project checkout's. The user-scope fast path still reads the shared fields, and an install with no record yet keeps comparing with lastPullRev without the unrecorded-checkout refusal: HOME is the scope's only checkout, so that revision is its own. Item 19, inherited user scope: a project pull with inheritUserScope rewrites HOME's skills, rules and agents under lastInheritedPullRev without moving the user scope's push bases, so the next user-scope push offered a teammate's newer update back the same way. That pull now adds its revision to HOME's pushBaseRevs, creating the record from lastPullRev if there is none, and leaves the record's rev, lastPullRev and the fast paths alone. Item 10, single-repo: the active tree's .teamai/rules and .teamai/skills are push sources, and on a branch behind the default branch they hold older team versions nobody edited, which push listed as modified. The isPastVersionOf guard that held only placed rules now covers every .teamai/rules copy, and .teamai/skills gets the same guard: a skill is skipped with a warning when every team file whose copy differs is an older version of it. A team file missing locally is a teammate's addition when the member's branch never added it, and the member's deletion otherwise; member-only files are ignored, as the equality check already ignores them. The checkout-base resolution that push and the agents scan each repeated (key, record, checkoutBaseRevs, lastPullRev fallback) is now one exported helper, resolveCheckoutBases, next to checkoutBaseRevs in pull.ts; pull uses the same key for its record. * fix(push): address review — record HOME's push base in an upgraded install (#823) An upgraded user-scope install with no HOME record synced HOME from R1 to R2 on its first push but saved no base, because push recorded one only when the bases came from a record. A teammate's R3 then made the next push compare the R2 copy with lastPullRev R1 and offer it back. Push now creates HOME's record from lastPullRev (userScopeRecord, shared with the inherited pull) and adds the revision its sync reached. An unrecorded project checkout still records nothing, since its fallback base may be another checkout's. skill-data: contribute-member explains the stale .teamai copy warning and how to publish an edit of such a copy. * fix(push): address review — keep HOME's inherited base and a partial pull's delivered base (#823) * fix(push): keep the push bases of skills a pull held, and match a replaced root rule at every base (#823)
Tencent#812) (Tencent#819) Before scanning, push syncs each rule and skill the member never edited to the team repo's version, and "never edited" meant equal to the version at the project's shared lastPullRev. state.json is shared by every worktree, so a pull in another checkout moved that revision past the copy a stale worktree still held: the unedited copy read as an edit, and push offered it as modified, ready to send the teammate's change back as the old version. Push now compares with the revision this checkout last synced, from its lastPullByWorkspace entry (checkoutKey is exported from pull.ts), and falls back to the shared lastPullRev for a checkout with no entry. For that entry to survive, a pull at a new team revision no longer drops the other checkouts' records: a checkout recorded at an older revision already misses the fast path. When the pull finds lastPullRev cleared, it resets the other records to an empty rev (FORCED_FULL_SYNC_REV), which matches no revision, so a forced full sync reaches every checkout, single-repo mode included, while each record keeps its push bases. Each full sync keeps only the records of checkouts `git worktree list` still reports, and keeps them all when the list comes back empty, so a removed or re-created worktree's entry does not pile up. The sync itself moves the unedited copies to the team repo's revision, so push then adds that revision to the entry's pushBaseRevs (newest first, the 20 newest kept) and the next push compares with them; otherwise a copy synced to R2 read as an edit against R1 once a teammate published R3. Push leaves the entry's rev alone, since the pull fast path reads it and the checkout still lacks that revision's docs and agents; the next pull rewrites the entry without pushBaseRevs. The sync accepts a copy at any of pushBaseRevs or rev (a skill only when all its files are at one of them), so a copy it left alone as edited is synced again once the member undoes the edit, back to whichever version a sync gave it. The base is recorded even when the sync stops partway, which now warns, since the copies it did not reach still match an older base; a revision push cannot save stops the push before the scan. A checkout with no entry (a new worktree, or one last pulled by an older CLI) can only sync against the shared lastPullRev, which may be another checkout's or cleared: when the scan lists a team rule or skill as modified, push stops before creating a branch and asks for a pull there, warning that the pull replaces those files. A rule this machine placed does not count, and config-only pushes and new resources go through.
…eamai copy (Tencent#823) (Tencent#835) * fix(push): stop reverting a teammate's update from HOME or a stale .teamai copy (Tencent#823) Item 4, user scope: push compared HOME's rules and skills with the shared lastPullRev only, because the per-checkout push bases of Tencent#819 were keyed for project scope alone. After a push synced HOME's unedited copy to a teammate's R2, the next push compared it with R1 and offered it back over the teammate's R3. A user-scope pull now records HOME under checkoutKey(HOME) in the user state.json, and push reads and extends it like a project checkout's. The user-scope fast path still reads the shared fields, and an install with no record yet keeps comparing with lastPullRev without the unrecorded-checkout refusal: HOME is the scope's only checkout, so that revision is its own. Item 19, inherited user scope: a project pull with inheritUserScope rewrites HOME's skills, rules and agents under lastInheritedPullRev without moving the user scope's push bases, so the next user-scope push offered a teammate's newer update back the same way. That pull now adds its revision to HOME's pushBaseRevs, creating the record from lastPullRev if there is none, and leaves the record's rev, lastPullRev and the fast paths alone. Item 10, single-repo: the active tree's .teamai/rules and .teamai/skills are push sources, and on a branch behind the default branch they hold older team versions nobody edited, which push listed as modified. The isPastVersionOf guard that held only placed rules now covers every .teamai/rules copy, and .teamai/skills gets the same guard: a skill is skipped with a warning when every team file whose copy differs is an older version of it. A team file missing locally is a teammate's addition when the member's branch never added it, and the member's deletion otherwise; member-only files are ignored, as the equality check already ignores them. The checkout-base resolution that push and the agents scan each repeated (key, record, checkoutBaseRevs, lastPullRev fallback) is now one exported helper, resolveCheckoutBases, next to checkoutBaseRevs in pull.ts; pull uses the same key for its record. * fix(push): address review — record HOME's push base in an upgraded install (Tencent#823) An upgraded user-scope install with no HOME record synced HOME from R1 to R2 on its first push but saved no base, because push recorded one only when the bases came from a record. A teammate's R3 then made the next push compare the R2 copy with lastPullRev R1 and offer it back. Push now creates HOME's record from lastPullRev (userScopeRecord, shared with the inherited pull) and adds the revision its sync reached. An unrecorded project checkout still records nothing, since its fallback base may be another checkout's. skill-data: contribute-member explains the stale .teamai copy warning and how to publish an edit of such a copy. * fix(push): address review — keep HOME's inherited base and a partial pull's delivered base (Tencent#823) * fix(push): keep the push bases of skills a pull held, and match a replaced root rule at every base (Tencent#823)
Summary
teamai pushin a stale worktree offered a teammate's newer rule back as its old copy: its pre-scan sync compared with the sharedlastPullRev, which another checkout had moved.teamai pullType of Change
Test Plan
npx tsc --noEmitpassesnpx vitest runpasses: 307 files, 4781 passed, 1 skippedsrc/__tests__/e2e/push-stale-worktree-812.test.ts,src/__tests__/pre-push-sync.test.ts(+3)Reproduced with the real CLI
Sandbox HOME, bare team repo, worktrees, teammate clone; pushes are
teamai --dry-run pushunless noted.origin/main(5e5b86d)lastPullRevis setReal CLI, git mode (excerpt)
From reading the code
lastPullByWorkspace;checkoutBaseRevskeeps''away from git.Related Issues
Closes #812
Notes for Reviewers
git worktree listper full sync.src/push.ts:1008).--dry-run. The sync already writes files there, so the push base is stored too.src/push.ts:1008); a skill copy failing midway leaves mixed revisions (src/utils/pre-push-sync.ts:237);recordedAgentMovedOnuses the sharedlastPullRev(src/resources/agents.ts:177); single-repogit showpaths resolve from the repo root (src/utils/pre-push-sync.ts:131).data-directory-layout.md,usage-guide{,.zh-CN}.md.