Skip to content

fix(workflow): serialize session archive publication - #1382

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
XY-code1:fix/workflow-session-publication-lock
Oct 25, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
XY-code1:fix/workflow-session-publication-lock

Conversation

@XY-code1

@XY-code1 XY-code1 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary workflow publish --sessions now holds the same per-team-repository publication lock as session push and session migrate --push across the complete archive save, Git commit, and push sequence. When another publisher keeps that lock for the full wait, the workflow publish is refused with the existing archive-busy message before it writes, commits, or pushes anything. ## Type of Change - [x] Bug fix - [ ] Breaking compatibility change ## Test Plan - [x] npx tsc --noEmit - [x] npm run lint - [x] npm run build - [x] Added built-CLI E2E coverage to the existing workflow session handoff scenario: - hold the real publication lock; - run teamai workflow publish <run> --sessions; - verify exit 1, the shared busy message, a clean team clone, and no session files on origin; - release the lock and verify the same built command archives, commits, and pushes successfully. - [x] Linux/macOS CI executed the built-CLI E2E suite successfully (all three fork-safe shards passed). Local Windows execution remains blocked before the test body by the fixture's existing file:// URL rewrite behavior. ## Related Issues Closes #1378 ## Notes for Reviewers - The publication lock is added only for git-kind team archives. Self-mode publication continues to use the existing teamai-reports writer lock. - Session reads and the “already archived” check remain outside the publication lock. Only mutation and Git publication are serialized. - The regression extends the existing real-CLI workflow archive test rather than adding a second fixture.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing executed real-CLI verification record — PR description. This changes runtime behavior, but the Test Plan records only added E2E coverage: local execution is blocked and CI results are pending. The trusted ## Code Review Rules explicitly requires an end-to-end / real-CLI verification record for runtime changes. Record one successful representative built-CLI run before merge; no provider × agent matrix is required.

No other confident findings in the specified diff.

@XY-code1
XY-code1 marked this pull request as ready for review October 25, 2026 14:33
@github-actions

Copy link
Copy Markdown

No confident findings in the specified PR diff.

  • Resolved: The earlier [P1 blocking] missing real-CLI verification finding. The updated description records successful Linux/macOS built-CLI E2E execution, including lock contention and successful publication after release. This satisfies the required testing record; Windows coverage is not blocking.
  • The production change serializes archive saves, commits, and pushes under the shared publication lock.

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

@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.

@XY-code1 Approving at 3fe8418. The body's test record was CI-only, so we ran the built CLI locally, with an isolated HOME, an empty global git config and TEAMAI_NONINTERACTIVE=1:

  • npm run test:e2e -- src/__tests__/e2e/workflow-publish-resume.test.ts at this head: exit 0, 5/5 pass. It also passes with TMPDIR behind a symlink.
  • The same command on the merge-base (13c891e) with only this head's test file: exit 1. While the lock is held, workflow publish --sessions exits 0 and publishes the session (AssertionError: exit 0 ... expected +0 to be 1 at workflow-publish-resume.test.ts:366). Current main (775c032) fails the same way, so nothing there already covers #1378.
  • tsc, lint, the session and workflow unit files (191 tests) and the workflow-conformance and workflow-delivery-drivers e2e files (93 tests) pass.

Non-blocking notes:

  • [P2 non-blocking] docs/dev/agent-sessions.md ("Session publication lock") still lists session push, session migrate --push and session pull as the commands that take withSessionPublicationLock. workflow publish --sessions takes it now too, so that list needs it added.
  • [P2 non-blocking] The e2e test rebuilds the lock path by copying the sha256-of-realpath key from sync.ts and holds it with acquireLock from update.ts. withSessionPublicationLock is exported, and session-push.test.ts already holds the lock through it. Doing the same here keeps the test independent of how the key is derived. If the key changed, the test would fail loudly rather than pass by mistake.
  • [P3 nit] Sessions are read before the lock is taken, whereas session push reads them under it. This only matters if two publishes of the same session race while that session is still changing.

Not run: Windows, the self-mode (teamai-reports) path, and a real two-process race. For that race we read the code; no run covers it.

The CI review's first comment raised a missing real-CLI record as [P1 blocking]. That was right for the body at the time. Its second comment marks it resolved and reports no findings. We agree that nothing blocks, and the local record above backs up the CI e2e runs. All CI jobs pass; the GitHub-provider e2e job is skipped by the fork policy.

@SaulMoro
SaulMoro merged commit 744d982 into Tencent:main Oct 25, 2026
20 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
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.

[bug] workflow publish --sessions commits and pushes without the session publication lock

3 participants