Repository navigation
feat(worktree): one side-branch checkout per self-mode repo (#1443) - #1465
Conversation
8b67e06 to
ed0b0d1
Compare
|
No confident findings in the specified PR diff. The PR description satisfies the testing requirement: it records a representative real-CLI verification after Review was read-only; I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@Walternater Thanks, the main fix works. We ran the built CLI at ed0b0d1 on a self-mode repo with a user-scope and a project-scope install:
- One move. From either starting place, the first pull moves the checkouts once, and later alternating pulls in both scopes remove nothing. All events from both scopes reach
teamai-reportsexactly once, the queued learning is published, anddoctorexits 0.mainstill removes and recreates both checkouts on every pull. - The move is safe. An unpushed commit is pushed, an uncommitted file is refused and kept, and a held old lock refuses until it is released. A half-finished move recovers, and a second run moves nothing.
- Mixed with 0.28.0, both orders. Every event is delivered once, and the checkout never moves back.
Three changes before this is approved:
-
[P1 blocking] The dashboard moves the checkout back.
src/dashboard/workspaces.ts:24reads the user config with its own parser, so it never getsbranchHome. OneGET /api/workflows?workspace=userrecreatesteamai-reportsat~/.teamai/reports-wt, and the next pull printsremoved the old checkoutagain. #1443 names the dashboard under "Every reader follows", and the body says it is covered. Loading the user workspace withloadLocalConfigForScope('user', undefined, { dryRun: true }), or applyingwithBranchHomeinconfigAt, would fix it. A dashboard step in the e2e would pin it. -
[P1 blocking] A different team in the same repo now shares the checkout. Take a user-scope self install of repo X and a project-scope install of another team repo Y inside X. Y keeps its clone at
<partition of X>/team-repo, so its checkouts are at<partition of X>/{reports,learnings}-wt, and X'sbranchHomenow points at the same two paths. Whichever creates a path first owns it, and the other is refused on every pull. In our run, X's 3 usage events stayed inuser-usage.jsonl, and Y could not publish learnings. Onmainboth deliver. #1443 lists this under "Keep apart". The warning also says "left by an install in another mode", and following itsgit worktree removeadvice only hands the path to the other install. Two ways out:- Give self-mode side branches their own subdirectory of the partition, which git-mode clones never use. We'd prefer this one, because it doesn't depend on which install came first.
- Attach
branchHomeonly when the partition holds no install, or akind: selfinstall of the same repository. That is smaller, but it breaks if Y installs later.
Either way, please add the case to the e2e.
-
[P1 blocking] A Breaking Changes line in CHANGELOG. This moves stored data on first use, so it needs a line under
[Unreleased]→💥 Breaking Changes, for example:A single-repo (
kind: self) team keeps oneteamai-reportsand oneteamai-learningscheckout per repository, in its project partition (~/.teamai/projects/<slug>/), for the user scope too. The first command after the upgrade removes the user-scope checkouts in~/.teamai/reports-wtand~/.teamai/learnings-wt. Their commits stay on the branch; a checkout with uncommitted changes is kept and named. teamai 0.28.0 run on the same machine afterwards cannot publish user-scope reports; they stay in~/.teamai/user-usage.jsonluntil an upgraded pull sends them (for #1443).
Non-blocking:
- [P3 nit] The body's record starts only from
~/.teamai; #1443 asked for both starts. Our run from the partition passes.
Once the first two are fixed, nothing else from #1443's acceptance criteria remains, so the body can say Fixes #1443.
CI review: we disagree with "no findings", because of the three items above.
Verified at ed0b0d1: tsc and lint pass. The full unit suite and 14 e2e files (98 tests) on the changed paths pass. The new tests fail on the baseline and pass here, also under a symlinked TMPDIR. Not run here: the outside-git fallback, and Windows (CI passes).
ed0b0d1 to
9f33728
Compare
|
No confident findings in the specified PR diff. The earlier pass raised no findings, so there are none to mark resolved. The PR description satisfies the testing requirement: it records representative real-CLI verification after Review was read-only; I did not run, build, or install anything from the PR. |
9f33728 to
2428ab4
Compare
|
No confident findings in the specified PR diff. Earlier passes raised no findings, so there are none to mark resolved. The PR description satisfies the testing requirement: it records representative real-CLI verification after Review was read-only; I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@Walternater Thanks, two of the three are fixed. With the built CLI at 2428ab4:
- Dashboard. After a dashboard request on the user workspace, both checkouts stay under
side-branches/, and the next pull removes nothing. - Keep apart. The subdirectory works in all three orders: Y first, X first, and X from the 0.28.0 layout with Y added later. Nothing is refused, every event is delivered, and
doctorpasses. - 0.28.0, both orders. Every event reaches
teamai-reports, and queued learnings from both scopes publish. - The move itself. An unpushed commit is pushed, an untracked file is kept, and a held lock is respected. A second run moves nothing.
- CI fixtures. 2428ab4 fixes the
self-mode-worktrees-808andinit-registration-resultfixtures that broke at 9f33728. All 33 tests in those files pass here.
One change is still open, and it's our mistake:
- [P1 blocking] The CHANGELOG line understates what 0.28.0 loses. The sentence we suggested says 0.28.0 "cannot publish user-scope reports". With the checkouts under
side-branches/, 0.28.0 run after an upgraded pull cannot publish reports or learnings from either scope. Nothing is lost, because the next upgraded pull sends all of it. Please replace the last sentence with:teamai 0.28.0 run on the same machine afterwards cannot publish reports or learnings from either scope; they stay queued locally (
~/.teamai/user-usage.jsonl, the partition'susage.jsonl, and the pending-learnings queues) until an upgraded pull sends them.
Non-blocking:
- [P3 nit] The comment at
src/__tests__/e2e/self-mode-worktrees-808.test.ts:823-825describes a git-mode leftover underside-branches/, which can no longer happen. "A checkout of another repository where self mode keeps its own" would fit. - [P3 nit] Two doc comments in
src/types.tsstill say the checkouts sit directly in the partition. - [P3 nit] The body's testing notes about
self-mode-worktrees-808are out of date.
CI review: we disagree with "no findings", because of the CHANGELOG sentence.
Verified at 2428ab4: tsc and lint pass. The unit files and the changed e2e files pass; the unit suite's only failures were timeouts under load, and those files pass when run alone. Not run here: Windows.
|
@SaulMoro all three P1s are addressed on
Also from the review:
Could you take another look at |
2428ab4 to
a78a027
Compare
|
No confident findings in the specified PR diff. Earlier passes raised no findings, so there are none to mark resolved. The PR description satisfies the testing requirement: it records representative real-CLI verification after Review was read-only; I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at a78a027. The CHANGELOG line now says what 0.28.0 loses: run after an upgraded pull, it cannot publish reports or learnings from either scope, and they stay queued until an upgraded pull sends them. The test comment and the src/types.ts doc comments are updated.
The rebase onto main resolves cleanly: withBranchHome wraps the new applyConfigOverlays and applyMachineSettings calls, and serializeLocalConfig drops branchHome next to the new overlay field. #1477 also changes src/config.ts and src/hook-handlers.ts after this branch's base, so we checked a merge with current main. tsc and lint pass there, and so do the config, types, self-mode, dashboard-workspaces, hook-handlers and doctor test files (34 files, 737 tests).
From the earlier rounds at 2428ab4, checked with the built CLI:
- both 0.28.0 layouts migrate;
- an unpushed commit is pushed, an untracked file is kept, and a held lock is respected;
- a second run moves nothing;
- the dashboard keeps both checkouts under
side-branches/; - the subdirectory case works in every order;
- every event reaches
teamai-reportswith 0.28.0 in both orders.
Thanks for seeing this through.
@jeff-r2026 Breaking for the next tag: a kind: self team's user-scope teamai-reports / teamai-learnings checkouts move into the repository's partition (side-branches/), and 0.28.0 run afterwards on the same machine queues reports and learnings instead of publishing them. See CHANGELOG.
…1443) A user-scope `kind: self` install and the repo's project partition computed different reports/learnings worktree paths, so whichever pulled second could take the branch but the other could never take it back. Tencent#1445 made eviction symmetric; each alternating pull still moved both checkouts and the two scopes used separate locks. Resolve one side-branch home per repository from its project anchor, attach it to the config at load time as a runtime-only `branchHome` (never saved), and let `getWorktreeDir` and the lock beside each checkout follow it. The first upgraded pull takes over a checkout left in `~/.teamai/` or a legacy `<checkout>/.teamai/` under the lock beside that checkout, so a command still using it is never deleted from under. Config, state, usage and queue files stay where each scope keeps them; hook ownership and every reader go through the same seam.
a78a027 to
944f550
Compare
|
No confident findings in the specified PR diff. Earlier passes raised no findings, so there are none to mark resolved. The PR description satisfies the testing requirement: it records representative real-CLI verification after Review was read-only; I did not run, build, or install anything from the PR. |
|
CI is green on |
…1465) Self-mode repos keep their side-branch checkout under ~/.teamai/projects/<slug>/side-branches/, one per repo, instead of a checkout per project. An existing checkout is moved on first use and nothing is deleted. Fixes Tencent#1443
Problem
A
kind: selfteam installed at user scope and the project partition of the same repository compute different side-branch worktree paths:~/.teamai/reports-wt~/.teamai/projects/<slug>/reports-wt#1445 made eviction symmetric so either pull could take the branch back, but the underlying split remains: every alternating pull moves both checkouts, and the two scopes use separate lock files, so they can evict a checkout the other scope is using. This is the follow-up the issue asks for (option 1).
Fix
One side-branch checkout per
kind: selfrepository, for both scopes and every checkout:LocalConfig.branchHomeis resolved when the config loads, from the repository's shared project anchor (resolveAnchors→resolvePartitionDir, so a pre-feat(partition): encode the full project path into the data-home slug #546 partition is adopted):<partition>/side-branches. It is runtime-only: never read from YAML and dropped byserializeLocalConfig, likedataHome.getWorktreeDirfollows it. For self mode both scopes return<branchHome>/reports-wt/<branchHome>/learnings-wt, and the lock path beside each checkout follows, so both scopes share one checkout and one lock per branch. No anchor (outside git) keeps today's~/.teamaifallback.loadLocalConfig,loadLocalConfigForScope,readConfigFrom(including the dry-run self-heal preview),initSelfRepoandbootstrapSelfRepo.dashboard/workspaces.tsread the user config with its own parser, so it never gotbranchHomeand its report writer recreated~/.teamai/reports-wt; it now callsloadLocalConfigForScope('user', …, { dryRun: true }).side-branches/subdirectory keeps installs apart. A git-mode team clone in the same partition (a nested team repo) keeps its own checkouts as siblings of the clone, directly under the partition (<partition>/reports-wt). Self mode's subdirectory means the two never claim the same path, whichever installed first.~/.teamai/, in a legacy<checkout>/.teamai/, or at the partition root (the pre-teamai-reports checkout conflict between user scope and project scope of the same single-repo (kind: self) team repo (variant not covered by #808) #1443 project layout), and now takes the lock beside that old checkout first, so a command still using it is never deleted from under.isOwnCheckout) recognises the shared checkouts; reports, learnings, dashboard, scorers and viz go throughgetWorktreeDir.~/.teamai/…for user scope, the partition for project scope). Only the two side-branch checkouts and their locks move.[Unreleased] → 💥 Breaking Changesline inCHANGELOG.mdcover the move. The changelog says 0.28.0 run after the upgrade cannot publish reports or learnings from either scope; they stay queued locally (the user-scopeuser-usage.jsonl, the partition'susage.jsonl, and the pending-learnings queues) until an upgraded pull sends them.Testing
npx tsc --noEmit,npm run lint(oxlint, changed files).src/__tests__/branch-home-1443.test.ts— 6 passed: both scopes, a linked worktree and the pre-feat(partition): encode the full project path into the data-home slug #546 partition resolve one checkout and lock;branchHomeis never saved; a git-mode sibling in the same partition is left alone; a held old lock blocks the takeover and releasing it lets the next call take over.dashboard-workspaces.test.tspins that the user workspace loadsbranchHome.src/__tests__/e2e/single-side-branch-1443.test.ts— 2 tests, real CLI:~/.teamai/; the firstpull --verbosemoves them intoside-branches/, usage from the user scope and then the project scope both reachteamai-reports, a queued learning is published, a git-mode sibling at<partition>/reports-wtsurvives, alternating pulls print noremoved the old checkoutagain, per-scope config/state/usage stay, andteamai doctorexits 0.side-branches/.Both fail on
main, pass here (control run).main(4d3d1f15), including fix(init): refuse --scope user in single-repo mode #1455 and fix(status): surface unconfirmed automatic reports #1462; the two conflicting loader/serializer hunks were merged with main's member-settings changes.branch-home-1443,dashboard-workspaces,branch-worktree-scope-eviction,branch-worktree-retire,single-repo-mode,status-list,hook-handlers,git-hook,init,migrate,reports-votes-owner,learnings-publish).self-mode-worktrees-808,single-side-branch-1443,init-registration-result): 32/33. The one failure (publishes from both checkouts …,worktreeDirpruning at line 313) also fails onorigin/mainin this environment, verified by switching to base; it passes in CI.origin/mainand not caused by this change:workflow-local-driversetup timeouts,workflow-skill-driverkilled-runner pid,workflow-workspacesubmodule ignore,env-execYAML message.Real CLI, after
npm run build, fresh HOME:A held old lock on the
~/.teamailayout:Fixes #1443.