Repository navigation
fix(push): preserve placed-agent history during format conversion - #1339
Conversation
The PR description documents sufficient testing, including a representative real built-CLI E2E run. I only read the scoped diff; I did not run, build, or install anything. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@nateEc Thanks. Both agent cases from #1326 are fixed, but the new guard also hides a legitimate edit.
We built this head, its merge-base 83f6d1db and main 54622c3a. On main, both #1326 agent cases still reproduce. On this head, merging your own conversion no longer stops with exit 2, and the deleted agent is not pushed back. tsc and lint pass, the unit files pass, and self-mode-push-behind.test.ts passes 10/10, with 2 cases red on base.
[P1 blocking]src/resources/agents.ts:254skips a root agent wheneverretiredPlacedAgentshas its name, without checking the team tree. Run with the built CLI: the team deletes the placedops/sample, then re-addsagents/sample.yamlat the root. The member edits that root copy and runsteamai push --all:It exits 0 and pushes nothing, so the edit is silently lost. The record is never cleared, so this lasts as long as⚠ [agents] sample was removed from the team; its root copy is not pushed as a new agent. ℹ No new or modified resources to pushstate.jsonkeeps it. Checking that the team has no current source for the name before treating the root copy as retired, and dropping the record once the team has one, would fix it. A case inself-mode-push-behind.test.tsfor the re-add would pin it.[P2 non-blocking]Records written before this build still produce the old stop, with a message that is true but doesn't explain why.[P2 non-blocking]The new code adds a!insrc/utils/pending-push.tsand anasinsrc/push.ts. A narrowing check would avoid both.[P3 nit]troubleshooting.mdconflicts with main at the end of the file, and thesharing.mdparagraph is long.
#1333 changes the same push function for the skill case without a textual conflict. We didn't run the two together.
CI review: it raised one [P1 blocking] at agents.ts:254, the same as ours. We agree and reproduced it above. We did not verify its point about tool copies via directStems. We agree the body's testing record is a real built-CLI run.
@nateEc the |
8bc3592 to
3044593
Compare
|
Addressed the review follow-up at
The PR description contains the updated verification record. Ready for another review. |
|
No new findings in the scoped diff.
I only read the scoped diff; I did not run, build, or install anything. |
3044593 to
4f1d8ff
Compare
|
Addressed the review follow-up at
The PR description contains the updated verification record. Ready for another review. |
|
No new findings in the scoped diff.
I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@nateEc Thanks, approving at 4f1d8ff. The blocking finding is fixed: re-adding an agent at the shared root now clears its retired record, and the re-add e2e fails on the commit before the fix. Both agent-format cases from #1326 are fixed. On the merge-base with this PR's tests, the false stop exits 2 and the deleted agent gets a pushed branch. Here self-mode-push-behind passes 11/11, also with a symlinked TMPDIR, and the focused unit files pass. Build, tsc and lint pass.
It conflicts with main again in skill-data/core/references/troubleshooting.md. Keeping both sections resolves it, and I'll merge it once it's rebased and green.
Each note below was reproduced with the built CLI on this head and on the merge-base:
- [P2 non-blocking] The retired record is cleared only when the team re-adds the agent at the shared root. If the team brings it back at
agents/ops/sample.md, for example by reverting the deletion, every later push,--role opsincluded, prints "sample was removed from the team" and pushes nothing, with exit 0. The base gets this flow wrong in another way (it publishes the edit as a new shared-root agent). A warning that names the retired path and the next step would at least make it visible. - [P2 non-blocking] The protection against a leftover tool copy holds only while the member's root copy exists.
teamai pulldelivers that root copy into.claude/agents/. If the member deletes the root copy, which the new warning suggests, the next push publishes the agent as a newagents/sample.yaml. This already happens onmain, but the body says the case is covered. The e2e writes the tool copy by hand and keeps the root copy, so it does not reach this path. - [P2 non-blocking] A member who is fully up to date still deletes a teammate's merged edit when converting
.mdto.yaml. The new docs sentence "a later team edit still stops the push" holds only while the member is behind that edit. This also happens onmain. The blob this PR now records would be enough to catch it. - [P3 nit] The stop message for pre-build records is unexplained (
src/push.ts:1177). There is a non-null assertion atsrc/utils/pending-push.ts:497and anascast atsrc/push.ts:1109. The new docs omit the re-add case.
The CI review reports no new findings and calls the earlier one resolved. We agree that nothing blocks, but it missed the namespaced re-add above and accepted the tool-copy claim. All CI jobs pass.
- Record each landed agent placement with its proven path and Git blob, and prune that metadata with the placement lifecycle. - Allow format conversion behind the placement merge only when the retiring file still matches that delivered blob; keep teammate-edit and legacy-record guards. - Remember upstream-deleted agents even before the first observed merge, and suppress publication from both canonical conversions and residual tool copies. - Verify 87 placement/agent tests, ten built-CLI push scenarios, type checking and lint; document the behavior in both guide languages and troubleshooting.
- 团队树中重新出现同名共享根 agent 时清除旧命名空间的退役记录,允许成员提交该新来源的编辑。 - 保留团队删除时的防复活保护与并发修改拒绝,避免把真正的重新加入误判为残留副本。 - 新单测在修复前失败;27 个记录用例和 11 个真实 CLI 用例通过,包含删除、格式转换及重新加入后的编辑。
- 即使 checkout 已同步,也比较交付时的源 blob,阻止转换删除队友修改。 - 退役的工具副本不再成为新 agent;命名空间重建时明确提示原始路径和编辑步骤。 - 移除不必要的类型断言,补充中英文恢复指引及旧记录拒绝原因。 - 119 项定向单测和 19 项真实 CLI 场景通过,类型、lint 与构建通过。
4f1d8ff to
22cd674
Compare
I reviewed the trusted base criteria and exact requested diff ending at |
|
Updated and rebased onto main Verification: 119 focused unit tests passed; types, lint and build passed. Post-build real-CLI Updated head: |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@nateEc Re-checked at 22cd674. The earlier items are fixed, each with an e2e or unit case: re-adding a root agent, the namespaced re-add, the leftover tool copy, and the stale message and cast. But the new guard blocks the recovery it tells the user to do, so our earlier approval (on 4f1d8ff) cannot carry over.
-
[P1 blocking] A conversion after a teammate's edit is refused even when the member has carried the edit in (
src/push.ts:1131-1132). Reproduced with the built CLI:- The member's agent is placed, recording blob A.
- A teammate changes the original on
origin/mainto B. - The member pulls, carries B's line into
sample.yaml, and runspush --all --role ops.
This head exits 2 with
... would delete .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it. Nothing was pushed. Run 'git pull origin main', carry that change into .teamai/agents/sample.yaml, then push again.It does the same on every retry, so there is no way out.mainpushes the same conversion.retiredTip !== deliveredBlobstays true because reconciliation keeps A, and the guard never looks at whether the converted file now holds the current source. Please let a conversion through when it already carries the current tip, or update the recorded blob once the member has pulled, and add an e2e case for the carried conversion. The troubleshooting text promises exactly this recovery. -
[P2 non-blocking] Older records with no delivered blob still delete a teammate's merged edit on a synced checkout. That also happens on
main, but the new docs say older records "stay conservative". Please either backfill the blob or reword the docs.
Build, tsc, lint, the PR's unit files (119 tests) and its e2e file (19 tests) pass, and a batch of 30 push and agent e2e files passes except one that fails on main too.
The CI review's [P1 blocking] at this head is the same finding, and we agree with it. The other CI jobs pass. The open-source scan check fails at this head, where it passed at 4f1d8ff; its report is on an internal host, so we could not read the cause.
# Conflicts: # skill-data/core/references/troubleshooting.md
…am edit The member's root copy is never refreshed from the team file, so a push cannot tell whether a conversion carries a teammate's edit. Each stop now records the version it named; the next push takes the conversion as carrying it, and a later team edit stops it again. A dry run records nothing. Reword the docs for older placement records, which catch a team edit only while the checkout is behind it.
|
No new findings in the scoped diff ending at
I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR. |
# Conflicts: # skill-data/core/references/troubleshooting.md
A stop no longer records the team version it named, so an unchanged retry stops again instead of deleting the teammate's edit. The stop prints `teamai push --carried <path>@<blob>`; with it, the push deletes the original only while the default branch still holds that blob, and a later team edit stops it again. Nothing is written to state, so a dry run or another checkout of the same project gains nothing from it. A value that names no stopped conversion is rejected.
# Conflicts: # skill-data/core/references/troubleshooting.md
|
No new findings in the scoped diff ending at
I read only the trusted base criteria and scoped diff. I did not run, build, or install anything from the PR. |
…tires a file --carried waives only the deletion of the file it names. The retirement check no longer skips the source and destination checks for the same item, so a teammate's file at the conversion's destination still stops the push.
|
No new findings in the scoped diff ending at
I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR. |
|
No new findings in the scoped diff ending at
I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR. |
…ts first merged edit A placement record written before placedAgentSources existed has no delivered blob, so its edits were never marked and the overwrite stop never applied to it. An edit reached through such a record is now marked as a placement, and reconcile records its blob once it lands. Nothing new stops on that push and nothing is written before the merge.
|
No new findings in the scoped diff ending at
I read only the trusted base review criteria and scoped diff. I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
Approved at a2c7323. The conversion and overwrite stops, the stateless --carried acknowledgment and the delivered-blob record (including records from older releases) check out on the built CLI. CI and the review bot are clean.
…ncent#1339) Closes Tencent#1326 Co-authored-by: Saul Moro <[email protected]>
In self mode, converting a placed agent from Markdown to YAML could be rejected after the author's own merge; a deleted placed agent could also be accidentally published again. Record the proven delivered source blob from Git history and use that evidence to distinguish a completed placement, a real upstream edit and retired copies. Shared-root re-additions clear retired records; namespaced re-additions get an explicit canonical-source recovery path.
Review follow-up:
Protect format conversions against teammate changes even when the checkout is fully synchronized, by comparing the default-branch blob of the retired file with the blob this machine last saw. Reject edited leftover tool copies as new shared-root agents. A namespaced source recreated by the team remains a distinct source: the warning names its exact path and directs the member to edit that canonical source after updating the checkout, while keeping retired flattened copies as backups. Older records explain their missing delivered-blob evidence. Remove unnecessary narrowing assertions.
Second and third review follow-ups:
.yamlcarries an edit made to the.md. The stop printsteamai push --carried <path>@<blob>, naming the retired file and its current blob on the default branch. With that value the push deletes the file only while the default branch still holds that blob; a later team edit stops it again and prints the new value. Without it every retry stops, as the other conflict guards do. A value that names no stopped conversion is rejected.--carried. An earlier revision recorded the blob a stop named, which let an unchanged retry delete the teammate's edit; that is removed. Updating the record on pull was not used either: a member who runsteamai pulland then converts the old root copy would delete the edit with no stop.--carriedis repeatable, regenerated intoskill-data/core/references/commands.md. An older placement record without a delivered blob keeps the plain "pull, carry, push again" message: once the checkout is up to date, it no longer stops. The docs say such records catch a team edit only while the checkout is behind it.main(4cb2b3c1). Thetroubleshooting.mdconflicts keep every section.Fourth review follow-up:
--carriedwaives only the deletion it names. The check for the file a conversion would delete no longer skips the source and destination checks for the same item. A teammate's file at the conversion's destination (for exampleagents/ops/sample.yamladded next to the.md) still stops the push with the usual "changed both here and on origin/main" message. Before, the carried push replaced that file.--carriedis checked against the conversions this push sends. A value for a conversion that--skillor the selection leaves out is rejected. So is any value on a push with no resource to send, including ateamai.yaml-only push and pushes outside single-repo mode. Before, those exited 0 or published the config branch.Fifth follow-up, an edited placed agent (the same gap exists on
main):main, nothing compared that file with what this machine had delivered, so a teammate's change toagents/ops/<name>.mdwas overwritten without a stop. The same happened after the "Merge origin/main" advice: the team file and the root copy are different paths, so git shows no conflict. The push now compares the placed file's blob onmainwith the delivered blob. When they differ it stops with exit 2 (... would overwrite .teamai/agents/ops/sample.md, which changed on origin/main since this machine delivered it ...) and prints the--carried <path>@<blob>value.--carriedfollows the same rules as for a deletion: exact current blob, only for items going out, nothing stored. A record without a delivered blob behaves as before until its first merged edit (sixth follow-up).--carriedhelp (regeneratedcommands.md), the docs in both languages andtroubleshooting.mdnow cover both cases. The rejection message now readsnames no placed agent file this push stops for; the earlier records below show the previous wording.main(97a762ce).Sixth follow-up, agents placed by an earlier release:
troubleshooting.mdnow say the first merged edit gives an older record its blob.Test Plan
npx tsc --noEmit,npm run lint,npm run build,git diff --check origin/main...HEAD: passed.Focused unit files (
agents,placement-records,pull-placement-reconcile,self-mode-push-scan,push-all-resources-namespaces,push-role,commands-reference): 222 passed.npx vitest run: 16476 passed, 21 skipped, 4 failed, all timeouts inworkflow-reconciliation.test.tsandworkflow-settle-cost.test.tswhile a real-CLI run went alongside. Those two files alone: 13 passed. Neither is touched here.After build,
npm run test:e2e --self-mode-push-behind,push-active-namespaces,role-scoped-agents,namespaced-entries,ownership-rules-agents-993: 146 passed. The new casedeletes a placed agent a teammate changed only with --carried naming the version the stop printedfailed before the fix: its unchanged retry exited 1 withPushed branchinstead of 2. It covers the dry-run stop, two unchanged retries, a value naming another path, an outdated value after a second team edit, a dry run with the value, and the carried push.Cases added in the fourth follow-up, each run against the previous head before its fix:
stops a --carried agent conversion when a teammate added its destination file(exited 1 withPushed branchinstead of 2),rejects --carried for an agent conversion this push leaves out(exited 1 withPushed branch),rejects --carried when no resource goes out, teamai.yaml changed: false(exited 0) and: true(exited 1 withPushed branch).Cases added in the fifth follow-up, each run against the head before its fix:
pushes the next conversion of a placed agent after this machine's own edit landed(stopped with the falsewould delete ... since this machine delivered it), andoverwrites a placed agent a teammate changed only with --carried naming the version the stop printed(its first dry run exited 0 instead of 2).pushes the next edit of a placed agent after this machine's own edit landedpassed before, and failed with the overwrite check alone until the delivered blob followed the member's merged edit.Case added in the sixth follow-up, run against the previous head before its fix:
stops an edit over a teammate's change once an older placement record took the blob of a merged edit(its push exited 1 withPushed branchinstead of 2).Real CLI for the sixth follow-up: self mode, local bare remote, isolated
HOMEand git config, the same script on the previous head (762a11cd) and on the new head. The member placesagents/ops/sample.mdand it merges.placedAgentSourcesis then removed from the state, as a record from an earlier release has none. The member edits the root copy, and that edit merges. A teammate then edits the placed file (blob B). The member runsgit pulland edits the root copy without B.Before (
762a11cd):After:
Real CLI for the fifth follow-up: self mode, local bare remote, isolated
HOMEand git config, the same script on this branch merged withmainand on the new head. The member placesagents/ops/sample.md, then makes two edits of the root copy, each merged. A teammate then edits the placed file (blob B). The member edits the root copy without B.Before (merge commit
8c19056f):After:
[...]marks the repeated tail of the same message.Real CLI, self mode, local bare remote, isolated
HOMEand git config. The member placesagents/ops/sample.mdwithpush --all --role opsand the team merges it. A teammate then edits it onmain. The member deletes.teamai/agents/sample.mdand writes.teamai/agents/sample.yamlfrom the old copy, without the teammate's line.Before the fix (this branch merged with
main), the unchanged retry deletes the teammate's edit:After:
Exit 1 after
Pushed branchcomes from thegitprovider, which cannot open a PR. The existing e2e expects the same. Step 7 is a linked worktree of the same project, which shares the state partition; its stale conversion would have updated the open PR.Real CLI for the fourth follow-up, same setup, the same script run on the previous head and on this one. After the placement merges, a teammate edits
agents/ops/sample.md(blob B) and addsagents/ops/sample.yaml. The member, still behind, converts its root copy and carries the.mdedit. Steps 1, 2 and 7 run with nothing else to push.Before (
d275d972):After:
Local host: macOS 27.0, Node 24.21.0, Git 2.56.0. Native Windows, live vendor applications and other provider and agent combinations were not run locally and are left to CI.
Deleted test:
pushes an agent conversion that carries the upstream edits each stop named. It required a plain retry after a stop to push, which is the behavior removed here; the--carriedcase above replaces it. The expected refusal text inrefuses agent conversion after an upstream editnow names the--carriedcommand.Refs #1221; this PR addresses only its stated independent defect.