fix(spawn): 刷新 no-mistakes gate,使 worktree push 能创建流水线 run#136
Open
JJ22007 wants to merge 1 commit into
Open
Conversation
Add bin/fm-nm-gate.sh and call it from fm-spawn for no-mistakes-mode ship tasks. An older no-mistakes left a post-receive hook with a relative gate path, so a crewmate pushing from a treehouse worktree failed with 'invalid gate path: .' and no pipeline run was created. The idempotent no-mistakes init refreshes the shared gate hook; running it at spawn self-heals stale gates without touching project files. Best-effort and non-fatal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
no-mistakes模式的项目里,crewmate 在自己的 treehouse worktree 里跑完整流水线时,git push no-mistakes <branch>不会创建流水线 run。post-receive hook 报错
invalid gate path: .,daemon 拒绝该 gate,于是没有 run 被创建;之后no-mistakes rerun又报no previous run for branch。结果就是 crewmate 无法在隔离工作流里通过 gate 校验后再交付,违背了 firstmate 的设计约定。根因
no-mistakes按仓库身份(origin URL) 维护一个共享 gate:主 clone 和它的每一个 linked / treehouse worktree 共用同一个 bare repo 与 post-receive hook。并没有「每个 worktree 一个 gate」这种东西 —— 在 worktree 里跑no-mistakes init只会刷新这同一个共享 gate。旧版本
no-mistakes安装的 post-receive hook 用的是相对 gate 路径:git 执行 hook 时GIT_DIR是相对的(.),所以传给 daemon 的--gate就是.,被判为invalid gate path: .。新版本改用绝对路径--gate "$(pwd)",但这个修复只有在重新跑一次no-mistakes init刷新已存在的 bare repo hook 后才会生效。而 firstmate 只在「添加项目」时跑一次 init,之后从不刷新,所以用旧版本初始化过的 gate 会一直带着坏 hook。修法
bin/fm-nm-gate.sh:对给定的项目 clone 幂等地刷新 gate(即 section 6 已授权的no-mistakes init例外),把陈旧 hook 原地修好。带护栏、尽力而为:非 git 目录 / 无 origin / 未装 no-mistakes / init 失败都只告警并exit 0,从不阻塞;只做 git remote/config 设置,绝不改动项目文件。bin/fm-spawn.sh:仅对no-mistakes模式的 ship 任务,在启动 crewmate 前调用该 helper 刷新主 clone(PROJ_ABS)的共享 gate —— 主 clone 的 bare repo 正是 worktree push 的目标,刷新它即可自愈。direct-PR/local-only/ scout / secondmate 都不触发。AGENTS.md:在 spawn 小节记录这个自愈步骤。端到端验证证据
在完全隔离的临时仓库(自带 origin 与 gate,验证后
eject清理)上复现并验证:helper单元测试tests/fm-nm-gate.test.sh覆盖用法错误 / 非 git 目录 / 无 origin / 正常刷新(断言确实调用了 init)/ 未装 no-mistakes / init 失败仍非致命,全部通过。fm-spawn-batch、fm-teardown等相关测试仍绿;改动前后~/.no-mistakes的仓库记录数不变(无污染)。