yadflow 4.6.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +259 -0
  2. package/README.md +46 -4
  3. package/bin/commands.mjs +9 -2
  4. package/bin/yad.mjs +309 -30
  5. package/cli/agent-guard.mjs +511 -0
  6. package/cli/agent-guide.mjs +83 -0
  7. package/cli/agent-rules.mjs +381 -0
  8. package/cli/argv-flags.mjs +7 -0
  9. package/cli/artifact-status.mjs +88 -20
  10. package/cli/build.mjs +1372 -0
  11. package/cli/checkpoint.mjs +2 -2
  12. package/cli/ci-check.mjs +492 -0
  13. package/cli/commit.mjs +1 -0
  14. package/cli/dial.mjs +21 -1
  15. package/cli/docs.mjs +7 -2
  16. package/cli/doctor.mjs +176 -33
  17. package/cli/epic-state.mjs +360 -12
  18. package/cli/errors.mjs +3 -0
  19. package/cli/find-product.mjs +36 -2
  20. package/cli/fold.mjs +9 -5
  21. package/cli/gate-local.mjs +9 -1
  22. package/cli/gate.mjs +364 -22
  23. package/cli/guide.mjs +549 -0
  24. package/cli/history.mjs +22 -2
  25. package/cli/hook.mjs +35 -4
  26. package/cli/index-command.mjs +2 -2
  27. package/cli/ledger.mjs +60 -0
  28. package/cli/lib.mjs +46 -0
  29. package/cli/lifecycle/defaults/2.json +124 -0
  30. package/cli/lifecycle/lifecycle.schema.json +5 -2
  31. package/cli/lifecycle.mjs +16 -3
  32. package/cli/manifest.mjs +75 -0
  33. package/cli/marked-block.mjs +48 -0
  34. package/cli/members.mjs +19 -5
  35. package/cli/migrate.mjs +17 -19
  36. package/cli/next.mjs +35 -12
  37. package/cli/openpr.mjs +81 -5
  38. package/cli/plan.mjs +326 -22
  39. package/cli/platform.mjs +21 -0
  40. package/cli/pr-list.mjs +5 -3
  41. package/cli/product-index.mjs +6 -3
  42. package/cli/product-token.mjs +186 -0
  43. package/cli/productcommit.mjs +33 -0
  44. package/cli/protection.mjs +50 -0
  45. package/cli/recommend.mjs +3 -1
  46. package/cli/reconcile.mjs +187 -26
  47. package/cli/repo-publish.mjs +2 -2
  48. package/cli/report.mjs +62 -14
  49. package/cli/run-checks.mjs +586 -0
  50. package/cli/setup.mjs +244 -25
  51. package/cli/ship-drift.mjs +49 -18
  52. package/cli/signing.mjs +377 -0
  53. package/cli/standup.mjs +1 -1
  54. package/cli/status.mjs +282 -0
  55. package/cli/test-agents-file.mjs +993 -0
  56. package/cli/test-build.mjs +1559 -0
  57. package/cli/test-ci-check.mjs +616 -0
  58. package/cli/test-guide.mjs +1267 -0
  59. package/cli/test-node.mjs +129 -0
  60. package/cli/test-run-checks.mjs +603 -0
  61. package/cli/test-setup-agent.mjs +352 -0
  62. package/cli/test-signing.mjs +524 -0
  63. package/cli/test-worktree.mjs +520 -0
  64. package/cli/thread.mjs +4 -0
  65. package/cli/tidy.mjs +2 -2
  66. package/cli/toolbox.mjs +37 -6
  67. package/cli/update-commit.mjs +313 -11
  68. package/cli/workspace.mjs +38 -10
  69. package/cli/worktree-record.mjs +53 -0
  70. package/cli/worktree.mjs +379 -0
  71. package/package.json +6 -4
  72. package/skills/sdlc/config.yaml +5 -5
  73. package/skills/sdlc/module-help.csv +2 -1
  74. package/skills/yad-backfill/templates/checks/backfill-check.sh +9 -9
  75. package/skills/yad-change/SKILL.md +5 -1
  76. package/skills/yad-checks/SKILL.md +61 -12
  77. package/skills/yad-checks/references/check-gates.md +78 -14
  78. package/skills/yad-checks/templates/checks/build-test-lint.sh +22 -3
  79. package/skills/yad-checks/templates/checks/commit-message.sh +8 -2
  80. package/skills/yad-checks/templates/checks/contract-check.sh +61 -33
  81. package/skills/yad-checks/templates/checks/epic-open.sh +87 -14
  82. package/skills/yad-checks/templates/checks/ledger-guard.sh +3 -3
  83. package/skills/yad-checks/templates/checks/lineage-check.sh +88 -15
  84. package/skills/yad-checks/templates/checks/member-check.mjs +206 -35
  85. package/skills/yad-checks/templates/checks/package-manager.sh +42 -5
  86. package/skills/yad-checks/templates/checks/product-checkout.sh +161 -13
  87. package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +94 -15
  88. package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
  89. package/skills/yad-checks/templates/checks/spec-link.sh +63 -4
  90. package/skills/yad-checks/templates/checks/verified-commits.sh +23 -5
  91. package/skills/yad-checks/templates/github/yad-checks.yml +9 -9
  92. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +4 -1
  93. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +5 -5
  94. package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +16 -3
  95. package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +5 -1
  96. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +5 -1
  97. package/skills/yad-checks/templates/hooks/agent-guard.mjs +116 -0
  98. package/skills/yad-commit/SKILL.md +8 -5
  99. package/skills/yad-connect-repos/SKILL.md +5 -3
  100. package/skills/yad-connect-repos/references/code-context.md +2 -1
  101. package/skills/yad-connect-repos/references/repos-registry.md +2 -1
  102. package/skills/yad-docs/templates/app/package-lock.json +395 -106
  103. package/skills/yad-docs/templates/app/package.json +2 -2
  104. package/skills/yad-docs-overview/references/pipeline-model.md +2 -2
  105. package/skills/yad-engineer-review/SKILL.md +55 -25
  106. package/skills/yad-engineer-review/references/ship-and-record.md +49 -12
  107. package/skills/yad-epic/SKILL.md +2 -1
  108. package/skills/yad-epic/references/state-schema.md +76 -17
  109. package/skills/yad-guide/SKILL.md +192 -0
  110. package/skills/yad-implement/SKILL.md +75 -13
  111. package/skills/yad-implement/references/implement-conventions.md +8 -1
  112. package/skills/yad-implement/templates/.gitmessage +3 -0
  113. package/skills/yad-open-pr/SKILL.md +21 -0
  114. package/skills/yad-pair-review/SKILL.md +14 -5
  115. package/skills/yad-pr-template/SKILL.md +6 -2
  116. package/skills/yad-pr-template/templates/checks/pr-template.sh +85 -4
  117. package/skills/yad-pr-template/templates/checks/pr-title.sh +1 -1
  118. package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -1
  119. package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -1
  120. package/skills/yad-product-bridge/SKILL.md +44 -12
  121. package/skills/yad-product-bridge/references/bridge.md +11 -5
  122. package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +2 -2
  123. package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +9 -4
  124. package/skills/yad-reconcile/SKILL.md +9 -3
  125. package/skills/yad-report/SKILL.md +15 -0
  126. package/skills/yad-review-companion/SKILL.md +5 -3
  127. package/skills/yad-review-gate/SKILL.md +16 -8
  128. package/skills/yad-review-gate/references/gating.md +26 -1
  129. package/skills/yad-run/SKILL.md +61 -33
  130. package/skills/yad-run/references/run-loop.md +44 -22
  131. package/skills/yad-spec/SKILL.md +137 -16
  132. package/skills/yad-spec/references/spec-handoff.md +50 -3
  133. package/skills/yad-status/SKILL.md +7 -0
  134. package/skills/yad-stories/references/story-schema.md +1 -1
  135. package/skills/yad-sync-repos/SKILL.md +2 -1
  136. package/skills/yad-ui/SKILL.md +2 -2
@@ -27,7 +27,7 @@ product_config() {
27
27
  if [ -n "${SDLC_PRODUCT_CONFIG:-}" ]; then printf '%s' "$SDLC_PRODUCT_CONFIG"; return 0; fi
28
28
  if [ -n "${SDLC_HUB_CONFIG:-}" ]; then printf '%s' "$SDLC_HUB_CONFIG"; return 0; fi
29
29
  if [ -f .sdlc/product.json ] && [ -f .sdlc/hub.json ] && ! cmp -s .sdlc/product.json .sdlc/hub.json; then
30
- echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. Run \`yad migrate\` in the Product to choose the copy to keep, and commit both." >&2
30
+ echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. In the Product, run \`yad migrate --apply --keep product\` (or \`--keep hub\`) to choose the copy to keep, then commit both files." >&2
31
31
  return 1
32
32
  fi
33
33
  if [ -f .sdlc/product.json ]; then printf '%s' .sdlc/product.json; else printf '%s' .sdlc/hub.json; fi
@@ -61,7 +61,7 @@ BASE="${1:-${SDLC_BASE:-$(resolve_base)}}"
61
61
 
62
62
  # Fail closed if the base ref can't be resolved (shallow clone / wrong base branch / unfetched ref).
63
63
  if ! git rev-parse --verify --quiet "${BASE}^{commit}" >/dev/null; then
64
- echo "FAIL [spec-link]: base ref '${BASE}' not found — fetch full history / check the base branch."
64
+ echo "FAIL [spec-link]: base ref '${BASE}' not found — check the code out with full history (GitHub: actions/checkout with fetch-depth: 0; GitLab: GIT_DEPTH: \"0\"), and give a base that names a fetched branch (the first argument, or SDLC_BASE)."
65
65
  exit 1
66
66
  fi
67
67
  RANGE="${BASE}..HEAD"
@@ -71,6 +71,61 @@ EXEMPT='ci|chore|build|test'
71
71
  # The letters are spelled out so no locale widens them; matched whole with bash `=~`.
72
72
  STORY_RE='^EP-[abcdefghijklmnopqrstuvwxyz0123456789-]+-S[0123456789]+$'
73
73
 
74
+ # --- shared SHA exemption (byte-identical in spec-link / lineage-check / epic-open / reconcile-debt-check;
75
+ # --- the gates are deliberately standalone, so it is duplicated, not sourced) ---
76
+ # A commit already on a shared branch cannot be reworded without rewriting that branch, so one bad trailer
77
+ # would fail every later PR whose range still holds it — and a release PR to the default branch walks the
78
+ # whole release, so it fails again on every release until that commit reaches the base. `.sdlc/gate-exempt`
79
+ # names such commits, one full SHA per line, `#` comments allowed; every per-commit gate passes
80
+ # them, so a commit is waived once, in a reviewed change, instead of on every pipeline. A listed commit
81
+ # skips EVERY check of the gate, not only its trailer's — a sealed epic or a frozen thread included. SDLC_GATE_EXEMPT
82
+ # names another path in the repo. It comes from the pipeline config, which a PR may change where the PR's
83
+ # own pipeline runs; it still names a file on the BASE whose every entry must be a full SHA, so it cannot
84
+ # list the PR's own commits — and a PR that changes the pipeline could drop the gates anyway, which
85
+ # required checks and branch protection, not this script, prevent. The list is read from the BASE, never from this PR — a PR that could
86
+ # list its own commits would wave itself past every gate; an entry counts once it merges. An entry must be
87
+ # a FULL hex SHA: git reads 40 hex characters (64 in a SHA-256 repo) as a commit, but looks a short one up as a tag or branch name
88
+ # first — so a tag named like a listed short SHA would stand in for another commit, and a short SHA also
89
+ # grows ambiguous as the repo grows. An entry that is not one, or names no commit here, exempts nothing;
90
+ # both are said as notes, so a typo is visible.
91
+ GATE_EXEMPT_FILE="${SDLC_GATE_EXEMPT:-.sdlc/gate-exempt}"
92
+ exempt_shas=''
93
+ load_exempt_shas() {
94
+ # Three dots: against the merge base, so a base that moved on is not mistaken for this PR's change.
95
+ # Only exit 1 means "it changed"; an error (no merge base) says nothing about the file.
96
+ _ex_rc=0
97
+ git diff --quiet "${BASE}...HEAD" -- "$GATE_EXEMPT_FILE" 2>/dev/null || _ex_rc=$?
98
+ if [ "$_ex_rc" -eq 1 ]; then
99
+ echo "note [$1]: ${GATE_EXEMPT_FILE} changes in this PR — the list is read from ${BASE}, not from this PR; the new one counts once it merges."
100
+ fi
101
+ git cat-file -e "${BASE}:${GATE_EXEMPT_FILE}" 2>/dev/null || return 0
102
+ _ex_list="$(git show "${BASE}:${GATE_EXEMPT_FILE}" 2>/dev/null | sed -E 's/#.*//; s/^[[:space:]]+//; s/[[:space:]]+$//')" || _ex_list=""
103
+ while IFS= read -r _ex; do
104
+ [ -z "$_ex" ] && continue
105
+ case "$_ex" in
106
+ *[!0123456789abcdef]*) echo "note [$1]: ${GATE_EXEMPT_FILE} entry '${_ex}' is not a lowercase hex SHA — it exempts nothing." ; continue ;;
107
+ esac
108
+ if [ "${#_ex}" -ne 40 ] && [ "${#_ex}" -ne 64 ]; then
109
+ echo "note [$1]: ${GATE_EXEMPT_FILE} entry '${_ex}' is not a full SHA (40 characters, or 64 in a SHA-256 repo) — it exempts nothing (a short one could be taken over by a tag or branch of that name)."
110
+ continue
111
+ fi
112
+ _ex_full="$(git rev-parse --verify --quiet "${_ex}^{commit}" 2>/dev/null)" || _ex_full=""
113
+ # Only an entry git reads back as exactly itself: hex of the other hash's length (64 in a SHA-1 repo,
114
+ # 40 in a SHA-256 one) is looked up as a tag or branch name first, so a ref of that name would stand in;
115
+ # and an annotated tag's own SHA peels to its commit's — the list names commits, as rev-list walks them.
116
+ if [ -z "$_ex_full" ] || [ "$_ex_full" != "$_ex" ]; then
117
+ echo "note [$1]: ${GATE_EXEMPT_FILE} entry '${_ex}' is not the full SHA of a commit here — it exempts nothing."
118
+ continue
119
+ fi
120
+ exempt_shas="${exempt_shas}${_ex_full}
121
+ "
122
+ done <<EXEMPT_LIST
123
+ $_ex_list
124
+ EXEMPT_LIST
125
+ }
126
+ is_exempt_sha() { [ -n "$exempt_shas" ] && printf '%s' "$exempt_shas" | grep -qxF "$1"; }
127
+ load_exempt_shas spec-link
128
+
74
129
  # Portable across bash 3.2 (macOS) and 4+ — no mapfile; feed the loop via heredoc (not a pipe) so
75
130
  # the failure count survives the loop body.
76
131
  commits="$(git rev-list --no-merges "$RANGE")"
@@ -85,6 +140,10 @@ while IFS= read -r sha; do
85
140
  short="$(git log -1 --format=%h "$sha")"
86
141
  subject="$(git log -1 --format=%s "$sha")"
87
142
  task="$(git log -1 --format='%(trailers:key=Task,valueonly)' "$sha" | awk '!f && length($0) { print; f = 1 }')"
143
+ if is_exempt_sha "$sha"; then
144
+ echo "PASS [spec-link]: ${short} '${subject}' — SHA exemption (${GATE_EXEMPT_FILE} on ${BASE})"
145
+ continue
146
+ fi
88
147
  exempt=0
89
148
  note=''
90
149
  if printf '%s' "$subject" | grep -qE "^(${EXEMPT})(\([a-z0-9._-]+\))?!?: "; then
@@ -99,7 +158,7 @@ while IFS= read -r sha; do
99
158
  continue
100
159
  fi
101
160
  if [ -z "$task" ]; then
102
- echo "FAIL [spec-link]: ${short} '${subject}' has no 'Task:' trailer"
161
+ echo "FAIL [spec-link]: ${short} '${subject}' has no 'Task:' trailer — add one naming the task it implements, as 'Task: EP-<slug>-S<n>-T<NN>'. \`yad commit --task <id>\` writes it, and reads the id from a branch named like feat/EP-<slug>-S01-T01-<words> when no --task is given. For a commit already made, reword it (git commit --amend, or git rebase -i ${BASE}) and force-push. A ci, chore, build or test commit needs no trailer."
103
162
  rc=1
104
163
  continue
105
164
  fi
@@ -122,7 +181,7 @@ while IFS= read -r sha; do
122
181
  if [ -f "specs/${story}/link.md" ]; then
123
182
  echo "PASS [spec-link]: ${short} ${task} -> specs/${story}/link.md${note}"
124
183
  else
125
- echo "FAIL [spec-link]: ${short} ${task} references specs/${story}/ but link.md is missing."
184
+ echo "FAIL [spec-link]: ${short} ${task} references specs/${story}/ but link.md is missing — run the yad-spec skill for ${story} in this repo (it writes specs/${story}/link.md), or fix the story id in the Task trailer."
126
185
  rc=1
127
186
  fi
128
187
  done <<EOF
@@ -42,7 +42,7 @@ product_config() {
42
42
  if [ -n "${SDLC_PRODUCT_CONFIG:-}" ]; then printf '%s' "$SDLC_PRODUCT_CONFIG"; return 0; fi
43
43
  if [ -n "${SDLC_HUB_CONFIG:-}" ]; then printf '%s' "$SDLC_HUB_CONFIG"; return 0; fi
44
44
  if [ -f .sdlc/product.json ] && [ -f .sdlc/hub.json ] && ! cmp -s .sdlc/product.json .sdlc/hub.json; then
45
- echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. Run \`yad migrate\` in the Product to choose the copy to keep, and commit both." >&2
45
+ echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. In the Product, run \`yad migrate --apply --keep product\` (or \`--keep hub\`) to choose the copy to keep, then commit both files." >&2
46
46
  return 1
47
47
  fi
48
48
  if [ -f .sdlc/product.json ]; then printf '%s' .sdlc/product.json; else printf '%s' .sdlc/hub.json; fi
@@ -76,7 +76,7 @@ BASE="${1:-${SDLC_BASE:-$(resolve_base)}}"
76
76
 
77
77
  # Fail closed if the base ref can't be resolved (shallow clone / wrong base branch / unfetched ref).
78
78
  if ! git rev-parse --verify --quiet "${BASE}^{commit}" >/dev/null; then
79
- echo "FAIL [verified-commits]: base ref '${BASE}' not found — fetch full history / check the base branch."
79
+ echo "FAIL [verified-commits]: base ref '${BASE}' not found — check the code out with full history (GitHub: actions/checkout with fetch-depth: 0; GitLab: GIT_DEPTH: \"0\"), and give a base that names a fetched branch (the first argument, or SDLC_BASE)."
80
80
  exit 1
81
81
  fi
82
82
  RANGE="${BASE}..HEAD"
@@ -114,13 +114,22 @@ case "$platform" in
114
114
  ;;
115
115
  esac
116
116
 
117
- # 0 when the platform marks the commit's signature verified.
117
+ # 0 when the platform marks the commit's signature verified. On GitHub a failed API call sets
118
+ # sig_api_error=1, so the FAIL can tell "not signed" from "could not ask" (#351). It is read from gh's
119
+ # exit status: on an HTTP error (a bad token, a rate limit) gh still prints the error body to stdout.
120
+ # GitLab answers an unsigned commit with a 404, which `curl -f` cannot tell from a refused token, so it
121
+ # stays one case.
122
+ sig_api_error=0
118
123
  signature_verified() {
119
124
  local sha v body
120
125
  sha="$1"
126
+ sig_api_error=0
121
127
  case "$platform" in
122
128
  github)
123
- v="$(gh api "repos/{owner}/{repo}/commits/${sha}" --jq '.commit.verification.verified' 2>/dev/null || echo api-error)"
129
+ if ! v="$(gh api "repos/{owner}/{repo}/commits/${sha}" --jq '.commit.verification.verified' 2>/dev/null)"; then
130
+ sig_api_error=1
131
+ return 1
132
+ fi
124
133
  [ "$v" = "true" ]
125
134
  ;;
126
135
  gitlab)
@@ -172,7 +181,16 @@ while IFS= read -r sha; do
172
181
  # falls through to FAIL below.
173
182
  echo "WARN [verified-commits]: ${short} unsigned merge commit — introduces no content of its own (covered by verified parents); signature waived. (Self-hosted GitLab does not sign UI merge commits; on a platform that signs its merges an unsigned content-free merge is unusual but still harmless.)"
174
183
  else
175
- echo "FAIL [verified-commits]: ${short} signature missing/unverified — sign commits (GPG/SSH key registered on ${platform}), or the signature API was unreachable (GitLab: set GITLAB_TOKEN/SDLC_API_TOKEN with read_api)."
184
+ if [ "$sig_api_error" = 1 ]; then
185
+ echo "FAIL [verified-commits]: ${short} — the job could not ask GitHub for the commit's signature (gh api failed). The job needs GH_TOKEN set to the workflow's github.token, as the yad workflows set it; then run it again. On your own machine: install gh and run gh auth login."
186
+ else
187
+ resign="sign commits with a GPG or SSH key added to your ${platform} account (git config commit.gpgsign true; for an SSH key also gpg.format ssh and user.signingkey). On a pull request branch, re-sign the commits already made: git rebase --exec 'git commit --amend --no-edit -S' ${BASE}, and force-push. On the default branch, do not force-push: revert the commit, then land the change again through a pull request of signed commits."
188
+ if [ "$platform" = gitlab ]; then
189
+ echo "FAIL [verified-commits]: ${short} signature missing/unverified — ${resign} If the commits are signed, the job could not read GitLab's signature API: set a GITLAB_TOKEN (or SDLC_API_TOKEN) CI/CD variable with the read_api scope."
190
+ else
191
+ echo "FAIL [verified-commits]: ${short} signature missing/unverified — ${resign}"
192
+ fi
193
+ fi
176
194
  rc=1
177
195
  fi
178
196
  fi
@@ -32,9 +32,9 @@ jobs:
32
32
  - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
33
33
  with: { fetch-depth: 0 }
34
34
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN
35
- # secret is set; without it this prints a note and the gate defers, as before.
35
+ # secret is set; without it the gate defers, with a WARNING unless the PR comes from a fork (#345).
36
36
  - run: bash checks/product-checkout.sh "origin/${{ github.base_ref }}"
37
- env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}" }
37
+ env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}", YAD_PR_FORK: "${{ github.event.pull_request.head.repo.full_name != github.repository }}" }
38
38
  - run: bash checks/contract-check.sh "origin/${{ github.base_ref }}"
39
39
 
40
40
  # E65/E66 — the risk map (.sdlc/risk-map: a risk level per directory, no names). Warnings, and the
@@ -53,7 +53,7 @@ jobs:
53
53
  if: github.event.action != 'edited'
54
54
  env:
55
55
  YAD_TEST_MAX_WORKERS: "2" # cap jest/vitest test workers in CI; ignored by other runners
56
- YAD_NODE_VERSION: ${{ vars.YAD_NODE_VERSION || '22' }} # repo variable; a current 20, 22 or 24 line (Node 25+ has no Corepack)
56
+ YAD_NODE_VERSION: ${{ vars.YAD_NODE_VERSION || '22' }} # repo variable; a current 22 or 24 line (Node 25+ has no Corepack; 18 and 20 are end of life)
57
57
  NX_BASE: ${{ github.event.pull_request.base.sha }}
58
58
  NX_HEAD: ${{ github.event.pull_request.head.sha }}
59
59
  COREPACK_HOME: ${{ github.workspace }}/.corepack-cache # pinned-manager downloads, cached below
@@ -93,9 +93,9 @@ jobs:
93
93
  - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
94
94
  with: { fetch-depth: 0 }
95
95
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN
96
- # secret is set; without it this prints a note and the gate defers, as before.
96
+ # secret is set; without it the gate defers, with a WARNING unless the PR comes from a fork (#345).
97
97
  - run: bash checks/product-checkout.sh "origin/${{ github.base_ref }}"
98
- env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}" }
98
+ env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}", YAD_PR_FORK: "${{ github.event.pull_request.head.repo.full_name != github.repository }}" }
99
99
  - run: bash checks/lineage-check.sh "origin/${{ github.base_ref }}"
100
100
 
101
101
  epic-open:
@@ -105,9 +105,9 @@ jobs:
105
105
  - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
106
106
  with: { fetch-depth: 0 }
107
107
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN
108
- # secret is set; without it this prints a note and the gate defers, as before.
108
+ # secret is set; without it the gate defers, with a WARNING unless the PR comes from a fork (#345).
109
109
  - run: bash checks/product-checkout.sh "origin/${{ github.base_ref }}"
110
- env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}" }
110
+ env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}", YAD_PR_FORK: "${{ github.event.pull_request.head.repo.full_name != github.repository }}" }
111
111
  - run: bash checks/epic-open.sh "origin/${{ github.base_ref }}"
112
112
 
113
113
  reconcile-debt:
@@ -117,9 +117,9 @@ jobs:
117
117
  - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
118
118
  with: { fetch-depth: 0 }
119
119
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN
120
- # secret is set; without it this prints a note and the gate defers, as before.
120
+ # secret is set; without it the gate defers, with a WARNING unless the PR comes from a fork (#345).
121
121
  - run: bash checks/product-checkout.sh "origin/${{ github.base_ref }}"
122
- env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}" }
122
+ env: { YAD_PRODUCT_TOKEN: "${{ secrets.YAD_PRODUCT_TOKEN }}", YAD_PR_FORK: "${{ github.event.pull_request.head.repo.full_name != github.repository }}" }
123
123
  - run: bash checks/reconcile-debt-check.sh "origin/${{ github.base_ref }}"
124
124
 
125
125
  # Pattern gates: commit subject + PR title + PR body all follow the convention (profile: code).
@@ -5,6 +5,9 @@ stages: [spec-link, contract-check, build-test-lint, verified-commits]
5
5
 
6
6
  default:
7
7
  image: node:${YAD_NODE_VERSION}
8
+ # Runner selection on tag-locked instances (run_untagged: false): set the YAD_RUNNER_TAGS CI/CD variable.
9
+ # When unset, current GitLab (>=15) runs the jobs untagged.
10
+ tags: [$YAD_RUNNER_TAGS]
8
11
 
9
12
  .mr_only:
10
13
  rules:
@@ -12,7 +15,7 @@ default:
12
15
 
13
16
  variables:
14
17
  GIT_DEPTH: "0" # full history so the gates can diff against the target branch
15
- YAD_NODE_VERSION: "22" # override with a project/group CI variable (a current 20, 22 or 24 line; Node 25+ has no Corepack)
18
+ YAD_NODE_VERSION: "22" # override with a project/group CI variable (a current 22 or 24 line; Node 25+ has no Corepack; 18 and 20 are end of life)
16
19
  NX_BASE: $CI_MERGE_REQUEST_DIFF_BASE_SHA
17
20
  NX_HEAD: $CI_COMMIT_SHA
18
21
 
@@ -23,7 +23,7 @@
23
23
  image: node:${YAD_NODE_VERSION}
24
24
  variables:
25
25
  # A project/group CI/CD variable overrides a YAML value, so YAD_NODE_VERSION can be changed in
26
- # project settings without editing the managed fragment (a current 20, 22 or 24 line; Node 25+ has no Corepack).
26
+ # project settings without editing the managed fragment (a current 22 or 24 line; Node 25+ has no Corepack).
27
27
  YAD_NODE_VERSION: "22"
28
28
  NX_BASE: $CI_MERGE_REQUEST_DIFF_BASE_SHA
29
29
  NX_HEAD: $CI_COMMIT_SHA
@@ -52,7 +52,7 @@ yad-contract-check:
52
52
  needs: []
53
53
  script:
54
54
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN CI/CD
55
- # variable is set (masked); without it this prints a note and the gate defers, as before.
55
+ # variable is set (masked); without it the gate defers, with a WARNING unless the MR comes from a fork (#345).
56
56
  - bash checks/product-checkout.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
57
57
  - bash checks/contract-check.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
58
58
 
@@ -81,7 +81,7 @@ yad-lineage-check:
81
81
  needs: []
82
82
  script:
83
83
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN CI/CD
84
- # variable is set (masked); without it this prints a note and the gate defers, as before.
84
+ # variable is set (masked); without it the gate defers, with a WARNING unless the MR comes from a fork (#345).
85
85
  - bash checks/product-checkout.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
86
86
  - bash checks/lineage-check.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
87
87
 
@@ -90,7 +90,7 @@ yad-epic-open:
90
90
  needs: []
91
91
  script:
92
92
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN CI/CD
93
- # variable is set (masked); without it this prints a note and the gate defers, as before.
93
+ # variable is set (masked); without it the gate defers, with a WARNING unless the MR comes from a fork (#345).
94
94
  - bash checks/product-checkout.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
95
95
  - bash checks/epic-open.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
96
96
 
@@ -99,7 +99,7 @@ yad-reconcile-debt:
99
99
  needs: []
100
100
  script:
101
101
  # E120: check the Product out where .sdlc/product-link.json says, when the YAD_PRODUCT_TOKEN CI/CD
102
- # variable is set (masked); without it this prints a note and the gate defers, as before.
102
+ # variable is set (masked); without it the gate defers, with a WARNING unless the MR comes from a fork (#345).
103
103
  - bash checks/product-checkout.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
104
104
  - bash checks/reconcile-debt-check.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
105
105
 
@@ -10,11 +10,24 @@
10
10
  # the gate can tell the two apart. Commit subjects are always Conventional-Commits.
11
11
  # Job names are yad-product-prefixed so they coexist with any code-repo fragment in one pipeline; jobs use
12
12
  # `needs: []` and no `stage:` so a foreign `stages:` list can neither break nor reorder them.
13
- default:
14
- image: node:20
15
- tags: [$YAD_RUNNER_TAGS]
13
+ #
14
+ # `image:`/`tags:` live on the .yad_product_mr_only anchor below — NOT a top-level `default:`. An included
15
+ # top-level `default:` merges into the HOST root pipeline: it would set this image and tag on every one of
16
+ # the Product's own jobs, and if the root already sets a top-level `image:`, GitLab rejects the whole
17
+ # config ("image is defined in top-level and 'default:' entry"). The anchor scopes them to these jobs.
16
18
 
17
19
  .yad_product_mr_only:
20
+ image: node:${YAD_NODE_VERSION}
21
+ variables:
22
+ # A project/group CI/CD variable overrides this YAML value, so the Node line can be changed in project
23
+ # settings without editing the managed fragment (a current 22 or 24 line). A shell-executor runner
24
+ # ignores `image:` — Node must then be on the runner host's PATH, and this value has no effect.
25
+ YAD_NODE_VERSION: "22"
26
+ # Runner selection: set the YAD_RUNNER_TAGS CI/CD variable (e.g. `dind_runner`) to route these jobs on
27
+ # instances whose runners are tag-locked (run_untagged: false) — it lives in project Settings → CI/CD →
28
+ # Variables, so it survives every `yad` sync. When unset, current GitLab (>=15) runs the jobs untagged;
29
+ # older versions may strand them — set a real tag if so. Single value only: `tags: [$VAR]` is one tag.
30
+ tags: [$YAD_RUNNER_TAGS]
18
31
  rules:
19
32
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
20
33
 
@@ -19,9 +19,13 @@
19
19
 
20
20
  .yad_update_guard_base: &yad_update_guard_base
21
21
  tags: [$YAD_RUNNER_TAGS]
22
- image: node:20
22
+ image: node:${YAD_NODE_VERSION}
23
23
  variables:
24
24
  GIT_DEPTH: "0" # full history so the gates can diff the pushed range
25
+ # A project/group CI/CD variable overrides this YAML value, so the Node line can be changed in project
26
+ # settings without editing the managed fragment (a current 22 or 24 line). A shell-executor runner
27
+ # ignores `image:` — Node must then be on the runner host's PATH, and this value has no effect.
28
+ YAD_NODE_VERSION: "22"
25
29
  before_script:
26
30
  # First push / an unresolvable before-SHA: fall back to the commit's parent (tip commit only —
27
31
  # a rare fail-open for a multi-commit first push, preferred over failing closed).
@@ -17,9 +17,13 @@ yad-product-verified-commits:
17
17
  # project Settings → CI/CD → Variables, so it survives every `yad` sync. When unset, current
18
18
  # GitLab (>=15) runs the job untagged; older versions may strand it — set a real tag if so.
19
19
  tags: [$YAD_RUNNER_TAGS]
20
- image: node:20
20
+ image: node:${YAD_NODE_VERSION}
21
21
  variables:
22
22
  GIT_DEPTH: "0" # full history so the gate can diff against the target branch
23
+ # A project/group CI/CD variable overrides this YAML value, so the Node line can be changed in project
24
+ # settings without editing the managed fragment (a current 22 or 24 line). A shell-executor runner
25
+ # ignores `image:` — Node must then be on the runner host's PATH, and this value has no effect.
26
+ YAD_NODE_VERSION: "22"
23
27
  rules:
24
28
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
25
29
  script:
@@ -0,0 +1,116 @@
1
+ // agent-guard HARNESS HOOK (E158) — before an AI agent's shell command runs, refuse a yad command only the
2
+ // person may run (an approval; a gate comment, advance or reopen; `commit --manual`), a PR/MR approval or merge
3
+ // (`gh`, `glab`), skipping the git hooks (`--no-verify` or `-n`, `YAD_HOOK_DISABLE`, `core.hooksPath`), or a force
4
+ // push, and say what to do instead: ask the person to run it themselves.
5
+ //
6
+ // This file is only the ADAPTER. It locates `yad` and hands the payload to `yad hook agent-guard`, which
7
+ // holds the decision (cli/agent-guard.mjs). ONE script serves both harnesses, and answers in the protocol
8
+ // the payload names:
9
+ //
10
+ // Claude Code `PreToolUse`, matcher `Bash`: exit 0 allows, exit 2 denies with the reason on stderr
11
+ // Cursor `beforeShellExecution`: a permission hook — a JSON verdict on stdout, ALWAYS, since an
12
+ // empty or off-schema answer blocks the command
13
+ //
14
+ // A SPEED BUMP, NOT PROOF: a command hidden in a script or an alias is not seen. The platform, and CI's
15
+ // ledger guard, are what prove an approval. Codex has no hooks: there only the rules in AGENTS.md apply.
16
+ //
17
+ // A NODE SCRIPT (E113), importing nothing outside Node, because it runs from the Product (`hooks/`) or a
18
+ // connected code repo (`checks/`, E158b), where yadflow may not be installed at all.
19
+ //
20
+ // FAIL-OPEN: if no `yad` can be found, or it cannot run, the command is ALLOWED and this says why on stderr.
21
+ import { spawnSync } from 'node:child_process';
22
+ import fs from 'node:fs';
23
+ import path from 'node:path';
24
+ import { fileURLToPath } from 'node:url';
25
+
26
+ // ---- yad-resolve (the same block in every hooks/*.mjs; a test keeps the copies identical) ----------
27
+ // The Product root is this script's grandparent — `<product>/hooks/<script>.mjs` — found from the
28
+ // script's OWN location, never from the harness's working directory or its project-root variable
29
+ // (whose form on Windows, `C:\…` or `/c/…`, no harness documents). `realpathSync` so a script reached
30
+ // through a symbolic link still finds its own Product.
31
+ const PRODUCT_ROOT = path.dirname(path.dirname(fs.realpathSync(fileURLToPath(import.meta.url))));
32
+ const IS_WINDOWS = process.platform === 'win32';
33
+
34
+ // A command found on PATH, or null. On Windows the npm launchers are `.cmd` files.
35
+ function onPath(name) {
36
+ const exts = IS_WINDOWS ? ['.cmd', '.exe', ''] : [''];
37
+ for (const dir of (process.env.PATH || '').split(path.delimiter)) {
38
+ if (!dir) continue;
39
+ for (const ext of exts) {
40
+ const full = path.join(dir, name + ext);
41
+ try { if (fs.statSync(full).isFile()) return full; } catch { /* not here */ }
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+
47
+ // Windows cannot start a `.cmd` launcher without a shell (Node refuses since 18.20.2), so those run
48
+ // through one, each word in double quotes. A Windows path cannot hold a `"`, so the quoting is whole.
49
+ const quoteForCmd = (word) => `"${String(word).replace(/"/g, '')}"`;
50
+
51
+ // How to run `yad`, cheapest and most specific first: an explicit override, then the copy installed in
52
+ // this Product, then `yad` on PATH, then a network-free npx. `--no-install` matters — a hook runs on
53
+ // every tool call and must never pause an agent to download a package. Returns
54
+ // `{ file, args, shell }` or null.
55
+ function resolveYad() {
56
+ // YAD_BIN is commonly an interpreter plus a script ("node /path/to/yad.mjs"). Split on spaces, with a
57
+ // double-quoted word kept whole — Node on Windows usually lives under `C:\Program Files\`.
58
+ const override = [...(process.env.YAD_BIN || '').matchAll(/"([^"]*)"|(\S+)/g)].map((m) => m[1] ?? m[2]).filter(Boolean);
59
+ if (override.length) {
60
+ const [file, ...args] = override;
61
+ return { file, args, shell: IS_WINDOWS && /\.(cmd|bat)$/i.test(file) };
62
+ }
63
+ const local = path.join(PRODUCT_ROOT, 'node_modules', 'yadflow', 'bin', 'yad.mjs');
64
+ if (fs.existsSync(local)) return { file: process.execPath, args: [local], shell: false };
65
+ const yad = onPath('yad');
66
+ if (yad) {
67
+ if (!IS_WINDOWS || !/\.(cmd|bat)$/i.test(yad)) return { file: yad, args: [], shell: false };
68
+ // An npm global install puts the package beside its launcher: run the script with this Node
69
+ // rather than through a shell whenever it is there.
70
+ const script = path.join(path.dirname(yad), 'node_modules', 'yadflow', 'bin', 'yad.mjs');
71
+ if (fs.existsSync(script)) return { file: process.execPath, args: [script], shell: false };
72
+ return { file: yad, args: [], shell: true };
73
+ }
74
+ const npx = onPath('npx');
75
+ if (npx) return { file: npx, args: ['--no-install', 'yadflow'], shell: IS_WINDOWS && /\.(cmd|bat)$/i.test(npx) };
76
+ return null;
77
+ }
78
+
79
+ // Run the resolved `yad` with `args` appended. `options` go to spawnSync.
80
+ function runYad(yad, args, options) {
81
+ const all = [...yad.args, ...args];
82
+ if (yad.shell) return spawnSync([yad.file, ...all].map(quoteForCmd).join(' '), { ...options, shell: true, windowsHide: true });
83
+ return spawnSync(yad.file, all, { ...options, windowsHide: true });
84
+ }
85
+ // ---- end yad-resolve ---------------------------------------------------------------------------------
86
+
87
+ // The payload is read here, so the protocol can be chosen even when `yad` cannot be reached.
88
+ let input = '';
89
+ try { input = process.stdin.isTTY ? '' : fs.readFileSync(0, 'utf8'); } catch { input = ''; }
90
+ let payload = null;
91
+ try { payload = JSON.parse(input); } catch { payload = null; }
92
+ const cursor = payload?.hook_event_name === 'beforeShellExecution' || typeof payload?.cursor_version === 'string';
93
+ const ALLOW = '{"permission":"allow"}';
94
+ const allow = (why) => {
95
+ if (why) process.stderr.write(` • yad hook: ${why} — allowing\n`);
96
+ if (cursor) process.stdout.write(`${ALLOW}\n`);
97
+ process.exit(0);
98
+ };
99
+
100
+ const yad = resolveYad();
101
+ if (!yad) allow(`no \`yad\` on PATH and none installed in ${PRODUCT_ROOT} (install yadflow to re-arm the agent guard)`);
102
+
103
+ const r = runYad(yad, ['hook', 'agent-guard', '--format', cursor ? 'cursor' : 'exit'], { input, stdio: ['pipe', 'pipe', 'inherit'], encoding: 'utf8' });
104
+ if (cursor) {
105
+ // The verdict is the last non-empty line that names a permission (see ledger-guard-cursor.mjs for why).
106
+ const lines = String(r.stdout || '').split(/\r?\n/).filter((l) => l.trim());
107
+ const verdict = lines.length ? lines[lines.length - 1] : '';
108
+ if (verdict.includes('"permission"')) { process.stdout.write(`${verdict}\n`); process.exit(0); }
109
+ allow(r.status === 0 ? '' : `\`yad hook agent-guard\` ${r.error ? r.error.message : `exited ${r.status ?? r.signal}`} (run \`yad doctor\` to check the install)`);
110
+ }
111
+ // Only an explicit deny (2) blocks: a yad that cannot run, or one older than this hook (it refuses the
112
+ // unknown action with another code), must not read as a refusal.
113
+ if (r.stdout) process.stdout.write(r.stdout);
114
+ if (r.status === 2) process.exit(2);
115
+ if (r.status !== 0) allow(`\`yad hook agent-guard\` ${r.error ? r.error.message : `exited ${r.status ?? r.signal}`} (run \`yad doctor\` to check the install)`);
116
+ process.exit(0);
@@ -57,9 +57,11 @@ staged, split it into separate commits rather than passing `--force`.
57
57
  ### Step 2 — Commit by convention
58
58
  Run the CLI from the repo root:
59
59
  ```
60
- yad commit --type <type> -m "<subject>" [--ai <id>] [--task <id>] [--contract-change] [--manual --reason "<why>"] [--dry-run]
60
+ yad commit --type <type> -m "<subject>" [--body "<text>"] [--ai <id>] [--task <id>] [--contract-change] [--manual --reason "<why>"] [--dry-run]
61
61
  ```
62
- Use `--dry-run` first to preview the exact message (subject + trailer block) without committing. The
62
+ `--body` adds a body between the subject and the trailers, as its own paragraph — for example the
63
+ `Decisions:` paragraph `yad-implement` writes (#357). `yad ship` takes no body: commit with `yad commit`, and open the
64
+ PR/MR later, when the flow says to (`yad open-pr`). Use `--dry-run` first to preview the exact message (subject + trailer block) without committing. The
63
65
  CLI validates the type, rejects a trailing period, and emits the trailers in the fixed order.
64
66
 
65
67
  ### Step 3 — Stop (no auto-advance)
@@ -75,9 +77,10 @@ the architecture gate. To also open the PR/MR in the same step, use `yad-ship`.
75
77
  - **Trailer order is fixed:** `Task → Contract-Change → Ledger-Override → Co-Authored-By` (the override only
76
78
  with `--manual`, the footer only when `--ai` is given).
77
79
  - **Never widen the contract here.** A contract touch is flagged (`--contract-change`), not hidden.
78
- - **Never pass `--manual` on your own initiative.** Committing past the ledger hook is a person's decision.
79
- Pass it only when the user asked for it, with the reason they gave. `--manual` needs `--reason`, and the
80
- reason must be one line.
80
+ - **Never pass `--manual` yourself, even when asked (E158).** Committing past the ledger hook is the person's
81
+ act. Give them the exact command (in Claude Code: `! yad commit --manual --reason "<why>"`), wait, then
82
+ confirm by reading (`git log -1`). `--manual` needs `--reason`, and the reason must be one line. The agent
83
+ guard hook refuses it if you try.
81
84
 
82
85
  ## Reference
83
86
  - Branch/commit conventions + the file-boundary rule: `../yad-implement/references/implement-conventions.md`.
@@ -188,10 +188,11 @@ the Shape phases will now load this repo's code-map. Nothing auto-advances; this
188
188
 
189
189
  - **`refresh`** — re-run Steps 2–4 (including Step 3b) for an already-connected repo (after its code moves). A new directory gets an `unset` line and a guess; a `confirmed` line is only ever suggested against. Updates
190
190
  `syncedHead` + `lastSyncedAt`. Same machinery as `connect`. Once the AI has regenerated the
191
- `code-map.md` (Step 3), publish it to the Product with **`yad repo refresh <repo> --push`**: it
191
+ `code-map.md` (Step 3), publish it to the Product with **`yad repo refresh <repo> --push`** — ask the
192
+ person first, every time: it pushes to the default branch (E158) — it
192
193
  commits the tracked code-maps + `.sdlc/repos.json` (never the gitignored `pack.md`) as one
193
194
  audit-trail commit `chore(product): sync code-context — <repos> by @<login> [skip ci]` and pushes it
194
- straight to the Product's **default branch** (add `--allow-branch` to commit on a non-default branch).
195
+ straight to the Product's **default branch** (add `--allow-branch` to commit on a non-default branch, only when the person asks).
195
196
  This is the code-context analogue of `yad checkpoint` — human-owned machine state, no Task trailer,
196
197
  no Co-Authored-By.
197
198
  - **`list`** — print every registry entry with a **fresh/stale** flag: compare each repo's current HEAD
@@ -253,7 +254,8 @@ any user name or password taken out of `git_url`) into every connected repo, and
253
254
  to each repo's default branch — a record on disk that is not committed as it stands is committed by the
254
255
  next `--push`, though `yad check` reads it as `ok`. The Product-reading gates read it from
255
256
  the base; `checks/product-checkout.sh` uses it with the `YAD_PRODUCT_TOKEN` secret. After connecting a
256
- repo, run `yad check --fix --push`; `yad doctor` warns `repos:product-link-missing` until it is on
257
+ repo, run `yad check --fix --open-pr` (a PR/MR per repo, no asking), or `yad check --fix --push` after the
258
+ person says yes (it pushes to every repo's default branch, E158); `yad doctor` warns `repos:product-link-missing` until it is on
257
259
  the repo's default branch.
258
260
 
259
261
  ## Live on-demand (the third context layer)
@@ -83,7 +83,8 @@ silently re-packing the whole repo. A phase never refreshes the registry on its
83
83
  `yad repo refresh` (or `yad check --fix`). After the AI regenerates the code-map, `yad repo refresh
84
84
  --push` publishes the refreshed code-maps + registry to the Product's default branch as a `chore(product): sync
85
85
  code-context … [skip ci]` audit commit (never the pack's content; `--allow-branch` overrides the branch
86
- guard). The `pack.md` is gitignored — `yad repo refresh`/`yad setup` scaffold
86
+ guard; it pushes to the default branch, so an AI agent asks the person first, every time, E158). The
87
+ `pack.md` is gitignored — `yad repo refresh`/`yad setup` scaffold
87
88
  `.sdlc/code-context/*/pack.md` into the Product `.gitignore` (so a regenerated pack never dirties the tree),
88
89
  and a Product that tracked the pack *before* that ignore existed is self-healed: `--push` untracks it and
89
90
  lands the removal + the managed `.gitignore` line in the same audit commit. The commit is a scoped
@@ -54,7 +54,8 @@ not under any `epics/EP-<slug>/.sdlc/`.
54
54
  Commit the **registry** (`repos.json`) and each repo's **`code-map.md`** — they are small, reviewable,
55
55
  and are what the Shape phases actually read (a diff on a code-map shows when a repo's surface moved).
56
56
  `yad repo refresh --push` commits and pushes exactly these (never `pack.md`) to the Product's default
57
- branch as one `chore(product): sync code-context … [skip ci]` audit commit.
57
+ branch as one `chore(product): sync code-context … [skip ci]` audit commit; an AI agent asks the person
58
+ before it, every time (E158).
58
59
  **Ignore** the full Repomix `pack.md` — it is large and regenerable (`action: refresh`). The Product
59
60
  's `.gitignore` carries `.sdlc/code-context/*/pack.md` for this. This mirrors how the per-epic
60
61
  `.sdlc/` state (state.json, approvals.json, build-log.json) is committed.