Skip to content

Commit 72a8c90

Browse files
committed
fix: Reconcile stale _meta source and drop unverified fallback link
Address Jim's review on #136 (closes the real #131 regression): - resolve_skill_meta: re-resolve when stored .source != current SKILL_SOURCE_REPO, so flipping the default to rossoctl/repoman does not strand existing installs on a dead agent-skills-pinned SHA (404). - skill_attribution: unresolved provenance now emits a LINKLESS footer instead of an unverified blob/main link (#131 item 4). - Tests: add stale-source-repair + linkless-unresolved cases; update the three footer suites' fallback assertions. - Docs: mark the Phase 6 spec superseded here; update the stale skill_attribution header comment; widen this spec's scope/deliverables. Assisted-By: Claude Code (Anthropic AI) <[email protected]> Signed-off-by: Gloire Rubambiza <[email protected]>
1 parent 5bdf101 commit 72a8c90

6 files changed

Lines changed: 109 additions & 30 deletions

‎docs/specs/2026-10-05-repoman-phase6-provenance-attribution-design.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# RepoMan Phase 6 — skill provenance, attribution anchor, and #86 close-out design
22

33
**Date:** 2026-10-05
4-
**Status:** Approved (2026-10-05)
4+
**Status:** Approved (2026-10-05). **Partially superseded by
5+
`docs/specs/2026-11-06-attribution-footer-source-and-format-design.md`** (automation#131):
6+
the attribution target is now `rossoctl/repoman` (not `rossoctl/agent-skills`), the footer
7+
is a lowercase markdown link `Generated by repoman [<skill>@<sha>](…)`, and an unresolved
8+
skill emits a linkless footer. The 6a provenance/`_meta` mechanism below still stands; only
9+
the source repo and footer-string shape changed.
510
**Epic:** [#72](https://github.com/rossoctl/automation/issues/72) (Phase 6 = [#77](https://github.com/rossoctl/automation/issues/77))
611
**Also closes:** [#86](https://github.com/rossoctl/automation/issues/86) (deferred pr-review + weekly-report consumer port)
712
**Milestone:** RepoMan v0.1.0

‎docs/specs/2026-11-06-attribution-footer-source-and-format-design.md‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,41 @@ Generated by repoman [<skill>@<sha>](https://github.com/<repo>/blob/<sha>/skills
7373

7474
## Out of scope
7575

76-
- `resolve_skill_meta`'s create-only `_meta` semantics and migration of pre-existing
77-
`_meta` files pinned to `agent-skills` — the `.source` mismatch handling is its own
78-
concern (overlaps repoman#10). This spec only changes the *default* and the *format*;
79-
it does not add `_meta.source`-vs-current-source reconciliation.
8076
- Removing the repoman-native skills from agent-skills (planned separately). This design
8177
is already correct before and after that cleanup because nothing points at agent-skills.
78+
- The broader deploy-layer `_meta` lifecycle (refresh-on-skill-update) beyond the stale-source
79+
case handled here — stays with repoman#10.
80+
81+
### Stale-source `_meta` reconciliation (IN scope — required for #131's "never 404")
82+
83+
`resolve_skill_meta` is create-only and short-circuits on any readable `.version`. Flipping
84+
`SKILL_SOURCE_REPO` without reconciling existing `_meta.<skill>.json` would be a regression:
85+
installs that already ran a program carry a meta pinned to an **agent-skills** SHA, which does
86+
not exist in repoman — so the host flips but the SHA stays, producing a 404 (the exact defect
87+
#131 reports). Fix in the read path: when the stored `.source` differs from the current
88+
`SKILL_SOURCE_REPO`, treat the file as stale and fall through to re-resolution (the existing
89+
`mv`-on-success rewrites both `.version` and `.source`). A matching `.source` stays authoritative.
90+
91+
### Unresolved-provenance footer is LINKLESS (#131 item 4)
92+
93+
When no SHA resolves (skill absent from the source repo — the doc-drift case that opened #131),
94+
the fallback emits `Generated by repoman <skill>` with **no link**, rather than an unverified
95+
`blob/main` URL that may 404.
8296

8397
## Deliverables
8498

85-
1. `scripts/github-api.sh`: `SKILL_SOURCE_REPO` default → `rossoctl/repoman`; both
86-
`skill_attribution` `printf` branches → `repoman` + markdown-link format.
87-
2. Update the unit tests that assert the footer string — `tests/test-skill-meta.sh`,
88-
`tests/test-attribution-consumers.sh`, and `tests/test-weekly-report.sh` (its exact-match
89-
`FALLBACK`) — to the new casing/format, watching them fail first (the old strings) then pass.
90-
3. Re-vendor into `rossoctl/repoman` (separate step/PR; `vendor-engine.sh` run + stamp).
99+
1. `scripts/github-api.sh`: `SKILL_SOURCE_REPO` default → `rossoctl/repoman`; the resolved
100+
`skill_attribution` branch → `repoman` + markdown-link format; the unresolved branch →
101+
linkless `Generated by repoman <skill>`.
102+
2. `scripts/github-api.sh` `resolve_skill_meta`: re-resolve when stored `.source` ≠ current
103+
`SKILL_SOURCE_REPO` (stale-source reconciliation above).
104+
3. Update the footer-asserting tests — `tests/test-skill-meta.sh` (incl. a stale-source-repair
105+
case and the linkless-unresolved case), `tests/test-attribution-consumers.sh`, and
106+
`tests/test-weekly-report.sh` (its exact-match `FALLBACK`) — watching them fail first then pass.
107+
4. Supersede pointer: `docs/specs/2026-10-05-repoman-phase6-provenance-attribution-design.md`
108+
still states the attribution target is `rossoctl/agent-skills` and shows the old footer format;
109+
this spec reverses both, so that spec gets a "superseded by 2026-11-06" note.
110+
5. Re-vendor into `rossoctl/repoman` (separate step/PR; `vendor-engine.sh` run + stamp).
91111

92112
## Acceptance criteria
93113

‎scripts/github-api.sh‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,23 @@ resolve_skill_meta() {
242242
# which overwrites it on success, honoring the spec's self-heal invariant.
243243
if [ -f "$meta_file" ]; then
244244
sha=$(jq -r '.version // empty' "$meta_file" 2>/dev/null)
245-
if [ -n "$sha" ]; then
245+
local stored_source
246+
stored_source=$(jq -r '.source // empty' "$meta_file" 2>/dev/null)
247+
if [ -n "$sha" ] && [ "$stored_source" = "$SKILL_SOURCE_REPO" ]; then
246248
printf '%s' "$sha"
247249
return 0
248250
fi
249-
echo "WARN: $meta_file exists but carries no usable .version (corrupt?); re-resolving provenance." >&2
251+
# A readable .version whose .source no longer matches the current
252+
# SKILL_SOURCE_REPO is STALE (the default flipped underneath it): the pinned
253+
# SHA belongs to the old source and would 404 under the new one. Treat it like
254+
# a corrupt file -- fall through to re-resolution, which rewrites both version
255+
# and source on success (automation#131 — the default flip must not strand
256+
# existing installs on a dead link).
257+
if [ -n "$sha" ]; then
258+
echo "WARN: $meta_file source '$stored_source' != '$SKILL_SOURCE_REPO'; re-resolving provenance." >&2
259+
else
260+
echo "WARN: $meta_file exists but carries no usable .version (corrupt?); re-resolving provenance." >&2
261+
fi
250262
fi
251263

252264
# Resolve the pinned SHA from the canonical source repo's history for this
@@ -287,9 +299,10 @@ resolve_skill_meta() {
287299
#
288300
# Resolves the skill's pinned SHA (via resolve_skill_meta, using the caller's
289301
# own SCRIPT_DIR as the skill directory so it works on every deploy layout) and
290-
# returns the pinned-SHA RepoMan footer. On resolution failure it returns the
291-
# blob/main fallback that pins to the live default branch instead -- additive,
292-
# so a working scan never depends on a reachable GitHub API.
302+
# returns a lowercase markdown footer: 'Generated by repoman [<skill>@<sha>](blob/<sha>)'.
303+
# On resolution failure it returns a LINKLESS footer ('Generated by repoman <skill>')
304+
# rather than an unverified link -- additive, so a working scan never depends on a
305+
# reachable GitHub API.
293306
#
294307
# Usage: footer=$(skill_attribution "link-health-scanner")
295308
# Args:
@@ -306,7 +319,9 @@ skill_attribution() {
306319
printf 'Generated by repoman [%s@%s](https://github.com/%s/blob/%s/skills/%s/SKILL.md).' \
307320
"$skill_name" "${sha:0:7}" "$SKILL_SOURCE_REPO" "$sha" "$skill_name"
308321
else
309-
printf 'Generated by repoman [%s](https://github.com/%s/blob/main/skills/%s/SKILL.md).' \
310-
"$skill_name" "$SKILL_SOURCE_REPO" "$skill_name"
322+
# No SHA resolved: emit a LINKLESS footer rather than an unverified blob/main
323+
# link that may 404 (a skill absent from the source repo — the doc-drift case
324+
# that opened automation#131, item 4). Attribution without a dead link.
325+
printf 'Generated by repoman %s.' "$skill_name"
311326
fi
312327
}

‎tests/test-attribution-consumers.sh‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ export GH_FAIL=1
5959
export REPOMAN_SKILL_DIR="$TMP/fixer-fail"
6060
mkdir -p "$REPOMAN_SKILL_DIR"
6161
footf=$(bash "$SCRIPTS/pr-review-fixer.sh" footer 2>/dev/null)
62+
# Unresolved provenance -> LINKLESS footer (no blob link we cannot verify, #131 item 4).
6263
case "$footf" in
63-
*"blob/main/skills/github-pr-review/SKILL.md"*)
64-
echo "PASS: fixer failure uses blob/main" ;;
65-
*) echo "FAIL: fixer failure uses blob/main: $footf"; fail=1 ;;
64+
*"Generated by repoman github-pr-review"*)
65+
echo "PASS: fixer failure emits linkless footer" ;;
66+
*) echo "FAIL: fixer failure should emit linkless footer: $footf"; fail=1 ;;
6667
esac
6768
case "$footf" in
68-
*@*) echo "FAIL: fixer fallback has no @sha: $footf"; fail=1 ;;
69-
*) echo "PASS: fixer fallback has no @sha" ;;
69+
*http*|*"]("*|*@*) echo "FAIL: fixer fallback must carry no link/@sha: $footf"; fail=1 ;;
70+
*) echo "PASS: fixer fallback has no link/@sha" ;;
7071
esac
7172
check "[ ! -f \"$REPOMAN_SKILL_DIR/_meta.github-pr-review.json\" ]" "fixer failure writes no _meta"
7273

@@ -118,9 +119,12 @@ outf="$TMP/report-fail.md"
118119
bash "$SCRIPTS/weekly-report.sh" --output "$outf" >/dev/null 2>&1
119120
lastf=$(tail -n 1 "$outf")
120121
case "$lastf" in
121-
*"blob/main/skills/github-weekly-report/SKILL.md"*)
122-
echo "PASS: weekly failure uses blob/main" ;;
123-
*) echo "FAIL: weekly failure uses blob/main: $lastf"; fail=1 ;;
122+
*"Generated by repoman github-weekly-report"*)
123+
echo "PASS: weekly failure emits linkless footer" ;;
124+
*) echo "FAIL: weekly failure should emit linkless footer: $lastf"; fail=1 ;;
125+
esac
126+
case "$lastf" in
127+
*http*|*"]("*) echo "FAIL: weekly fallback must carry no link: $lastf"; fail=1 ;;
124128
esac
125129
check "[ ! -f \"$REPOMAN_SKILL_DIR/_meta.github-weekly-report.json\" ]" "weekly failure writes no _meta"
126130

‎tests/test-skill-meta.sh‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,15 @@ sha=$(SKILL_SOURCE_REPO="rossoctl/agent-skills" resolve_skill_meta "$dir2" "$SKI
7171
[ ! -f "$dir2/$META" ] \
7272
|| { echo "FAIL branch2: $META must NOT be written on failure (self-heal retry)"; fail=1; }
7373
foot=$(SCRIPT_DIR="$dir2" SKILL_SOURCE_REPO="rossoctl/agent-skills" skill_attribution "$SKILL" 2>/dev/null)
74+
# Unresolved provenance emits a LINKLESS footer: a SHA could not be resolved, so
75+
# any blob link would be unverified (automation#131 item 4 — never emit a link we
76+
# cannot stand behind). Plain 'Generated by repoman <skill>', no markdown link, no URL.
7477
case "$foot" in
75-
*"Generated by repoman [$SKILL](https://github.com/"*"/blob/main/skills/$SKILL/SKILL.md)."*) ;;
76-
*) echo "FAIL branch2: fallback footer should be the lowercase markdown blob/main form, got: [$foot]"; fail=1 ;;
78+
"Generated by repoman $SKILL."|"Generated by repoman $SKILL") ;;
79+
*) echo "FAIL branch2: unresolved footer should be linkless 'Generated by repoman $SKILL', got: [$foot]"; fail=1 ;;
7780
esac
7881
case "$foot" in
79-
*"@"*) echo "FAIL branch2: fallback footer must NOT carry an @<sha>, got: [$foot]"; fail=1 ;;
82+
*http*|*"]("*|*"@"*) echo "FAIL branch2: unresolved footer must carry no link/@sha, got: [$foot]"; fail=1 ;;
8083
esac
8184

8285
# =============================================================================
@@ -154,5 +157,37 @@ sha2=$(SKILL_SOURCE_REPO="rossoctl/agent-skills" resolve_skill_meta "$dir5" "$SK
154157
[ "$sha2" = "$HEAL_SHA" ] \
155158
|| { echo "FAIL branch5: healed meta should be read back, got [$sha2]"; fail=1; }
156159

160+
# =============================================================================
161+
# Branch 6: a _meta pinned to a DIFFERENT source than the current
162+
# SKILL_SOURCE_REPO is stale (the default flipped underneath it). It must NOT be
163+
# treated as authoritative: re-resolve and rewrite .source, so a footer never
164+
# links a SHA from a repo that is no longer the source (automation#131 — flipping
165+
# the default must not strand old installs on a 404). Regression for Jim's #136
166+
# must-fix.
167+
# =============================================================================
168+
dir6="$TEST_TMPDIR/case6"
169+
mkdir -p "$dir6"
170+
STALE_SHA="235a7f76deadbeef0000000000000000cafebabe" # an agent-skills sha, not in repoman
171+
FRESH_SHA="a0b39d3b00000000000000000000000000000000" # what repoman resolves to now
172+
# Seed a stale meta: version from the OLD source, source=agent-skills.
173+
jq -n --arg v "$STALE_SHA" '{version:$v, source:"rossoctl/agent-skills", installed_at:"2026-10-01"}' \
174+
> "$dir6/$META"
175+
# gh now answers for the NEW (repoman) source.
176+
gh() { printf '%s\n' "$FRESH_SHA"; }
177+
sha=$(SKILL_SOURCE_REPO="rossoctl/repoman" resolve_skill_meta "$dir6" "$SKILL")
178+
[ "$sha" = "$FRESH_SHA" ] \
179+
|| { echo "FAIL branch6: stale-source meta must re-resolve, got [$sha] want [$FRESH_SHA]"; fail=1; }
180+
v6=$(jq -r '.version // empty' "$dir6/$META" 2>/dev/null)
181+
s6=$(jq -r '.source // empty' "$dir6/$META" 2>/dev/null)
182+
[ "$v6" = "$FRESH_SHA" ] \
183+
|| { echo "FAIL branch6: stale meta .version not rewritten, got [$v6]"; fail=1; }
184+
[ "$s6" = "rossoctl/repoman" ] \
185+
|| { echo "FAIL branch6: stale meta .source not rewritten, got [$s6]"; fail=1; }
186+
# A matching-source meta is still authoritative (no needless re-resolve).
187+
gh() { echo "FAIL branch6: gh must NOT be called when .source already matches" >&2; return 1; }
188+
sha_ok=$(SKILL_SOURCE_REPO="rossoctl/repoman" resolve_skill_meta "$dir6" "$SKILL" 2>/dev/null)
189+
[ "$sha_ok" = "$FRESH_SHA" ] \
190+
|| { echo "FAIL branch6: matching-source meta should be read back, got [$sha_ok]"; fail=1; }
191+
157192
unset -f gh
158193
[ "$fail" -eq 0 ] && echo "PASS: skill-meta provenance+attribution" || exit 1

‎tests/test-weekly-report.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ EOF
4141
chmod +x "$TEST_TMPDIR/bin/gh"
4242
export PATH="$TEST_TMPDIR/bin:$PATH"
4343
export REPOMAN_SKILL_DIR="$TEST_TMPDIR/meta"
44-
FALLBACK='Generated by repoman [github-weekly-report](https://github.com/rossoctl/repoman/blob/main/skills/github-weekly-report/SKILL.md).'
44+
FALLBACK='Generated by repoman github-weekly-report.'
4545

4646
# Owner-qualified --repos, no --org. The footer is appended to the file, not stdout.
4747
out="$TEST_TMPDIR/out.md"

0 commit comments

Comments
 (0)