Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .agents/skills/skill-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ path) is the only writer of `~/.claude/skills/`.

1. **List** the staged drafts:
```bash
skill-review list # tab-separated: <slug>\t<description>
skill-review list # tab-separated: <slug>\t<digest>\t<description>
```
If "(no staged drafts)", stop and say so.

Expand All @@ -39,8 +39,8 @@ path) is the only writer of `~/.claude/skills/`.
steps lets the agent follow the summary and skip the body. Start with "Use when ...".

3. **Decide per draft** (always show the user the draft and your read before acting):
- Approve -> `skill-review promote <slug>` (moves it into `~/.claude/skills/<slug>/`; refuses to
overwrite a live skill without `--force`).
- Approve -> `skill-review promote <slug> <digest>` (moves it into `~/.claude/skills/<slug>/`; refuses
digest mismatch or overwriting a live skill without `--force`).
- Reject -> `skill-review reject <slug>` (moves it to `_rejected/`, recoverable, never deleted).

4. **Report** what was promoted vs rejected, and any draft you left staged for the user to decide.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ GENERATED , do not hand-edit. Regenerate: `bash lib/registry/feature-registry.sh
| `memory-tidy` | `[I]` | Use when auditing, consolidating, or cleaning a repo's .claude/memory store, "dọn memory", "memory tidy", the biweekly memory audit, dupl… | SPEC-208, SPEC-225, SPEC-249 | test-audit-cadence.sh, test-audit-verdict-grammar.sh, test-memory-tidy-contract.sh +1 |
| `observe` | `[I]` | Query and render the kit's control plane (fleet runs, spend, debt; backed by lib/bench) from an agent session. NOT for your own Claude Code… | SPEC-033, SPEC-052, SPEC-128 +17 | smoke.sh, test-bin-forwarders.sh, test-kit-contract.sh +4 |
| `repo-hygiene` | `[I]` | Use for the whole-repo decay audit, "run the repo-hygiene loop", "what has rotted in this repo", "is anything mis-shelved", "dọn repo", o… | SPEC-256 | test-audit-cadence.sh, test-audit-verdict-grammar.sh, test-repohygiene.sh |
| `skill-review` | `[I]` | Review and promote skill drafts that skill-curator staged from past sessions. Use when the user runs /skill-review, says "review my skill d… | SPEC-218, SPEC-285 | test-async.sh, test-bin-forwarders.sh, test-egress-visible.sh +7 |
| `skill-review` | `[I]` | Review and promote skill drafts that skill-curator staged from past sessions. Use when the user runs /skill-review, says "review my skill d… | SPEC-218, SPEC-285 | test-async.sh, test-bin-forwarders.sh, test-egress-visible.sh +8 |
| `stats` | `[I]` | Query or render ledger state and propose backlog rows off anomalies. Use when asked to SEE it -- "show me the ledger state", "my waived gat… | SPEC-001, SPEC-182, SPEC-192 +24 | test-anomalies-advisor.sh, test-bin-forwarders.sh, test-board-brief.sh +39 |
| `system-design` | `[I]` | Own the repo's system design document at docs/SYSTEM-DESIGN.md: its format, its updates per feature, and rendering it as a UML drawing set … | SPEC-292, SPEC-426, SPEC-427 | test-doc-figures.sh, test-system-design.sh |
| `topology-drift` | `[I]` | Maintainer-only. Use to audit THIS KIT's OWN feature estate against its path map, "run the topology-drift loop", "feature inventory drift".… | SPEC-225, SPEC-235, SPEC-237 | test-audit-cadence.sh, test-audit-scanner-contract.sh, test-audit-verdict-grammar.sh +1 |
Expand Down
140 changes: 140 additions & 0 deletions docs/verification/skill-promote-reviewed-digest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Verification: skill-promote-reviewed-digest

Proof of done for digest-pinned skill promotion (atomic private move out of staging, strict entry classification with mode bit and draft-contained relative symlinks, no inherited-temp recursive delete, no post-promote retire step hiding newer drafts) and safe `curate_restore` (slug validation, live-target refusal with no nesting, and guarded `manifest.tsv` row removal).

## Green runs

### Fix round 1 on /bin/bash (3.2.57) and bash 5 (5.3.20), temp HOME

```
Command: HOME="$H" /bin/bash lib/skill-curator/tests/test-promote-digest.sh && HOME="$H" /opt/homebrew/bin/bash lib/skill-curator/tests/test-promote-digest.sh
Exit: 0
Output:
[1] list prints 12-hex digest; added file and symlink target change it
ok: 12-hex digests change on added file and symlink target (b5e281e2a95f -> a438b47fd3f0 -> 0924f274b843 -> 50101cd74165)
[2] re-stage between list and promote is refused (rc=4), nothing moves
ok: re-staged draft refused (rc=4), nothing moved
[3] no digest, --force in digest slot, and wrong digest all refuse (rc=4)
ok: missing/wrong digest refused (rc=4), draft untouched
[4] right digest promotes exact reviewed draft including extra files and symlinks
ok: right digest promoted draft with extra file and symlink intact
[5] --force after digest replaces live skill and backs up previous live copy
ok: --force after digest replaced live skill and backed up old copy
[6] re-stage during promotion (PATH stub) publishes reviewed copy, newer draft stays visible
ok: mid-digest re-stage: live got V1, newer V2 stayed staged and listed
[7] late re-stage during promote (mkdir stub, Fault 2) does not hide newer draft
ok: late re-stage: live got V1, newer V2 not hidden by retire step
[8] re-stage during refused promotion preserves BOTH old and new drafts
ok: refusal during re-stage preserved both V2-REF-NEW and V1-REF-OLD
[9] inherited temp variable does not recursively delete unrelated folder (Fault 1)
ok: inherited temp env left canary folder untouched; no recursive rm in promote.sh
[10] auto mode promotes eligible draft from private copy and preserves concurrent newer draft
ok: auto mode published V1 from private copy, kept newer V2 staged, skipped ineligible
[11] curate_restore refuses over a live skill (rc=5), no nesting, manifest unchanged
ok: restore over live skill refused (rc=5), no nesting, manifest unchanged
[12] normal curate_restore moves archive back and removes only its manifest row
ok: normal restore moved skill back and pruned only its exact manifest row
[13] file with newline in name added after list is refused (rc=4), not installed
ok: newline-named file refused (rc=4), nothing installed
[14] fifo added after list is refused (rc=4), not installed
ok: fifo refused (rc=4), nothing installed
[15] chmod +x after list changes digest and is refused (rc=4), not installed
ok: chmod +x refused (rc=4), nothing installed
[16] absolute symlink target swap after list is refused (rc=4), not installed
ok: absolute symlink refused (rc=4), swapped target not installed
[17] curate_restore refuses traversal, slash, empty, and leading-dash slugs
ok: curate_restore refused invalid slugs (rc=2), live skill stayed inside skills/
test-promote-digest: all 17 passed (identical on /bin/bash 3.2.57 and bash 5.3.20)
Verdict: PASS
```

```
Command: HOME="$H" /bin/bash lib/skill-curator/tests/test-promote.sh && HOME="$H" /bin/bash lib/skill-curator/tests/test-curate.sh && HOME="$H" /opt/homebrew/bin/bash lib/skill-curator/tests/test-promote.sh && HOME="$H" /opt/homebrew/bin/bash lib/skill-curator/tests/test-curate.sh
Exit: 0
Output:
test-promote: all 11 passed (/bin/bash 3.2.57 and bash 5.3.20)
test-curate: all 11 passed (/bin/bash 3.2.57 and bash 5.3.20)
Verdict: PASS
```

```
Command: HOME="$H" tests/run-all.sh --changed e75b5b2d --time (bash 5.3.20) and --changed origin/master --time (/bin/bash 3.2.57)
Exit: 0 (all 12 lib-skill-curator suites, test-meta-docs-registry 123/123, test-no-personal-paths 3/3, test-no-scattered-ids 9/9, test-skills-root, test-kit-contract, and 51/52 suites pass in run-all on bash 5.3.20; test-flick timed out under host load 385 in run-all and passed standalone 346/346 on both bash 5.3.20 and /bin/bash 3.2.57; test-board-registry-env 13/13 and test-repohygiene 100/100 are pre-existing bash-4+ suites that pass on bash 5.3.20)
Output:
lib-skill-curator-test-async ok
lib-skill-curator-test-curate ok
lib-skill-curator-test-hook-async ok
lib-skill-curator-test-install ok
lib-skill-curator-test-promote-digest ok
lib-skill-curator-test-promote ok
lib-skill-curator-test-reentrancy ok
lib-skill-curator-test-reviewer ok
lib-skill-curator-test-signal-gate ok
lib-skill-curator-test-staging-gate ok
lib-skill-curator-test-surface ok
lib-skill-curator-test-transcript-parse ok
test-meta-docs-registry ok
flick: 346 passed, 0 failed (/bin/bash 3.2.57 and bash 5.3.20)
Verdict: PASS
```

## Negative controls

### Baseline on origin/master (before initial fix)

```
Command: bash lib/skill-curator/tests/test-promote-digest.sh
Exit: 1
Output:
FAIL: digest sensitivity failed: d1='first draft' d2='first draft' d3='first draft' d4='first draft'
FAIL: re-stage not refused cleanly (rc=0, live=beta)
FAIL: bad-digest refusal wrong (none=2 flag=2 wrong=2)
FAIL: --force behavior wrong (noforce=4 force=4)
FAIL: mid-digest re-stage failed (rc=0, list='alpha replacement')
FAIL: late re-stage hid or lost newer draft (rc=0, list='alpha replacement')
FAIL: refusal during re-stage lost a draft (rc=0)
FAIL: auto mode wrong (rc=0)
FAIL: restore over live skill failed (rc=0, nested=live-one
FAIL: normal restore wrong (rc=0, manifest='live-one 2026-01-01T00:00:00+0000 umb
test-promote-digest: 2 passed, 10 FAILED
Verdict: RED
```

### Fix round 1 red-first run (before digest-else and curate_restore slug fixes)

```
Command: HOME="$H" /bin/bash lib/skill-curator/tests/test-promote-digest.sh && HOME="$H" /opt/homebrew/bin/bash lib/skill-curator/tests/test-promote-digest.sh
Exit: 1
Output:
FAIL: newline-named file bypassed digest (rc=0)
FAIL: fifo bypassed digest (rc=0)
FAIL: chmod +x bypassed digest (rc=0)
FAIL: absolute symlink bypassed digest (rc=0, dig='cd5d134b11a1')
FAIL: curate_restore accepted an invalid slug or moved live skill out
test-promote-digest: 12 passed, 5 FAILED
Verdict: RED
```

### Planted faults on a temp sandbox copy of the fixed code

| Fault | Mutation | Exit | Failing cases |
|---|---|---|---|
| A | Disable digest comparison in `promote.sh` | 1 | `test-promote-digest: 9 passed, 3 FAILED` (re-stage, wrong digest, refusal re-stage) |
| B | Remove live-exists guard in `curate_restore` | 1 | `test-promote-digest: 10 passed, 2 FAILED` (restore over live skill nested, manifest drift) |
| C | Re-introduce inherited `_PTMP` removal in `promote_one` | 1 | `test-promote-digest: 11 passed, 1 FAILED` (canary folder deleted) |
| D | Re-introduce post-promote retire move of `$staged` | 1 | `test-promote-digest: 10 passed, 2 FAILED` (mid-digest and late re-stage hid newer draft) |

```
Command: planted-fault sandbox runs A, B, C, D against lib/skill-curator/tests/test-promote-digest.sh
Exit: 1
Output:
Fault A: test-promote-digest: 9 passed, 3 FAILED
Fault B: test-promote-digest: 10 passed, 2 FAILED
Fault C: test-promote-digest: 11 passed, 1 FAILED
Fault D: test-promote-digest: 10 passed, 2 FAILED
Verdict: RED
```

## Rollback

Revert the commits on this branch (`git revert <sha>`). No data migration, hook change, or live skill mutation occurs; staged drafts remain under `skill-proposals/` and archived skills under `skills/_archive/`.
12 changes: 6 additions & 6 deletions lib/skill-curator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ settings.json.
After a session stages drafts, inspect status and review them:

```bash
bin/skill-improve status # staged-draft count + reviewer runs + 7-day loop spend
bin/skill-review list # one line per draft: <slug>\t<description>
bin/skill-review promote <slug> # vet (writing-skills) then move into ~/.claude/skills/<slug>/
bin/skill-review promote <slug> --force # replace an existing live skill (backs old copy to _replaced/)
bin/skill-review reject <slug> # move to skill-proposals/_rejected/<slug>/ (recoverable)
bin/skill-improve status # staged-draft count + reviewer runs + 7-day loop spend
bin/skill-review list # one line per draft: <slug>\t<digest>\t<description>
bin/skill-review promote <slug> <digest> # vet (writing-skills) then move into ~/.claude/skills/<slug>/
bin/skill-review promote <slug> <digest> --force # replace an existing live skill (backs old copy to _replaced/)
bin/skill-review reject <slug> # move to skill-proposals/_rejected/<slug>/ (recoverable)
```

Or run `/skill-review` (the skill) for the guided, vet-each-draft flow.

Promote exit codes: `2` no such draft, `3` secret-shaped string found (scrub it first), `4` live skill already exists (re-run with `--force` after reading the live skill), `5` move/mkdir failure.
Promote exit codes: `2` no such draft, `3` secret-shaped string found (scrub it first), `4` missing/mismatched digest or live skill already exists (re-run with `--force` after reading the live skill), `5` move/mkdir failure.

**Gotchas:**
- `deploy/install.sh` aborts if `settings.json` is invalid JSON, after backing it up to `settings.json.bak-<ts>`. The reviewer only fires on a real session end or compaction, so `status` stays empty until a substantial session finishes.
Expand Down
4 changes: 2 additions & 2 deletions lib/skill-curator/bin/skill-review
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

case "${1:-list}" in
list) promote_list ;;
promote) promote_one "${2:-}" "${3:-}" ;;
promote) promote_one "${2:-}" "${3:-}" "${4:-}" ;;
reject) promote_reject "${2:-}" ;;
auto) promote_auto ;;
*) echo "usage: skill-review {list|promote <slug> [--force]|reject <slug>|auto}" >&2; exit 2 ;;
*) echo "usage: skill-review {list|promote <slug> <digest> [--force]|reject <slug>|auto}" >&2; exit 2 ;;
esac
6 changes: 6 additions & 0 deletions lib/skill-curator/lib/curate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,18 @@ curate_run() {
# curate_restore <name>: reverse an archive (git mv back, or mv on a non-git host).
curate_restore() {
local name="${1:-}"; [ -n "$name" ] || { echo "restore: need a skill name" >&2; return 2; }
case "$name" in .*|-*|*/*) echo "restore: invalid skill name '$name'" >&2; return 2 ;; esac
local arc="$SKILL_CURATOR_SKILLS_DIR/_archive/$name"
[ -d "$arc" ] || { echo "restore: '$name' is not in _archive/" >&2; return 2; }
local dest="$SKILL_CURATOR_SKILLS_DIR/$name" mf="$SKILL_CURATOR_SKILLS_DIR/_archive/manifest.tsv" kept
[ ! -e "$dest" ] && [ ! -L "$dest" ] || { echo "restore: REFUSED, live skill '$name' already exists" >&2; return 5; }
if git -C "$SKILL_CURATOR_SKILLS_DIR" rev-parse --git-dir >/dev/null 2>&1; then
git -C "$SKILL_CURATOR_SKILLS_DIR" mv "_archive/$name" "$name" 2>/dev/null || mv "$arc" "$SKILL_CURATOR_SKILLS_DIR/$name" 2>/dev/null || { echo "restore: move failed" >&2; return 5; }
else
mv "$arc" "$SKILL_CURATOR_SKILLS_DIR/$name" 2>/dev/null || { echo "restore: move failed" >&2; return 5; }
fi
if [ -f "$mf" ] && kept="$(NAME="$name" awk -F'\t' '($1 "") != (ENVIRON["NAME"] "")' "$mf" 2>/dev/null)"; then
printf '%s' "${kept:+$kept$'\n'}" > "$mf"
fi
echo "restore: '$name' <- _archive/"; si_log "curate: restored '$name' from _archive/"
}
Loading
Loading