Skip to content

fix(init): preserve member registration failure reasons - #1272

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
ydflow:fix/init-registration-failure-reason
Oct 22, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
ydflow:fix/init-registration-failure-reason

Conversation

@ydflow

@ydflow ydflow commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

init collapsed updateReports to a boolean and only reported failure when the roster callback changed a member. A reports checkout or initial commit failure before that callback was silent; a later failure guessed "no write access?" and discarded the returned reason.

Both git-backed and single-repo init now handle PublishResult before the changed-member checks: failed names the returned reason and how to retry, and busy identifies the reports-branch writer and asks the member to retry after it finishes. Local setup still completes. published and already-present do not produce a failure warning. Failed writes no longer print a registration-success line. The bilingual FAQ, contributor note and changelog describe the warning.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Test Plan

  • npm run typecheck
  • npm run lint
  • npm run build
  • git diff --check
  • npx vitest run src/__tests__/init.test.ts -t 'member registration result': 12 passed, covering both init modes, failure before/after the callback, busy, published and already-present. Before the runtime change, the six failure/busy regressions failed.
  • npx vitest run src/__tests__/init-projects.test.ts src/__tests__/members.test.ts src/__tests__/projects-members.test.ts: 43 passed.
  • Real CLI after build: npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/init-registration-result.test.ts --retry 0: 2 passed. Each fixture runs the built node dist/index.js init . --provider git --agent claude --force with a temporary HOME and real Git repo. One configures a missing GPG program so the reports branch's first commit fails before the member callback; the other holds .reports-lock with the test process's live PID. Both preserve the local self-mode config, finish init with exit 0, print the appropriate cause/busy warning and retry hint, and report no member-registration success. The busy case preserves the other writer's lock. Both cases failed against the pre-fix build because the registration warning was absent.
  • A complete green local unit suite. This Windows environment has baseline failures:
    • init.test.ts: 70 passed / 5 failed before the final two already-present cases were added; pristine d60e68f has the same 5 failures / 60 passed. The failures concern Windows path separators in existing clone fixtures. All final 12 new cases pass separately.
    • init-scope-default.test.ts: the same 3 path-normalization failures on this branch and pristine d60e68f (16 passed on each).
    • Broad attempt: npx vitest run --maxWorkers=4 --bail=10 --reporter=json --outputFile=../init-unit-results.json stopped early; its report recorded 110 passed, 7 failed, 12 pending. All seven observed failing test names also fail when running unchanged local-agent.test.ts on pristine d60e68f (the baseline file has 104 passed / 34 failed). This was not a completed full-suite run.

Local verification used Windows, Node 24.19.0 and Git 2.33.1. Other providers and AI-tool sessions are left to CI; no live model session was used.

Related Issues

Closes #1267.

Notes for Reviewers

Only the two registration-result consumers in src/init.ts change at runtime. The reports writer, lock, timeout and roster merge behavior are unchanged. #1268 changes reports Git timeouts and is a related, separate fix.

Door: two-way; reverting restores the old diagnostics, with no data/schema migration.

Blast radius: init's member-registration messages. Registration remains non-blocking and uses the existing retry operation.

Signed-off-by: ydflow <314143294+ydflow@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

No findings in the specified PR diff.

The PR description documents sufficient testing, including two post-build real-CLI runs covering registration failure and a busy reports lock. The stated baseline failures and deferred provider/agent coverage do not warrant a blocking finding.

Review was read-only; I did not run, build, or install anything from the PR.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

@ydflow Approving with notes. We built this head and main (d60e68f5) and ran single-repo teamai init . --provider git --agent claude --force in an isolated HOME.

Case main this head
Commit fails before the member callback (missing gpg.program) exit 0, no warning exit 0, the warning names cannot exec '.../missing-signer'
Push fails (unreachable origin) exit 0, guesses (no write access?) exit 0, shows git's error
.reports-lock held exit 0, no warning exit 0, says another write holds the reports branch

[P2 non-blocking] The hint "re-run the same teamai init command to retry" does not retry for a non-interactive member. Without --force, the second run hits the re-init guard and stops with Aborted. Existing config is unchanged., so registration never runs. An interactive member has to answer the overwrite prompt first. The e2e test passes --force, so it doesn't catch this. The same wording is in both init.ts paths, both FAQ pages and CONTRIBUTING. Naming --force in the hint, or pointing at a command that registers without re-initializing, would fix it.

[P3 nit] PublishResult.reason from a failed push is git's raw stderr with a trailing newline, so the warning prints . You are still set up locally… on a line of its own. .trim() on the reason fixes it.

#1268 changes the timeout inside the same two withTimeout(updateReports(...)) calls. This PR owns how the result is handled and what the messages say. The overlap is only textual.

The Node 20 / ubuntu job failed with a vitest worker crash (ERR_IPC_CHANNEL_CLOSED), not a failing test. A re-run should clear it.

@SaulMoro
SaulMoro merged commit b9511c9 into Tencent:main Oct 22, 2026
29 of 30 checks passed
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.

fix(init): member registration hides why the reports write failed

3 participants