Skip to content

fix(pull): don't skip sync when a submodule update changed the tree - #526

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
88lin:fix/pull-submodule-skip-sync
Sep 12, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
88lin:fix/pull-submodule-skip-sync

Conversation

@88lin

@88lin 88lin commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the second half of the review note on #501: don't skip when the update succeeded and the tree changed.

refreshTeamRepo already reports a failed submodule update so the caller holds lastPullRev back and retries (#501). The successful update was not covered. getInstalledResourceTargets only records which AI tools are installed, not which skills appeared, so filling an empty submodule leaves the parent SHA — the fast path's only cache key — untouched, and Already synced at <rev>, skipping suppresses the deploy.

That is the upgrade footgun described in #525: a member pulls with a CLI that predates submodules: true (the unknown yaml key is stripped), so the parent SHA is cached while the submodule directories are still empty. Upgrading the CLI and pulling fills the clone, reports "Already synced", and ~/.claude/skills (etc.) stay empty until teamai pull --force or an unrelated parent commit moves HEAD.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes
  • npx vitest run passes for the affected suites (pull-skip-sync, pull-submodule-skip-sync: 15 passed). Full-suite runs on this Windows dev box have pre-existing failures in the suites that shell out to a corporate git host; not related to this change.
  • Added/updated tests for the change

Red → green, unit (src/__tests__/pull-skip-sync.test.ts). New case: parent rev already cached, git submodule status moves from - (uninitialized) to (checked out). Reverting only src/pull.ts on unmodified main:

× does not skip sync when a successful submodule update changed the tree
  → expected "spy" to not be called with arguments: [ StringContaining "Already synced" ]
  +   "[user] Already synced at abc1234, skipping"

Companion case pins the steady state so the fix cannot silently become "always full sync": an update that changes nothing still takes the fast path.

Red → green, real CLI pull (src/__tests__/pull-submodule-skip-sync.test.ts, real bare remotes + a real submodule, no simple-git mock, following contribute-self-learnings.test.ts). The fixture clones the team repo without --recurse-submodules and seeds state with the current parent SHA, i.e. exactly the issue's member. Reverting only src/pull.ts:

× deploys submodule content on a pull whose parent rev is already cached
  → expected "spy" to not be called with arguments: [ StringContaining "Already synced" ]
  +   "[user] Already synced at db0a308, skipping"

With the fix, skills/common/distributed-skill/SKILL.md reaches ~/.claude/skills on that pull. The second case asserts the fast path is still taken when the submodule was already populated.

Related Issues

Fixes #525

Follow-up to #501.

Notes for Reviewers

Only a real change invalidates the fast path. The obvious fix — always bypass skip-sync when submodules: true — would make every pull in a submodule-using team pay a full re-deploy forever. Instead this captures git submodule status before and after the update and treats a changed string as "the tree the deploy step reads is not what was cached". The leading status char is - while uninitialized and /+ (checkout behind its pin) afterwards, so both the fill-from-empty and pin-advance cases are covered. A team whose submodules are already current keeps taking the fast path.

Degradation direction. An unreadable submodule status is treated as changed: a redundant full sync is cheap and self-correcting, whereas wrongly skipping re-pins the empty tool directories this fix exists to clear. Only the status read degrades — the update itself still fails into the existing outer catch, so the submodulesFailed rev hold-back from #501 is untouched.

Scope. No behavior change for the HTTP and single-repo backends (both return submodulesChanged: false), and none for repos without the submodules knob. submodulesChanged only gates this run's fast path; it is not persisted, matching submodulesFailed.

Verified on Windows; the submodule protocol guard (protocol.file.allow) needed by the local-path fixture lives in a temp global config the test writes outside its own temp root, so beforeEach cannot drop it.

`refreshTeamRepo` reports a failed submodule update so the caller holds
`lastPullRev` back and retries next pull (#501). It does not cover the
successful update: `getInstalledResourceTargets` only records which AI
tools are installed, not which skills appeared, so filling an empty
submodule leaves the parent SHA — the fast path's only cache key —
untouched and the unchanged-rev fast path skips the deploy.

That is the upgrade path in #525: a member pulls with a CLI that predates
`submodules: true` (the unknown yaml key is stripped), so the parent SHA
is cached with the submodule directories still empty. Upgrading the CLI
and pulling fills the clone, then reports "Already synced at <rev>,
skipping" and the tool directories stay empty until `pull --force` or an
unrelated parent commit.

Compare `git submodule status` before and after the update and carry the
result into the fast path as `submodulesChanged`. The leading status char
is `-` while uninitialized and ` `/`+` once checked out, so a changed
string means the on-disk tree the deploy step reads is not what was
cached. The fast path only skips when the update left the tree alone, so
a submodule-using team still takes it in steady state instead of paying a
full re-deploy on every pull.

An unreadable status degrades to "changed": a redundant full sync is
cheap and self-correcting, whereas wrongly skipping re-pins the empty
tool directories this fixes. It is only the status read that degrades —
an update failure still reaches the outer catch and holds the rev back.

Fixes #525
@88lin
88lin force-pushed the fix/pull-submodule-skip-sync branch from 5adda20 to 770e4cc Compare September 11, 2026 17:47
@jeff-r2026
jeff-r2026 merged commit ba24e80 into Tencent:main Sep 12, 2026
7 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…encent#526)

`refreshTeamRepo` reports a failed submodule update so the caller holds
`lastPullRev` back and retries next pull (Tencent#501). It does not cover the
successful update: `getInstalledResourceTargets` only records which AI
tools are installed, not which skills appeared, so filling an empty
submodule leaves the parent SHA — the fast path's only cache key —
untouched and the unchanged-rev fast path skips the deploy.

That is the upgrade path in Tencent#525: a member pulls with a CLI that predates
`submodules: true` (the unknown yaml key is stripped), so the parent SHA
is cached with the submodule directories still empty. Upgrading the CLI
and pulling fills the clone, then reports "Already synced at <rev>,
skipping" and the tool directories stay empty until `pull --force` or an
unrelated parent commit.

Compare `git submodule status` before and after the update and carry the
result into the fast path as `submodulesChanged`. The leading status char
is `-` while uninitialized and ` `/`+` once checked out, so a changed
string means the on-disk tree the deploy step reads is not what was
cached. The fast path only skips when the update left the tree alone, so
a submodule-using team still takes it in steady state instead of paying a
full re-deploy on every pull.

An unreadable status degrades to "changed": a redundant full sync is
cheap and self-correcting, whereas wrongly skipping re-pins the empty
tool directories this fixes. It is only the status read that degrades —
an update failure still reaches the outer catch and holds the rev back.

Fixes Tencent#525
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.

pull: submodule update can succeed while skip-sync still skips tool-dir deploy

2 participants