Repository navigation
fix(workflow): serialize session archive publication - #1382
Conversation
No other confident findings in the specified diff. |
|
No confident findings in the specified PR diff.
Review was read-only; I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
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.tsat this head: exit 0, 5/5 pass. It also passes withTMPDIRbehind 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 --sessionsexits 0 and publishes the session (AssertionError: exit 0 ... expected +0 to be 1atworkflow-publish-resume.test.ts:366). Currentmain(775c032) fails the same way, so nothing there already covers #1378. tsc, lint, the session and workflow unit files (191 tests) and theworkflow-conformanceandworkflow-delivery-driverse2e files (93 tests) pass.
Non-blocking notes:
- [P2 non-blocking]
docs/dev/agent-sessions.md("Session publication lock") still listssession push,session migrate --pushandsession pullas the commands that takewithSessionPublicationLock.workflow publish --sessionstakes 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.tsand holds it withacquireLockfromupdate.ts.withSessionPublicationLockis exported, andsession-push.test.tsalready 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 pushreads 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.
Summary
workflow publish --sessionsnow holds the same per-team-repository publication lock assession pushandsession migrate --pushacross 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; - runteamai 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 existingfile://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 existingteamai-reportswriter 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.