Repository navigation
fix(tags,roles): honor --dry-run and count namespaced skills in tags list (#836) - #837
Merged
Merged
Conversation
…and roles set (Tencent#836) The three commands saved the local config and reset lastPullRev even under the global --dry-run, which is documented as "Preview mode, no changes made". Their siblings (tags add/remove, roles init/add/remove/ update) already return early with a [dry-run] message. The roles set preview names the additional roles it would save, including none, because a real run replaces the existing list. oxlint reported the unused options parameter in tagsSubscribe and tagsUnsubscribe; rolesSet has the same bug but reads options.add.
This was referenced Sep 25, 2026
The "N skill(s) have no tags and are always synced" hint counted the top-level directories under skills/, so a namespace counted as one skill and its skills were not counted at all. It also subtracted the number of tags.yaml entries instead of checking which skills have tags. Count the untagged skills among those pull delivers, using pull's own resolver (resolveDesiredSkills with the member's role context). Pull delivers every skill in the member's namespaces, all of them without roles, whatever its tags; tags only add skills from elsewhere. So roles, exclusions and a name held by both the root and a namespace are counted the way pull counts them.
SaulMoro
force-pushed
the
fix/dry-run-tags-roles
branch
from
September 25, 2026 20:44
751ac93 to
3e8d4c8
Compare
|
Findings
Testing
|
…alformed manifest (Tencent#836)
|
Findings
Previous Finding
Testing
|
SaulMoro
added a commit
to SaulMoro/teamai-cli
that referenced
this pull request
Sep 26, 2026
…nd unsubscribe With the Tencent#837 dry-run fix reverted out of this PR, both functions no longer read options. The underscore prefix keeps the signature and call sites unchanged, so Tencent#837 can rebase onto it by renaming the parameter back.
…emory under --dry-run (Tencent#836)
|
Findings
Previous Findings
Testing
|
… partition adoption under --dry-run (Tencent#836) detectProjectConfig now takes the { dryRun } load option that roles set, tags subscribe and tags unsubscribe already pass. Under it, a fresh self-mode clone gets the config bootstrapSelfRepo would write, kept in memory (previewSelfBootstrap), and a pre-Tencent#546 partition is read where it is instead of being renamed. One test hashes HOME, the project (with .git) and state.json around each command on three fixtures.
|
Findings
Previous Findings
Testing
|
…dry-run bootstrap preview (Tencent#836)
|
Findings
Previous Findings
Testing
|
jeff-r2026
self-requested a review
September 26, 2026 11:24
jeff-r2026
approved these changes
Sep 26, 2026
5 tasks done
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 26, 2026
* fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (#836) The three commands saved the local config and reset lastPullRev even under the global --dry-run, which is documented as "Preview mode, no changes made". Their siblings (tags add/remove, roles init/add/remove/ update) already return early with a [dry-run] message. The roles set preview names the additional roles it would save, including none, because a real run replaces the existing list. oxlint reported the unused options parameter in tagsSubscribe and tagsUnsubscribe; rolesSet has the same bug but reads options.add. * chore(lint): add oxlint with its default rules Pinned to an exact version so a new default rule arrives in its own PR, not as a CI failure on an unrelated one. The no-unused-vars options keep oxlint's _ ignore patterns and add ignoreRestSiblings, which the rest-omit in dashboard.ts relies on to keep config and roots out of /api/workspaces. * style(lint): apply oxlint safe fixes Drop redundant escapes in regex character classes and template literals, empty-object fallbacks in object spreads (spreading undefined adds nothing), and anchored regexes that are plain startsWith/endsWith checks. No behavior change. * refactor(lint): remove unused imports and an unused catch binding Applied with oxlint --fix-suggestions and reviewed by hand. Every removed whole import is a library module with no import-time side effects. * refactor(lint): remove dead code reported by no-unused-vars Each hit was checked against its callers and git history; none is missing wiring (the two that were, tags subscribe/unsubscribe, are fixed in the preceding commit). Removed: unused locals and functions, the options parameter of tagsList, rolesList and generateDigest (read-only commands), the never-read interactive option of importFromRepo, the empty test/e2e.mjs left over from the E2E migration, and a try/catch that only rethrew. new Array(n) becomes Array.from. No behavior change. * test(lint): fix lint hits in tests - contribute dry-run test asserted nothing; it now checks that the run leaves the repo/HOME tree unchanged (verified to fail when the dry-run early return is removed). - Drop a no-op expect(result).not.toThrow on a string. - Keep undefined in two optional-chain casts so a regression fails the assertion instead of throwing a TypeError. - Remove unused locals, helpers and imports; new Array(n) becomes Array.from. * refactor(lint): write control-character classes as \p{Cc} no-control-regex flags literal control ranges. \p{Cc} names the same set (C0, DEL, C1) and reads as what it means. Checked against the old classes on every code point from U+0000 to U+10FFFF: manifest-schema and agent-format match exactly, and contribute-check's normalization pipeline produces the same output. The test assertion is now stricter and checks every control character the sanitizer removes. * refactor(lint): remove disable directives for rules that are not enabled Four eslint-disable comments named rules this repo never ran (no-await-in-loop, @typescript-eslint/no-explicit-any), so they suppressed nothing. * ci(lint): fail CI on any oxlint warning (#828) npm run lint runs oxlint --deny-warnings and runs before the type check in both GitHub Actions and Coding CI. The repo is at zero warnings, so new code must stay clean. --report-unused-disable-directives also fails on a disable comment that suppresses nothing, so a suppression cannot outlive the code it was written for. CLAUDE.md, AGENTS.md, CONTRIBUTING.md and the PR template list the command so contributors and agents run it before opening a PR. Closes #828 * chore(lint): pin oxlint 1.16.0, the newest release that accepts Node 20.0 oxlint 1.17.0 and later declare engines.node ^20.19.0 || >=22.12.0, while the repo supports Node >=20. 1.16.0 declares >=8, supports --deny-warnings and --report-unused-disable-directives, and reports 0 warnings on this branch. * Revert "fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (#836)" This reverts commit 224d459. * refactor(lint): mark the unused options parameter of tags subscribe and unsubscribe With the #837 dry-run fix reverted out of this PR, both functions no longer read options. The underscore prefix keeps the signature and call sites unchanged, so #837 can rebase onto it by renaming the parameter back. * chore(lint): restore oxlint 1.85.0 This reverts commit e2347ef. oxlint is a devDependency, so its Node requirement (^20.19.0 || >=22.12.0) never reaches users installing teamai-cli, and CI's node-version 20 resolves to the latest 20.x. Staying on 1.85.0 keeps the #836 warning counts and the planned type-aware follow-up on the same version. * docs(contributing): note the Node version npm run lint needs * docs(agents): note the Node version npm run lint needs
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 27, 2026
…on save and recall use (#853) #837 threaded LoadOptions through the config loaders, and #850 fixes the three commands that still reach them bare (pull, push, status). Three more commands load their config before their own dry-run guard and pass nothing: - contribute (--scope project loads, then --scope user / auto-detect) - session save (same three branches) - recall (detection, the inherited user scope, and the user branch) On a config pending the legacy role migration each of them rewrote ~/.teamai/config.yaml under --dry-run, printing the migration line without any [dry-run] marker; the auto-detect and project branches can also adopt a pre-#546 partition and run the single-repo self-heal bootstrap. loadLocalConfigForScope is the loader #837 missed: it now takes LoadOptions and forwards them to detectProjectConfig and both migrateLegacyRoleConfig calls. Callers that pass nothing behave as before — a real run still migrates in place. Co-authored-by: ydflow <[email protected]>
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 28, 2026
…s and list use (#866) * fix(dry-run): thread { dryRun } through the loaders pull, push, status and list use `--dry-run` is documented as previewing without making changes, and #837 made that true for `tags subscribe`, `tags unsubscribe` and `roles set`. `pull`, `push` and `status` still wrote: each runs its scope-detection block before any dry-run guard, and that block called config loaders that were never given the flag. A preview could therefore persist the legacy role migration, and in a git repo adopt a pre-#546 partition or run the single-repo self-heal bootstrap. The loaders already take LoadOptions — #853 threaded them through `loadLocalConfigForScope` for contribute / session save / recall. These commands simply did not supply the flag. - pull.ts: both loaders take { dryRun: options.dryRun }. - push.ts: autoDetectInit takes it. - status.ts and list: { dryRun: true } unconditionally, because both are read-only and should never migrate, adopt a partition or bootstrap. Callers that pass nothing behave as before, the same compatibility promise #837 made. The one observable change is that the preview path logs, so `status`/`list` now surface a "[dry-run] Would ..." line where a migration or bootstrap is pending; the PR description asks for a decision on that label. Verification: seven new command-level cases, each failing on unmodified main with the identical test file (the project-scope three need a git project with a pre-#546 partition name, which the existing user-scope fixture never reaches); and the issue's own real-CLI reproduction, 6/6 — the control writes the reported fields, this change writes nothing. oxlint --deny-warnings and tsc --noEmit: rc=0 here and rc=0 on unmodified main. Closes #850 * fix(pull,push): a --dry-run must leave a fresh self-mode clone alone Resolves both P1 findings on this PR. pull.ts:1891 - the previewed self-mode config reached lockScope(), whose acquireLock() calls ensureDir() on the lock's parent. On a fresh clone the partition does not exist yet, so the directory was created and stayed: releaseLock removes the lock file, not its parent. The guard sits inside lockScope(), the one choke point all three call sites share. push.ts:731 - the same previewed config ran the whole self-mode setup before pushCore reached its own dry-run guard at push.ts:1577: the sync-lock, migrateSelfModeGitignore(), and the disposable knowledge worktree. Both guards are deliberately narrow. A blanket early return before the git-mode branch would also skip resetToCleanMaster/pullRepo (push.ts:934), which a dry run performs on purpose so it can name the destination the real command would use. Only writes that outlive the command are gated. The preview still reads the uncommitted teamai.yaml that pushCore receives as initialPendingTeamConfig; that block is now pendingSelfTeamConfig(), the identical read, so the preview keeps describing the config edit it exists to describe. Fixture gap, also flagged: dry-run-load-path.test.ts already had a fresh-self-mode-clone fixture, but only tags/roles ran against it. pull and push ran at user scope, or on a project partition that already exists - never on the one shape where acquireLock has something new to create. Two cases added there; the unfixed tree fails them at fs.existsSync(<HOME>/.teamai/projects) with "expected true to be false". Not fixed here, and named in the PR description: pull --dry-run on a fresh clone still creates an empty <HOME>/.teamai/locks/, via listPendingForInstall in utils/pending-learnings.ts. That call is unchanged by this PR and the file is outside its scope; the test declares and counts the entry, so anything else appearing still fails. * test(pull): pin the loader call shape the widened signature produces Fixes the red Lint & Test on the previous head (all four matrix entries). pull-scope-isolation.test.ts asserted the exact argument list of loadLocalConfigForScope, which this change widens to carry LoadOptions: expect(loadLocalConfigForScope).toHaveBeenCalledWith('user'); received ['user', undefined, { dryRun: undefined }] The shape is not a free choice: recall.ts:464 and recall.ts:515 already pass the same third argument, landed with #853, so pull.ts matches the merged precedent. recall-scope-isolation.test.ts never asserts the argument list, which is why the same change left it green. The affected set is derived from the changed symbols rather than from the topic: every test file that mentions loadLocalConfigForScope, detectProjectConfig or autoDetectInit (76 files, 1221 tests). * fix(update): a --dry-run asks the lock for its state instead of taking it `acquireLock` is not a read. It `ensureDir`s the lock's parent, which on a fresh self-mode clone is a `<getDataHome>` partition that does not exist yet — and `releaseLock` removes the lock FILE, not that directory, so the directory outlives the command. Any preview that calls it therefore writes, which is the defect this PR is about (#866). The new `options.dryRun` returns what the preview actually owes its caller: the ANSWER the real run would get. `lockState` already separates `live` (a holder is running) from `stale` and `missing`, and the real run reclaims either of the latter and wins, so `acquireLock(path, { dryRun: true })` is exactly that verdict — no mkdir, no lock file, no reclaim sentinel. Nothing is recorded in `heldLockOwners`, which is what makes the preview safe alongside the existing `releaseLock` calls: it returns at its first line when it holds no owner token for the path, so a preview cannot delete a lock another process owns. No caller passes `dryRun` yet; this commit is the primitive only. * fix(pull,push): acquire the preview's locks read-only, and stop hiding what it reports Supersedes the guards added in cfd7c57. Those guards stopped the writes, and E2E (fork-safe) caught what they cost — 6 failures in push-sync-followups-823.test.ts, all of the same shape: expected '- Scanning local resources...\nNo new or modified resources to push' to contain '[rules] teamai-rule (modified)' A preview that reports no changes for a tree with a deliberately edited team rule is not a conservative preview; it is this PR's own defect with the sign flipped. pull.ts — `lockScope()` returned `true` outright for a dry run, asserting the scope was uncontended. That is a fabricated fact: its callers read `true` as "you hold the lock". It now acquires through the read-only primitive and records the lock for release only when it really took one, so a scope with a live holder is reported as contended and skipped, exactly as a real pull does. push.ts — the self-mode branch returned early for a dry run. Two of the three things it skipped are right to skip and one is not. - the sync-lock: read-only now, at both push.ts:784 (self) and push.ts:839 (git mode). - `migrateSelfModeGitignore()`: still skipped. It rewrites a tracked file in the user's ACTIVE tree, which outlives the preview, and it is idempotent, so the next real push performs it. - the knowledge worktree: MUST run, and that is the correction. `pushCore` adds the active tree's `.teamai/{skills,rules}` as scan sources and diffs them against `localConfig.repo.localPath` (push.ts:1095-1112) — the clean worktree checkout. Outside the worktree those are the same path in self mode, so the diff is empty by construction: skipping the worktree does not report an edit early, it hides the edit. `withKnowledgeWorktree` already removes it in a `finally`, so it stays disposable. Fixture — `push --dry-run` now performs its `git fetch` for real, which leaves `app/.git/FETCH_HEAD` behind. Declared and counted next to the existing `<getDataHome>/locks/` entry, so any OTHER new entry still fails the case.
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…list (Tencent#836) (Tencent#837) * fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (Tencent#836) The three commands saved the local config and reset lastPullRev even under the global --dry-run, which is documented as "Preview mode, no changes made". Their siblings (tags add/remove, roles init/add/remove/ update) already return early with a [dry-run] message. The roles set preview names the additional roles it would save, including none, because a real run replaces the existing list. oxlint reported the unused options parameter in tagsSubscribe and tagsUnsubscribe; rolesSet has the same bug but reads options.add. * fix(tags): count namespaced skills in tags list (Tencent#836) The "N skill(s) have no tags and are always synced" hint counted the top-level directories under skills/, so a namespace counted as one skill and its skills were not counted at all. It also subtracted the number of tags.yaml entries instead of checking which skills have tags. Count the untagged skills among those pull delivers, using pull's own resolver (resolveDesiredSkills with the member's role context). Pull delivers every skill in the member's namespaces, all of them without roles, whatever its tags; tags only add skills from elsewhere. So roles, exclusions and a name held by both the root and a namespace are counted the way pull counts them. * fix(tags): address review — warn instead of aborting tags list on a malformed manifest (Tencent#836) * fix(tags,roles): address review — keep the legacy role migration in memory under --dry-run (Tencent#836) * fix(tags,roles): address review — preview the self-mode bootstrap and partition adoption under --dry-run (Tencent#836) detectProjectConfig now takes the { dryRun } load option that roles set, tags subscribe and tags unsubscribe already pass. Under it, a fresh self-mode clone gets the config bootstrapSelfRepo would write, kept in memory (previewSelfBootstrap), and a pre-Tencent#546 partition is read where it is instead of being renamed. One test hashes HOME, the project (with .git) and state.json around each command on three fixtures. * fix(bootstrap): address review — make no provider auth call in the --dry-run bootstrap preview (Tencent#836)
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…t#839) * fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (Tencent#836) The three commands saved the local config and reset lastPullRev even under the global --dry-run, which is documented as "Preview mode, no changes made". Their siblings (tags add/remove, roles init/add/remove/ update) already return early with a [dry-run] message. The roles set preview names the additional roles it would save, including none, because a real run replaces the existing list. oxlint reported the unused options parameter in tagsSubscribe and tagsUnsubscribe; rolesSet has the same bug but reads options.add. * chore(lint): add oxlint with its default rules Pinned to an exact version so a new default rule arrives in its own PR, not as a CI failure on an unrelated one. The no-unused-vars options keep oxlint's _ ignore patterns and add ignoreRestSiblings, which the rest-omit in dashboard.ts relies on to keep config and roots out of /api/workspaces. * style(lint): apply oxlint safe fixes Drop redundant escapes in regex character classes and template literals, empty-object fallbacks in object spreads (spreading undefined adds nothing), and anchored regexes that are plain startsWith/endsWith checks. No behavior change. * refactor(lint): remove unused imports and an unused catch binding Applied with oxlint --fix-suggestions and reviewed by hand. Every removed whole import is a library module with no import-time side effects. * refactor(lint): remove dead code reported by no-unused-vars Each hit was checked against its callers and git history; none is missing wiring (the two that were, tags subscribe/unsubscribe, are fixed in the preceding commit). Removed: unused locals and functions, the options parameter of tagsList, rolesList and generateDigest (read-only commands), the never-read interactive option of importFromRepo, the empty test/e2e.mjs left over from the E2E migration, and a try/catch that only rethrew. new Array(n) becomes Array.from. No behavior change. * test(lint): fix lint hits in tests - contribute dry-run test asserted nothing; it now checks that the run leaves the repo/HOME tree unchanged (verified to fail when the dry-run early return is removed). - Drop a no-op expect(result).not.toThrow on a string. - Keep undefined in two optional-chain casts so a regression fails the assertion instead of throwing a TypeError. - Remove unused locals, helpers and imports; new Array(n) becomes Array.from. * refactor(lint): write control-character classes as \p{Cc} no-control-regex flags literal control ranges. \p{Cc} names the same set (C0, DEL, C1) and reads as what it means. Checked against the old classes on every code point from U+0000 to U+10FFFF: manifest-schema and agent-format match exactly, and contribute-check's normalization pipeline produces the same output. The test assertion is now stricter and checks every control character the sanitizer removes. * refactor(lint): remove disable directives for rules that are not enabled Four eslint-disable comments named rules this repo never ran (no-await-in-loop, @typescript-eslint/no-explicit-any), so they suppressed nothing. * ci(lint): fail CI on any oxlint warning (Tencent#828) npm run lint runs oxlint --deny-warnings and runs before the type check in both GitHub Actions and Coding CI. The repo is at zero warnings, so new code must stay clean. --report-unused-disable-directives also fails on a disable comment that suppresses nothing, so a suppression cannot outlive the code it was written for. CLAUDE.md, AGENTS.md, CONTRIBUTING.md and the PR template list the command so contributors and agents run it before opening a PR. Closes Tencent#828 * chore(lint): pin oxlint 1.16.0, the newest release that accepts Node 20.0 oxlint 1.17.0 and later declare engines.node ^20.19.0 || >=22.12.0, while the repo supports Node >=20. 1.16.0 declares >=8, supports --deny-warnings and --report-unused-disable-directives, and reports 0 warnings on this branch. * Revert "fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (Tencent#836)" This reverts commit 224d459. * refactor(lint): mark the unused options parameter of tags subscribe and unsubscribe With the Tencent#837 dry-run fix reverted out of this PR, both functions no longer read options. The underscore prefix keeps the signature and call sites unchanged, so Tencent#837 can rebase onto it by renaming the parameter back. * chore(lint): restore oxlint 1.85.0 This reverts commit e2347ef. oxlint is a devDependency, so its Node requirement (^20.19.0 || >=22.12.0) never reaches users installing teamai-cli, and CI's node-version 20 resolves to the latest 20.x. Staying on 1.85.0 keeps the Tencent#836 warning counts and the planned type-aware follow-up on the same version. * docs(contributing): note the Node version npm run lint needs * docs(agents): note the Node version npm run lint needs
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…on save and recall use (Tencent#853) Tencent#837 threaded LoadOptions through the config loaders, and Tencent#850 fixes the three commands that still reach them bare (pull, push, status). Three more commands load their config before their own dry-run guard and pass nothing: - contribute (--scope project loads, then --scope user / auto-detect) - session save (same three branches) - recall (detection, the inherited user scope, and the user branch) On a config pending the legacy role migration each of them rewrote ~/.teamai/config.yaml under --dry-run, printing the migration line without any [dry-run] marker; the auto-detect and project branches can also adopt a pre-Tencent#546 partition and run the single-repo self-heal bootstrap. loadLocalConfigForScope is the loader Tencent#837 missed: it now takes LoadOptions and forwards them to detectProjectConfig and both migrateLegacyRoleConfig calls. Callers that pass nothing behave as before — a real run still migrates in place. Co-authored-by: ydflow <[email protected]>
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…s and list use (Tencent#866) * fix(dry-run): thread { dryRun } through the loaders pull, push, status and list use `--dry-run` is documented as previewing without making changes, and Tencent#837 made that true for `tags subscribe`, `tags unsubscribe` and `roles set`. `pull`, `push` and `status` still wrote: each runs its scope-detection block before any dry-run guard, and that block called config loaders that were never given the flag. A preview could therefore persist the legacy role migration, and in a git repo adopt a pre-Tencent#546 partition or run the single-repo self-heal bootstrap. The loaders already take LoadOptions — Tencent#853 threaded them through `loadLocalConfigForScope` for contribute / session save / recall. These commands simply did not supply the flag. - pull.ts: both loaders take { dryRun: options.dryRun }. - push.ts: autoDetectInit takes it. - status.ts and list: { dryRun: true } unconditionally, because both are read-only and should never migrate, adopt a partition or bootstrap. Callers that pass nothing behave as before, the same compatibility promise Tencent#837 made. The one observable change is that the preview path logs, so `status`/`list` now surface a "[dry-run] Would ..." line where a migration or bootstrap is pending; the PR description asks for a decision on that label. Verification: seven new command-level cases, each failing on unmodified main with the identical test file (the project-scope three need a git project with a pre-Tencent#546 partition name, which the existing user-scope fixture never reaches); and the issue's own real-CLI reproduction, 6/6 — the control writes the reported fields, this change writes nothing. oxlint --deny-warnings and tsc --noEmit: rc=0 here and rc=0 on unmodified main. Closes Tencent#850 * fix(pull,push): a --dry-run must leave a fresh self-mode clone alone Resolves both P1 findings on this PR. pull.ts:1891 - the previewed self-mode config reached lockScope(), whose acquireLock() calls ensureDir() on the lock's parent. On a fresh clone the partition does not exist yet, so the directory was created and stayed: releaseLock removes the lock file, not its parent. The guard sits inside lockScope(), the one choke point all three call sites share. push.ts:731 - the same previewed config ran the whole self-mode setup before pushCore reached its own dry-run guard at push.ts:1577: the sync-lock, migrateSelfModeGitignore(), and the disposable knowledge worktree. Both guards are deliberately narrow. A blanket early return before the git-mode branch would also skip resetToCleanMaster/pullRepo (push.ts:934), which a dry run performs on purpose so it can name the destination the real command would use. Only writes that outlive the command are gated. The preview still reads the uncommitted teamai.yaml that pushCore receives as initialPendingTeamConfig; that block is now pendingSelfTeamConfig(), the identical read, so the preview keeps describing the config edit it exists to describe. Fixture gap, also flagged: dry-run-load-path.test.ts already had a fresh-self-mode-clone fixture, but only tags/roles ran against it. pull and push ran at user scope, or on a project partition that already exists - never on the one shape where acquireLock has something new to create. Two cases added there; the unfixed tree fails them at fs.existsSync(<HOME>/.teamai/projects) with "expected true to be false". Not fixed here, and named in the PR description: pull --dry-run on a fresh clone still creates an empty <HOME>/.teamai/locks/, via listPendingForInstall in utils/pending-learnings.ts. That call is unchanged by this PR and the file is outside its scope; the test declares and counts the entry, so anything else appearing still fails. * test(pull): pin the loader call shape the widened signature produces Fixes the red Lint & Test on the previous head (all four matrix entries). pull-scope-isolation.test.ts asserted the exact argument list of loadLocalConfigForScope, which this change widens to carry LoadOptions: expect(loadLocalConfigForScope).toHaveBeenCalledWith('user'); received ['user', undefined, { dryRun: undefined }] The shape is not a free choice: recall.ts:464 and recall.ts:515 already pass the same third argument, landed with Tencent#853, so pull.ts matches the merged precedent. recall-scope-isolation.test.ts never asserts the argument list, which is why the same change left it green. The affected set is derived from the changed symbols rather than from the topic: every test file that mentions loadLocalConfigForScope, detectProjectConfig or autoDetectInit (76 files, 1221 tests). * fix(update): a --dry-run asks the lock for its state instead of taking it `acquireLock` is not a read. It `ensureDir`s the lock's parent, which on a fresh self-mode clone is a `<getDataHome>` partition that does not exist yet — and `releaseLock` removes the lock FILE, not that directory, so the directory outlives the command. Any preview that calls it therefore writes, which is the defect this PR is about (Tencent#866). The new `options.dryRun` returns what the preview actually owes its caller: the ANSWER the real run would get. `lockState` already separates `live` (a holder is running) from `stale` and `missing`, and the real run reclaims either of the latter and wins, so `acquireLock(path, { dryRun: true })` is exactly that verdict — no mkdir, no lock file, no reclaim sentinel. Nothing is recorded in `heldLockOwners`, which is what makes the preview safe alongside the existing `releaseLock` calls: it returns at its first line when it holds no owner token for the path, so a preview cannot delete a lock another process owns. No caller passes `dryRun` yet; this commit is the primitive only. * fix(pull,push): acquire the preview's locks read-only, and stop hiding what it reports Supersedes the guards added in cfd7c57. Those guards stopped the writes, and E2E (fork-safe) caught what they cost — 6 failures in push-sync-followups-823.test.ts, all of the same shape: expected '- Scanning local resources...\nNo new or modified resources to push' to contain '[rules] teamai-rule (modified)' A preview that reports no changes for a tree with a deliberately edited team rule is not a conservative preview; it is this PR's own defect with the sign flipped. pull.ts — `lockScope()` returned `true` outright for a dry run, asserting the scope was uncontended. That is a fabricated fact: its callers read `true` as "you hold the lock". It now acquires through the read-only primitive and records the lock for release only when it really took one, so a scope with a live holder is reported as contended and skipped, exactly as a real pull does. push.ts — the self-mode branch returned early for a dry run. Two of the three things it skipped are right to skip and one is not. - the sync-lock: read-only now, at both push.ts:784 (self) and push.ts:839 (git mode). - `migrateSelfModeGitignore()`: still skipped. It rewrites a tracked file in the user's ACTIVE tree, which outlives the preview, and it is idempotent, so the next real push performs it. - the knowledge worktree: MUST run, and that is the correction. `pushCore` adds the active tree's `.teamai/{skills,rules}` as scan sources and diffs them against `localConfig.repo.localPath` (push.ts:1095-1112) — the clean worktree checkout. Outside the worktree those are the same path in self mode, so the diff is empty by construction: skipping the worktree does not report an edit early, it hides the edit. `withKnowledgeWorktree` already removes it in a `finally`, so it stays disposable. Fixture — `push --dry-run` now performs its `git fetch` for real, which leaves `app/.git/FETCH_HEAD` behind. Declared and counted next to the existing `<getDataHome>/locks/` entry, so any OTHER new entry still fails the case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two
tags/rolesbugs from #836, one commit each.1.
--dry-runwrote anyway.teamai tags subscribe,tags unsubscribeandroles setsaved the local config and resetlastPullReveven under the global--dry-run("Preview mode, no changes made"). Now they return early after validation, the same waytags add/removeandroles init/add/remove/updatealready did.Loading the config could still write before that guard. For a user config with no
primaryRolenext to aroles.yamlthat declareshai,loadLocalConfig()migrates the config tohaiand saves it.loadLocalConfig,requireInitandautoDetectInitnow take an optional{ dryRun }, and these three commands pass theirs, so under--dry-runthe migration stays in memory and logs[dry-run] Would migrate …. Callers that pass nothing behave as before.migrateLegacyRoleConfig(config, path, options = {}) migrated = { ...config, primaryRole: 'hai', … } + if options.dryRun + log "[dry-run] Would migrate …" + return migrated write config.yamlProject detection could write as well. On a fresh clone of a single-repo (
mode: self) project with no machine config,detectProjectConfig()runsbootstrapSelfRepo(). That call writes the partition config, state and anchor, seeds tool dirs, injects hooks and registers the member on the reports branch. Detection also renames a partition that still has its pre-#546 name.detectProjectConfigandresolvePartitionDirnow take the same{ dryRun }. Under it, detection previews the bootstrap:previewSelfBootstrapbuilds the config the bootstrap would write, keeps it in memory, and prints[dry-run] Would bootstrap …. The preview makes no provider auth call: with a stale token,authenticate()can fall through togh auth login --web, which prompts and stores credentials. So the preview names the provider but not the username. A partition with its old name is read where it is.detectProjectConfig(cwd, onUnreadable, options = {}) - partitionDir = resolvePartitionDir(anchor) + partitionDir = resolvePartitionDir(anchor, options) // dryRun: no rename, no config rewrite read the partition config - bootstrapSelfRepo(root), then read the partition + if options.dryRun: previewSelfBootstrap(root) // in-memory config, "[dry-run] Would bootstrap …" + else: bootstrapSelfRepo(root), then read the partitionbootstrapSelfRepois split into a plan (remote, provider, username, team config, agents, role) and the writes. The preview runs the plan without its two auth calls (isAuthenticated,authenticate).Audited writes on the path these three commands take before their guard:
--dry-run.teamai/into the partitioninit,pull,pushand the learning-queueing commands trigger itresolvePartitionDir(detection and bootstrap)repo.localPathin itsconfig.yaml<repo>/.teamai/.bootstrap.lockconfig.yaml,anchor,state.json.claude/skills, …), hook settings (.claude/settings.json, managed-hooks record)git worktree add),members/<user>.yaml, commit, pushloadLocalConfiglegacy role migration~/.teamai/config.yamlresolveAnchors,readConfigFrom,loadTeamConfig,loadRolesManifestisAuthenticated()in the bootstrap plangh auth status/gf auth whoami/cnbauthenticate()in the bootstrap plangh api user,GET /user; falls through togh auth login --web,gf auth login,cnb loginor GitCode's token prompt (writes~/.netrc)getProvider,detectProvider,parseRepoInputgetRemoteUrl,resolveAnchorsgit remote/rev-parse)~/.teamai/debug.logpull --dry-run,push --dry-runandstatusreach the same writes through loaders that do not pass{ dryRun }(loadLocalConfigForScope, andautoDetectInit/detectProjectConfigwithout options). They are outside #836 and are not changed here. Callers that pass nothing behave as before.The
roles setpreview always names the additional roles it would save, includingnone, because a real run replaces the existing list. oxlint found the first two:optionswas never read in either function.rolesSethas the same bug, but the linter misses it because the function readsoptions.add.2.
tags listcounted namespaces as skills. The "N skill(s) have no tags" hint counted the top-level directories underskills/, so a namespace counted as one skill and its skills were not counted at all. It also subtracted the number oftags.yamlentries instead of checking which skills have tags.Pull delivers every skill in the member's namespaces (all of them without roles) whatever its tags; tags only add skills from elsewhere. So "no tags and always synced" means the untagged skills among those pull delivers, and asking pull's own resolver counts roles, exclusions and a name held by both the root and a namespace the way pull does. No new walk of
skills/.The count is only a hint, so if the resolver throws (a malformed
manifest/roles.yamlormanifest/projects.yaml),tags listwarnsCould not count untagged skills: <cause>and drops the hint instead of failing after the table is printed. The old helper swallowed errors silently;teamai doctorhandles the same resolver failure the same way.Refs #836, the oxlint follow-up to #828.
Evidence
Before: the new tests fail on
origin/main(7c834ce4).dry-run-load-path.test.tshashes every file under a temp root (HOME, the project with.gitand.git/hooks, andstate.json) around each of the three commands. It uses three fixtures: a fresh self-mode clone, a config waiting for the legacy role migration, and a partition with its pre-feat(partition): encode the full project path into the data-home slug #546 name. The provider stub parses the remote and records and throws on every other method, and the test asserts it saw no call.updateReportsis a spy that must not be called. On5dcd6d2bthe self-mode fixture fails for all three commands withexpected [ 'isAuthenticated' ] to deeply equal []. On4661d2f9the self-mode and partition fixtures fail for all three commands (6 of 9). The diff lists the new files: partitionconfig.yaml,state.json,anchor, andapp/.claude/settings.json. The legacy-migration fixture was already fixed in the previous round (it failed on7e5e4414).After: unit tests
npx vitest run: 5061 passed, 1 skipped.npx tsc --noEmitis clean,npm run buildsucceeds. New tests also cover a role member (an untagged skill outside their namespaces is not counted), a name in both the root and a namespace (counted once), a malformedroles.yaml(table still prints, hint replaced by a warning, no throw), and--dry-runin project scope.Real CLI,
--dry-run(npm run build,node dist/index.js, isolatedHOMEwith a local team repo, user scope,state.jsonseeded withlastPullRev: abc1234). Neitherconfig.yamlnorstate.jsonchanges under--dry-run; both change without it:The last run replaced
additionalRoles: [pm]with[], which is what thenonepreview says. Project scope is covered by a unit test, not a real-CLI run; the dry-run guard runs before the scope branch.Real CLI,
--dry-runwith a config that needs the legacy role migration (noprimaryRoleinconfig.yaml,roles.yamldeclareshaiandpm, freshHOMEper run, cwd outside git). Before is7e5e4414built fromgit archive:The hashes differ between runs because each run writes its own temp path into
config.yaml.Real CLI,
--dry-runon a fresh self-mode clone with an invalidGITHUB_TOKENin a terminal. The project is agit initwith originhttps://github.com/SaulMoro/teamai-dry-run-demo.git(the repo does not exist) and a committed.teamai/teamai.yamlwithmode: selfand a two-role manifest.HOMEis isolated and has~/.claude.GITHUB_TOKEN=ghp_invalid…, andscript -q /dev/nullgives the CLI a TTY, soisInteractive()is true.treeis a sha256 over every file under HOME and the project,.gitincluded, excludingdebug.log. Aghshim first onPATHlogs every invocation. Before is5dcd6d2b, built fromgit archive:The
gh auth login --webbefore the fix reached no prompt only because gh refuses to log in whileGITHUB_TOKENis set; without that guard it prompts, for examplecnb loginwith a rejectedCNB_TOKEN(by reading the code; not run). Before the baseline, the fixture HOME rangh auth statusonce, because gh writes its own~/.local/state/gh/device-idthe first time it runs under a new HOME. The file-write contrast from the previous round (4661d2f9wroteapp/.claude/settings.json, the partition config/state/anchor andreports-wt/members/SaulMoro.yaml) is covered by the unit test above.Real CLI,
tags list:skills/solo(flat) plusskills/hai/{a,b,c}(namespace), and onlyais tagged.Merge Danger
Door: two-way
Blast Radius: small
Only runs with
--dry-runchange, and they no longer write anything or call the provider's auth. The config loaders,detectProjectConfigandresolvePartitionDirgain an optional{ dryRun }argument that only these three commands pass.bootstrapSelfRepokeeps its steps and results. Its one non-silent "Detected a teamai single-repo project" line now prints after the team config and roles manifest are read, not before.tags listchanges only its untagged-skills hint: the number, and a warning in place of a crash when the manifest is malformed. Everything else behaves as before, and the existing tests pass unchanged.Review notes: Under
--dry-run, an adoption that crashed between the rename and therepo.localPathrewrite is not finished, because finishing it is a write. The dry run reads the stalerepo.localPathas it is, soroles setcannot find the roles manifest there (by reading the code; not run). Nothing is written, and the next real command finishes the adoption.