feat(kyberforge): primitive-author and factory-audit support for apm hooks, instructions and prompts #144

Closed
Claude wants to merge 19 commits from feat/primitive-author into main
pull from: feat/primitive-author
Owner

Summary

Closes the gap #94 describes: kyberforge had no author or audit support for three apm primitives (hooks, instructions and prompts), and forge had no route for them.

  • primitive-author (new skill). It authors and improves hooks, instructions and prompts.
    • The shared create/improve procedure lives in SKILL.md.
    • references/{hook,instruction,prompt}.md hold each primitive's boundary gate and Must/Should checklist, and assets/templates/ holds .template files.
    • It closes by running factory-audit inline, then a local-path apm install into a scratch mktemp -d directory with --target set to the package's targets, then the package version bump and commit verification.
  • factory-audit: three new Step 0 flows (hook, instruction, prompt). These follow ADR-0020's merge-siblings rule rather than adding a separate audit skill.
    • Deterministic checks are in scripts/lib-checks-primitive.sh. Judgment checks are in the flow references.
    • Author Must ↔ audit FAIL and Should ↔ SUGGESTION. The flow files document the deliberate deviations and the shell parser's known blind spots.
    • Vale covers instruction and prompt bodies.
  • forge gains a route for apm hooks, instructions and prompts to primitive-author, using the same two-tier clean audit. Its description and body are back within budget.
  • ADR-0029: prompts are thin, user-triggered steering messages. Procedure belongs in a skill. A prompt's description is one plain sentence that names the skills or agents it steers. Its claims are sourced inline.
  • CONTEXT.md gains the terms apm primitive, Prompt, Instruction and Hook.
  • The research docs (plugins/kyberforge/docs/research/docs/microsoft-apm/) are completed and corrected against apm 0.28.0 (pinned upstream at v0.28.0):
    • Copilot hooks are not reshaped.
    • A malformed .claude/settings.json is overwritten on install.
    • Instruction validation only produces warnings.
  • kyberforge's own SessionStart hook:
    • It uses the target-neutral ${PLUGIN_ROOT}. The deployed .claude/settings.json entry is unchanged; this was checked byte for byte against scratch installs.
    • It runs only when CLAUDE_PROJECT_DIR is set, with no cwd fallback, so Copilot and Codex do not run apm update.
    • It is portable and bounded: it falls back to gtimeout and prints a notice when neither timeout tool exists, kills after a 5 s grace (worst case 370 s against the 380 s limit), sets GIT_TERMINAL_PROMPT=0, and uses flock to stop concurrent sessions refreshing at once.
    • ADR-0019 is amended. The README and docs/hooks.md are corrected.
  • Other skills:
    • skill-author's new-skill.sh is portable and safe to retry: it builds in dot-prefixed staging and fails loudly when a repair fails. New skills stay at 0.1.0, and ADR-0022 is amended to match.
    • apm-workflow and agent-author now route hook, instruction and prompt authoring to primitive-author.
    • agent-author skips the version bump when the branch already bumped the package.
    • ADR-0025 is amended for the new flows.
  • Housekeeping. Literal U+FEFF BOM characters in lib-boundary-resolver.sh and validate-adapter.bats are now Python unicode escape sequences, which silences apm's hidden-character warning.

Versions

  • kyberforge 2.0.1 → 2.1.0, and the root executables.allow key moves with it.
  • Catalog 0.5.1 → 0.5.2, with marketplace.json regenerated.
  • Skill versions:
    • factory-audit 1.1.1
    • forge 1.0.2
    • skill-author 1.0.6
    • apm-workflow 1.0.2
    • agent-author 1.0.4
    • primitive-author is new at 0.1.0

Verification

  • Four review and audit rounds. The last one had 10 parallel reviewers: factory-audit on every changed skill and on the hook, plus code, docs and PR-intent review. Every finding is resolved in 9285b29..641ebca.
  • Tests:
    • factory-audit bats: 406/406
    • skill-author bats: 33/33
    • validate-adapter.bats: 42/42
    • test-apm-current-hook.sh: 66/66
    • every other tests/test-*.sh suite passes
  • Pre-commit and pre-push hooks all passed, including apm audit --ci, apm pack --check-clean, the provenance corpus check and the executables allow-key sync. The one remaining gate output is a SUGGESTION that predates this PR: agent-author's body is over the 600-word target, and was before this PR too.

Not in this PR

  • Pre-commit Vale coverage for *.instructions.md and *.prompt.md. The repo has none of these files yet, so check-hooks-apply and test-vale-wrap.sh case 32 reject a hook that matches nothing. The gap is recorded in docs/spec/gates.md.
  • Unverified at runtime: whether Copilot CLI runs nested hook entries or honours matcher, and how strongly Claude avoids routing to a prompt description with no trigger clause.

Fixes #94
Fixes #143

🤖 Generated with Claude Code

https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi

## Summary Closes the gap #94 describes: kyberforge had no author or audit support for three apm primitives (hooks, instructions and prompts), and `forge` had no route for them. - **`primitive-author` (new skill).** It authors and improves hooks, instructions and prompts. - The shared create/improve procedure lives in `SKILL.md`. - `references/{hook,instruction,prompt}.md` hold each primitive's boundary gate and Must/Should checklist, and `assets/templates/` holds `.template` files. - It closes by running `factory-audit` inline, then a local-path `apm install` into a scratch `mktemp -d` directory with `--target` set to the package's targets, then the package version bump and commit verification. - **`factory-audit`: three new Step 0 flows** (hook, instruction, prompt). These follow ADR-0020's merge-siblings rule rather than adding a separate audit skill. - Deterministic checks are in `scripts/lib-checks-primitive.sh`. Judgment checks are in the flow references. - Author Must ↔ audit FAIL and Should ↔ SUGGESTION. The flow files document the deliberate deviations and the shell parser's known blind spots. - Vale covers instruction and prompt bodies. - **`forge`** gains a route for apm hooks, instructions and prompts to `primitive-author`, using the same two-tier clean audit. Its description and body are back within budget. - **ADR-0029: prompts are thin, user-triggered steering messages.** Procedure belongs in a skill. A prompt's description is one plain sentence that names the skills or agents it steers. Its claims are sourced inline. - **`CONTEXT.md`** gains the terms apm primitive, Prompt, Instruction and Hook. - **The research docs** (`plugins/kyberforge/docs/research/docs/microsoft-apm/`) are completed and corrected against apm 0.28.0 (pinned upstream at `v0.28.0`): - Copilot hooks are not reshaped. - A malformed `.claude/settings.json` is overwritten on install. - Instruction validation only produces warnings. - **kyberforge's own SessionStart hook:** - It uses the target-neutral `${PLUGIN_ROOT}`. The deployed `.claude/settings.json` entry is unchanged; this was checked byte for byte against scratch installs. - It runs only when `CLAUDE_PROJECT_DIR` is set, with no cwd fallback, so Copilot and Codex do not run `apm update`. - It is portable and bounded: it falls back to `gtimeout` and prints a notice when neither timeout tool exists, kills after a 5 s grace (worst case 370 s against the 380 s limit), sets `GIT_TERMINAL_PROMPT=0`, and uses `flock` to stop concurrent sessions refreshing at once. - ADR-0019 is amended. The README and `docs/hooks.md` are corrected. - **Other skills:** - skill-author's `new-skill.sh` is portable and safe to retry: it builds in dot-prefixed staging and fails loudly when a repair fails. New skills stay at `0.1.0`, and ADR-0022 is amended to match. - apm-workflow and agent-author now route hook, instruction and prompt authoring to `primitive-author`. - agent-author skips the version bump when the branch already bumped the package. - ADR-0025 is amended for the new flows. - **Housekeeping.** Literal U+FEFF BOM characters in `lib-boundary-resolver.sh` and `validate-adapter.bats` are now Python unicode escape sequences, which silences apm's hidden-character warning. ## Versions - kyberforge 2.0.1 → 2.1.0, and the root `executables.allow` key moves with it. - Catalog 0.5.1 → 0.5.2, with `marketplace.json` regenerated. - Skill versions: - `factory-audit` 1.1.1 - `forge` 1.0.2 - `skill-author` 1.0.6 - `apm-workflow` 1.0.2 - `agent-author` 1.0.4 - `primitive-author` is new at 0.1.0 ## Verification - **Four review and audit rounds.** The last one had 10 parallel reviewers: `factory-audit` on every changed skill and on the hook, plus code, docs and PR-intent review. Every finding is resolved in `9285b29`..`641ebca`. - **Tests:** - `factory-audit` bats: 406/406 - `skill-author` bats: 33/33 - `validate-adapter.bats`: 42/42 - `test-apm-current-hook.sh`: 66/66 - every other `tests/test-*.sh` suite passes - **Pre-commit and pre-push hooks** all passed, including `apm audit --ci`, `apm pack --check-clean`, the provenance corpus check and the executables allow-key sync. The one remaining gate output is a SUGGESTION that predates this PR: `agent-author`'s body is over the 600-word target, and was before this PR too. ## Not in this PR - Pre-commit Vale coverage for `*.instructions.md` and `*.prompt.md`. The repo has none of these files yet, so `check-hooks-apply` and `test-vale-wrap.sh` case 32 reject a hook that matches nothing. The gap is recorded in `docs/spec/gates.md`. - **Unverified at runtime:** whether Copilot CLI runs nested hook entries or honours `matcher`, and how strongly Claude avoids routing to a prompt description with no trigger clause. Fixes #94 Fixes #143 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Claude added the Kind/Enhancement
Priority
Medium
3
labels 2026-09-28 18:48:43 +00:00
Claude added 9 commits 2026-09-28 18:48:43 +00:00
Re-verify the three primitive schema docs against the installed apm-cli
0.28.0 source and live installs, and add an authoring checklist to each.

Corrections to the earlier docs:
- Copilot hooks are not reshaped: events are renamed, paths rewritten and
  version: 1 added, but command/timeout are not renamed to bash/timeoutSec.
- A malformed .claude/settings.json is overwritten on install, losing
  user content.
- Instruction validate() messages are warnings only; apm compile
  --validate never fails on them.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Record the house rule for the apm prompt primitive: a single-intent,
user-triggered, parameterised message that steers existing skills or
agents by name and carries no procedure of its own. It also sets the
prompt description contract (one plain sentence, no trigger clause).

Add the glossary terms settled in the same grill to CONTEXT.md: apm
primitive, Prompt, Instruction and Hook. Narrow the Skill entry's Avoid
list and log the prompt ambiguity as resolved.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
factory-audit gains three Step 0 rows and flows for the apm primitives
that have no container of their own: a .json file under hooks/, a
*.instructions.md and a *.prompt.md. apm validates almost none of them
(invalid hook JSON is skipped silently, instruction validate() only
warns, input: names are never checked against ${input:x}), so the
deterministic checks live in a new scripts/lib-checks-primitive.sh,
wired into validate.sh's path-shape detection. Each check and tier
traces to the Authoring checklists in the microsoft-apm research docs.

- Hook: JSON/shape/event-list checks mirroring the Copilot payload
  validator, never-firing event casing, missing/escaping/non-executable
  scripts (FAIL); deprecated filename routing and ${CLAUDE_PLUGIN_ROOT}
  (SUGGESTION).
- Instruction: location, frontmatter, description, body, stem clash
  (FAIL); missing or list applyTo and unread keys (SUGGESTION).
- Prompt: location/name, frontmatter, description, input names, the
  upstream `- name: x` docs bug, declared-vs-used ${input:x} (FAIL);
  ADR-0029 description length and trigger clause, dropped keys,
  camelCase aliases, argument-hint with input (SUGGESTION). Whether a
  prompt carries procedure is judgment in prompt-flow.md, not a script
  heuristic.

Vale now lints *.instructions.md and *.prompt.md with the Kyberforge
style; test-vale-wrap.sh gains their probe rows. New
tests/validate-primitive.bats (31 cases). kyberforge 2.0.1 -> 2.1.0 with
the executables.allow key, catalog 0.5.1 -> 0.5.2, marketplace.json
regenerated.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
New skill that creates or improves an apm hook, instruction or prompt.
Its SKILL.md holds the shared procedure (dispatch on primitive, boundary
gate, create-or-improve, factory-audit close); one self-contained
reference per primitive carries its gate, checklist and template, drawn
from the microsoft-apm research docs and ADR-0029.

forge gains a route row sending a hook, instruction or prompt to
primitive-author through author-routes.md, and no longer lists hooks as
unroutable. factory-audit's description adds the primitive-author
boundary now that the target resolves.

Fixes #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
primitive-author:
- description excludes read-only review (-> factory-audit)
- validation Gotcha now matches the research: compile never reads
  prompts, install fails only on a bad Copilot hook payload and warns on
  prompt input names and dropped keys
- instruction fold-in into AGENTS.md/CLAUDE.md stated as conditional on
  dedup and --force-instructions
- hook checklist gains the wrapped-shape Must, drops hardlinks, notes
  why executable is stricter than the research, and states the
  separate Copilot-targeted package route instead of a blanket "don't"
- prompt Must 5 keeps the research's Copilot-only-key exception; adds
  model-slug and 250-char Shoulds; descriptions name skills or agents
- placeholder instruction covers both FILL IN and FILL_IN_ tokens

factory-audit: hardlink FAIL scoped to instructions and prompts
(find_hook_files skips symlinks only), with bats cases; prompt-flow
description rubric names skills or agents.

forge: version-bump, apm-routes and sources references updated for the
primitive route.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Second clean-context audit found author Must/Should and audit FAIL/SUGGESTION
tiers drifting apart, and author Musts the audit never checked.

- factory-audit: FAIL on absolute or bare relative hook script paths, an
  applyTo present but empty, and unbalanced braces/brackets in applyTo;
  judgment steps for dependency stem collisions, helper .json in hook dirs,
  unresolvable instruction links, prompt model slugs and second-person
  bodies; an unmatched glob drops to SUGGESTION; deliberate tier deviations
  recorded in hook-flow.md; validate.sh --help lists the three new modes;
  DescriptionOpener message no longer prescribes "Use when".
- primitive-author: deprecated routing, extra prompt keys and the prompt
  description contract become Shoulds; hook Musts gain "contributes an
  entry", no bare relative paths, and executable-when-run-directly;
  prompt Must 1 covers hardlinks; Vale prose FAILs resolved at close.
- forge: say "hook, instruction or prompt" rather than "apm primitive".

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Switch the SessionStart hook to apm's target-neutral ${PLUGIN_ROOT} token.
Two scratch packages differing only in the token deploy byte-identical
SessionStart entries with apm 0.28.0, matching the committed
.claude/settings.json, so the deployed output does not change. The test
pin in tests/test-apm-current-hook.sh moves with it.

Correct the claim that Copilot loads no hooks from kyberforge. targets:
is package-wide, so apm also writes .github/hooks/kyberforge-hooks.json
(nested shape passed through, runtime unverified) and merges into
.codex/hooks.json when .codex/ exists. Recorded as accepted in an
ADR-0019 amendment dated 2026-09-28; README and docs/hooks.md updated.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
lib-boundary-resolver.sh and the provider-adapter-author BOM fixtures
carried literal U+FEFF characters, which apm install reports as "files
contain hidden characters". Both sites feed the text to Python, which
interprets the '' escape identically, so behaviour is unchanged:
the resolver's strip_bom and all five validate-adapter BOM cases pass.

No core package bump: the fixture writes the same bytes, so the edit is
not substantive under the apm-workflow version policy.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
deployment-modes.md told authors to use ${CLAUDE_PLUGIN_ROOT} in hook
commands. Hook authoring now belongs to primitive-author, which
specifies the target-neutral ${PLUGIN_ROOT}; point there instead.

Refs #94

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Claude added this to the Skills & Agents milestone 2026-09-28 18:49:01 +00:00
Defame1297 added 3 commits 2026-09-29 05:45:58 +00:00
- factory-audit: no-op hooks, ./ after interpreters, split-quote and
  spaced ${PLUGIN_ROOT} paths, camelCase events in Claude-targeted flat
  files, case-insensitive routing stems, and non-string YAML keys are
  now caught; input: forms and prompt boundary clauses align with
  primitive-author; bats 347 -> 367
- primitive-author: routing forms, quoting guidance, install exit on
  hidden Unicode, argument-hint exception
- forge: drop duplicated gotcha, fit description and body budgets (#143)
- skill-author: primitive-author boundary, Claude-only env vars
- hook: exit unless CLAUDE_PROJECT_DIR is set, so Copilot/Codex never
  run apm update; ADR-0019 correction, ADR-0025 amendment, docs fixes

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
- factory-audit: ./ and bare/absolute script checks scoped to command
  position (no false FAILs on ./src or printf); hook sources limited to
  .apm/hooks or package-root hooks/; Kiro-aware lowercase events;
  unfilled template placeholders FAIL; repo-only instructions FAIL at
  any scope; Vale description FAIL documented; bats 367 -> 378
- primitive-author: split-quote/spaced paths and handler-less entries
  promoted to Must; Step 4.2 renders into a scratch consumer instead of
  a no-op dry run; dispatch and gate hand-off trimmed
- apm-workflow 1.0.2: mutual boundary with primitive-author
- forge: no double package bump; gotcha wording
- skill-author: create keeps seeded 0.1.0 (ADR-0022); portable,
  retry-safe new-skill.sh; template and flow consistency fixes
- hook docs: cite the ADR-0019 correction; guard caveat

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
- factory-audit: hook events judged per deployed target after apm's
  rename (Claude/Copilot event sets FAIL, others SUGGESTION); Claude
  plugin layouts accepted as hook sources; interpreter options and
  sh -c strings checked; bats 378 -> 386
- primitive-author: Must 4/5 match the audit; reference hand-back
  points at the right steps; Step 4.2 --target all fallback
- skill-author: new-skill.sh repair only on the template marker line,
  so complete skills stay a no-op; provenance and calibration text
- forge: restore "already named" qualifier; drop false HITL claim
- apm-workflow: token example uses an env var
- docs/hooks.md: the apm-hooks.json sidecar is committed, not ignored

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Author
Owner

Review and audit loop: 3 rounds

I ran three rounds of review and fixes on this PR. Each round had:

  • a code review of the branch diff,
  • a clean-context factory-audit of every changed primitive: primitive-author, factory-audit, forge, skill-author, apm-workflow, and kyberforge's hooks.json,
  • fixes through skill-author / primitive-author, followed by the full test suite.

The audits used the branch copy of factory-audit. The deployed copy is older than this PR and cannot audit hooks, instructions or prompts.

Round Findings Commit
1 Review: 4 MEDIUM, 5 LOW. Audits: 2 FAIL, 18 SUGGESTION df28351
2 Review: 2 MEDIUM, 1 LOW. Audits: 5 FAIL, 30 SUGGESTION (deeper passes, some on code older than this PR) 965208b
3 Review: 3 MEDIUM, 2 LOW. Audits: 1 FAIL, 11 SUGGESTION 5d0f988

After round 3, every agent that applied fixes re-audited its own changes and got PASS; two of those results still carry an INFO note. No fourth independent round was run, because the cap was three rounds.

Behaviour changes

  • kyberforge SessionStart hook: now exits unless CLAUDE_PROJECT_DIR is set.
    • apm deploys this hook to Copilot and Codex too. In a project that consumes it, apm has already written the lockfile, so the lockfile check never stopped it. That meant it would run apm update --yes in Copilot and Codex sessions.
    • ADR-0019 now has a correction. The README and docs/hooks.md are corrected, and there are new tests for the variable being unset or empty.
  • factory-audit: hook checks now catch real breakage. Each of these now fails:
    • a hook with no entries, or an entry with no handler;
    • a missing script run through an interpreter, including one behind interpreter options (bash -e, sh -c "…");
    • a ${PLUGIN_ROOT} path with the quotes split or a space in it, which apm does not rewrite;
    • an event name that a target never fires. This is checked per deployed target, after apm renames events for that target (_HOOK_EVENT_MAP).
  • factory-audit: false positives removed. Commands like npx prettier ./src and printf '.\n' no longer FAIL, and Claude-plugin layouts (plugin.json with no apm.yml) are accepted.
  • factory-audit: two more cases now fail.
    • Unfilled template placeholders.
    • Any instruction whose rule only applies to this repo (it belongs in AGENTS.md).
  • Author and audit severities now line up. A primitive-author "must" rule is a factory-audit FAIL, and a "should" rule is a SUGGESTION. Where a script cannot decide, the difference is documented in the flow files.
  • primitive-author Step 4.2: apm install --dry-run replaced. The dry run showed neither what each target receives nor the branch's own files. The step now renders into a throwaway consumer with a local-path install, which was verified with apm 0.28.0.
  • forge: the description and body now fit their length budgets (closes #143), and it no longer bumps the package version twice.
  • skill-author:
    • Creating a skill keeps the seeded 0.1.0 (ADR-0022).
    • new-skill.sh works with both GNU and BSD sed. A failed run no longer leaves a half-built scaffold, and re-running it on a finished skill changes nothing.
  • apm-workflow 1.0.2: its description now sends hook, instruction and prompt work to primitive-author, so the two skills no longer overlap.

Verification

  • The factory-audit bats suite passes 386/386; it had 347 tests at the start.
  • tests/run-tests.sh passes 21/21 suites.
  • All pre-push gates passed, including apm audit --ci, apm pack --check-clean, the provenance corpus check and the version-bump check.
  • Neither .claude/settings.json nor apm.lock.yaml was touched.

Decisions worth a look

  • Event lists for Claude and Copilot come from their live docs (fetched 2026-09-28) and are recorded in factory-audit's sources.md. These lists will need updating when those docs change.
  • Copilot docs name the event userPromptSubmitted, but apm renames it to userPromptSubmit. The audit accepts apm's name because authors cannot change the rename. This may be an apm bug worth reporting upstream.
  • forge description: it uses the form If named, use instead: skill -> …, at exactly 250 characters. That fits the budget and keeps the "already named" qualifier.

Still open

  • The deployed .claude/skills/factory-audit stays stale until this merges to main and is reinstalled.
  • ADR-0019 lines 207–208 still say the sidecar is gitignored. The 2026-09-16 correction directly below them supersedes that.
  • #94 was closed before this PR merged.
  • The PR description's version and test counts are from before these rounds. apm-workflow 1.0.2 is also new since then.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi

## Review and audit loop: 3 rounds I ran three rounds of review and fixes on this PR. Each round had: - a code review of the branch diff, - a clean-context `factory-audit` of every changed primitive: `primitive-author`, `factory-audit`, `forge`, `skill-author`, `apm-workflow`, and kyberforge's `hooks.json`, - fixes through `skill-author` / `primitive-author`, followed by the full test suite. The audits used the branch copy of `factory-audit`. The deployed copy is older than this PR and cannot audit hooks, instructions or prompts. | Round | Findings | Commit | |---|---|---| | 1 | Review: 4 MEDIUM, 5 LOW. Audits: 2 FAIL, 18 SUGGESTION | `df28351` | | 2 | Review: 2 MEDIUM, 1 LOW. Audits: 5 FAIL, 30 SUGGESTION (deeper passes, some on code older than this PR) | `965208b` | | 3 | Review: 3 MEDIUM, 2 LOW. Audits: 1 FAIL, 11 SUGGESTION | `5d0f988` | After round 3, every agent that applied fixes re-audited its own changes and got PASS; two of those results still carry an INFO note. No fourth independent round was run, because the cap was three rounds. ### Behaviour changes - **kyberforge SessionStart hook: now exits unless `CLAUDE_PROJECT_DIR` is set.** - apm deploys this hook to Copilot and Codex too. In a project that consumes it, apm has already written the lockfile, so the lockfile check never stopped it. That meant it would run `apm update --yes` in Copilot and Codex sessions. - ADR-0019 now has a correction. The README and `docs/hooks.md` are corrected, and there are new tests for the variable being unset or empty. - **factory-audit: hook checks now catch real breakage.** Each of these now fails: - a hook with no entries, or an entry with no handler; - a missing script run through an interpreter, including one behind interpreter options (`bash -e`, `sh -c "…"`); - a `${PLUGIN_ROOT}` path with the quotes split or a space in it, which apm does not rewrite; - an event name that a target never fires. This is checked per deployed target, after apm renames events for that target (`_HOOK_EVENT_MAP`). - **factory-audit: false positives removed.** Commands like `npx prettier ./src` and `printf '.\n'` no longer FAIL, and Claude-plugin layouts (`plugin.json` with no `apm.yml`) are accepted. - **factory-audit: two more cases now fail.** - Unfilled template placeholders. - Any instruction whose rule only applies to this repo (it belongs in AGENTS.md). - **Author and audit severities now line up.** A primitive-author "must" rule is a factory-audit FAIL, and a "should" rule is a SUGGESTION. Where a script cannot decide, the difference is documented in the flow files. - **primitive-author Step 4.2: `apm install --dry-run` replaced.** The dry run showed neither what each target receives nor the branch's own files. The step now renders into a throwaway consumer with a local-path install, which was verified with apm 0.28.0. - **forge:** the description and body now fit their length budgets (closes #143), and it no longer bumps the package version twice. - **skill-author:** - Creating a skill keeps the seeded `0.1.0` (ADR-0022). - `new-skill.sh` works with both GNU and BSD `sed`. A failed run no longer leaves a half-built scaffold, and re-running it on a finished skill changes nothing. - **apm-workflow 1.0.2:** its description now sends hook, instruction and prompt work to `primitive-author`, so the two skills no longer overlap. ### Verification - The factory-audit bats suite passes 386/386; it had 347 tests at the start. - `tests/run-tests.sh` passes 21/21 suites. - All pre-push gates passed, including `apm audit --ci`, `apm pack --check-clean`, the provenance corpus check and the version-bump check. - Neither `.claude/settings.json` nor `apm.lock.yaml` was touched. ### Decisions worth a look - **Event lists for Claude and Copilot** come from their live docs (fetched 2026-09-28) and are recorded in factory-audit's `sources.md`. These lists will need updating when those docs change. - **Copilot docs name the event `userPromptSubmitted`, but apm renames it to `userPromptSubmit`.** The audit accepts apm's name because authors cannot change the rename. This may be an apm bug worth reporting upstream. - **forge description:** it uses the form `If named, use instead: skill -> …`, at exactly 250 characters. That fits the budget and keeps the "already named" qualifier. ### Still open - The deployed `.claude/skills/factory-audit` stays stale until this merges to `main` and is reinstalled. - ADR-0019 lines 207–208 still say the sidecar is gitignored. The 2026-09-16 correction directly below them supersedes that. - #94 was closed before this PR merged. - The PR description's version and test counts are from before these rounds. apm-workflow 1.0.2 is also new since then. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Defame1297 added 7 commits 2026-09-29 08:08:58 +00:00
Why: PR #144 review round 4 reproduced hooks referencing $PLUGIN_ROOT or
${PLUGIN_ROOT} without a path separator passing the audit, although apm
only rewrites ${TOKEN}/ and the deployed hook points nowhere.

- FAIL unbraced or unseparated plugin-root tokens
- check the exec bit for scripts run via an interpreter -c string
- skip env NAME=value prefixes when locating bare relative paths
- correct input: and empty-frontmatter messages, depth-walk applyTo braces
- INFO on unrecognised targets; failing-case tests for untested checks
- document tiers, blind spots and crash exit 2; drop rtk from portable flow
- restore the after-a-hand-edit trigger; pin upstream apm source URL

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Why: repair_placeholders ran inside a command substitution, so a failing
sed left an emptied file behind and the script still exited 0 reporting
success.

- write via tmp file and abort on sed or mv failure
- re-check the target before moving staging into place
- stage in a dot-prefixed mktemp dir so a killed run leaves no fake skill
- source apm claims in deployment-modes.md; tag untyped code blocks

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
- annotate the research Must demoted to hook Should 12; narrow Must 5 note
- extend Must 6 to scripts run via an interpreter -c string
- add a fallback dispatch row and comma-joined --target guidance
- fall back when agentsmd-author is not installed
- add the apm-workflow boundary; pin upstream apm source URL

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
- say apm hook/instruction/prompt so pre-commit hooks stay with pc-author
- restore the idea-without-a-home trigger
- cite checkpoints forge's apm routes actually hit
- diff version bumps against the remote default branch

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
- reach the MCP ${VAR} secrets rule from the compile flow
- restore the Gotcha remedy for type: coverage
- route .apm/instructions and .apm/prompts to primitive-author
- agent-author: add the primitive-author boundary and the already-bumped
  skip, bump to 1.0.4

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Why: stock macOS has no timeout(1), so the hook exited silently and never
checked the install, the silent staleness ADR-0019 exists to prevent.

- fall back to gtimeout, else emit a notice instead of running apm unbounded
- kill after a 5s grace; worst case 370s stays under the 380s host limit
- export GIT_TERMINAL_PROMPT=0 so a credential prompt cannot hang startup
- serialise concurrent refreshes with flock when available

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
- cite the VS Code prompt-file deprecation and the verbatim apm quote
- add ADR-0029 boundary-clause enforcement and Consequences
- mark superseded ADR-0019 passages; record neutral lock advice, source
  fork and reloadSkills, amend for the hook hardening
- move the ADR-0025 amendment out of the Decision list
- amend ADR-0022 for create keeping 0.1.0
- fix hooks.md merge and event claims, README guard caveat, gates.md Vale
  globs, and pin the research registry URL

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Author
Owner

Review round 4: findings resolved

Ten parallel reviewers covered this round:

  • factory-audit on every changed skill (factory-audit, primitive-author, skill-author, forge, apm-workflow) and on the kyberforge hook
  • code review of lib-checks-primitive.sh
  • code review of the scripts and tests, including the gates
  • docs and ADR consistency
  • PR intent against the earlier rounds

There were no blockers: 4 majors, about 30 minors and a batch of nits. All of them are fixed in 7 commits (9285b29..641ebca), each behaviour fix with a test that failed before it.

Majors

Finding Fix
Unbraced $PLUGIN_ROOT and ${PLUGIN_ROOT} without a following / passed the hook audit. apm does not rewrite them, so the deployed hook points nowhere. 9285b29: these now FAIL, with tests.
new-skill.sh repair ran inside $(...), so a failing sed emptied the file and the script still exited 0. 36723ae: writes go through a tmp file and the script aborts on failure, with a failing-sed stub test.
ADR-0029's VS Code "Agent Host" deprecation claim had no source. 641ebca: now cited to code.visualstudio.com prompt-files docs. The apm quote now uses the verbatim "a prompt is a program for an LLM" from the "What is APM?" page.
The PR description was stale, and #143 was fixed here but not linked. Description updated, and Fixes #143 added.

Minors and nits by area

  • factory-audit (9285b29):
    • Checks:
      • the exec bit is now checked for scripts run from an interpreter's -c string;
      • env NAME=value prefixes are skipped when looking for bare relative paths;
      • the input: and empty-frontmatter messages are corrected;
      • brace balance in applyTo is walked by depth;
      • unknown targets: values get an INFO.
    • Tests: about 20 failing-case tests for checks that had none, including crash exit 2.
    • Docs: hook-flow is split into lists and records the tier deviations and the parser's blind spots; rtk is gone from the instruction flow.
    • Provenance: the apm source URL is pinned upstream.
  • skill-author (36723ae):
    • new-skill.sh: it re-checks for the target before the mv, builds in dot-prefixed mktemp staging, and its repair message is honest about what it did.
    • Docs: the apm claims in deployment-modes.md are now sourced.
  • primitive-author (fd86ee4):
    • Tier moves are annotated.
    • Must 6 covers scripts run from a -c string.
    • Step 1 has a fallback row, and Step 4.2 says to join targets with commas.
    • There is a fallback when agentsmd-author is missing, and an apm-workflow boundary.
  • forge (06b01f8):
    • The route says apm hook so pre-commit hook requests stay with pc-author.
    • The "idea without a home" trigger is back.
    • The apm-route rationale is accurate.
    • Version bumps are diffed against origin/main.
  • apm-workflow and agent-author (1e8f057):
    • The MCP ${VAR} secrets rule now reaches the compile flow, and the Gotcha remedy is restored.
    • Instructions and prompts route to primitive-author.
    • agent-author gets the primitive-author boundary and the skip when the branch already bumped (1.0.4).
  • Hook (4a4b598):
    • It falls back to gtimeout, or prints a notice, since stock macOS has no timeout.
    • It uses timeout -k 5, so the worst case is 370 s against 380 s.
    • It sets GIT_TERMINAL_PROMPT=0.
    • A flock lock stops concurrent refreshes.
    • Tests go from 48 to 66.
  • Docs (641ebca):
    • ADR-0019: superseded passages are marked, the neutral lock advice is recorded, fork and reloadSkills are cited to the Claude Code hooks docs, and there is an amendment for the hook hardening.
    • ADR-0025's amendment is moved out of the Decision list.
    • ADR-0022 is amended for create keeping 0.1.0.
    • ADR-0029 gets its full Enforcement list and a Consequences section.
    • Also fixed: the hooks.md claims about merging and events, the README guard caveat, the gates.md Vale globs, and the research URL pins.

Verification

  • Tests:
    • factory-audit bats: 406/406
    • skill-author bats: 33/33
    • validate-adapter.bats: 42/42
    • test-apm-current-hook.sh: 66/66
    • all tests/test-*.sh suites pass
  • Hooks:
    • Pre-commit: clean.
    • Pre-push: all passed on push, including apm audit --ci and apm pack --check-clean.

Open for a maintainer decision

  • #94 was closed by hand before merge. Reopen it so Fixes #94 closes it on merge, or leave it closed on purpose.
  • Squash-merge recommended. The round 1–3 commits bundle several areas each.
  • agent-author's body is 692 words, over the 600 target. This SUGGESTION predates this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi

## Review round 4: findings resolved Ten parallel reviewers covered this round: - `factory-audit` on every changed skill (factory-audit, primitive-author, skill-author, forge, apm-workflow) and on the kyberforge hook - code review of `lib-checks-primitive.sh` - code review of the scripts and tests, including the gates - docs and ADR consistency - PR intent against the earlier rounds There were no blockers: 4 majors, about 30 minors and a batch of nits. All of them are fixed in 7 commits (`9285b29`..`641ebca`), each behaviour fix with a test that failed before it. ### Majors | Finding | Fix | |---|---| | Unbraced `$PLUGIN_ROOT` and `${PLUGIN_ROOT}` without a following `/` passed the hook audit. apm does not rewrite them, so the deployed hook points nowhere. | `9285b29`: these now FAIL, with tests. | | `new-skill.sh` repair ran inside `$(...)`, so a failing `sed` emptied the file and the script still exited 0. | `36723ae`: writes go through a tmp file and the script aborts on failure, with a failing-`sed` stub test. | | ADR-0029's VS Code "Agent Host" deprecation claim had no source. | `641ebca`: now cited to code.visualstudio.com prompt-files docs. The apm quote now uses the verbatim "a prompt is a program for an LLM" from the "What is APM?" page. | | The PR description was stale, and #143 was fixed here but not linked. | Description updated, and `Fixes #143` added. | ### Minors and nits by area - **factory-audit** (`9285b29`): - Checks: - the exec bit is now checked for scripts run from an interpreter's `-c` string; - `env NAME=value` prefixes are skipped when looking for bare relative paths; - the `input:` and empty-frontmatter messages are corrected; - brace balance in `applyTo` is walked by depth; - unknown `targets:` values get an INFO. - Tests: about 20 failing-case tests for checks that had none, including crash exit 2. - Docs: hook-flow is split into lists and records the tier deviations and the parser's blind spots; `rtk` is gone from the instruction flow. - Provenance: the apm source URL is pinned upstream. - **skill-author** (`36723ae`): - `new-skill.sh`: it re-checks for the target before the `mv`, builds in dot-prefixed `mktemp` staging, and its repair message is honest about what it did. - Docs: the apm claims in `deployment-modes.md` are now sourced. - **primitive-author** (`fd86ee4`): - Tier moves are annotated. - Must 6 covers scripts run from a `-c` string. - Step 1 has a fallback row, and Step 4.2 says to join targets with commas. - There is a fallback when `agentsmd-author` is missing, and an `apm-workflow` boundary. - **forge** (`06b01f8`): - The route says `apm hook` so pre-commit hook requests stay with `pc-author`. - The "idea without a home" trigger is back. - The apm-route rationale is accurate. - Version bumps are diffed against `origin/main`. - **apm-workflow and agent-author** (`1e8f057`): - The MCP `${VAR}` secrets rule now reaches the compile flow, and the Gotcha remedy is restored. - Instructions and prompts route to `primitive-author`. - agent-author gets the `primitive-author` boundary and the skip when the branch already bumped (1.0.4). - **Hook** (`4a4b598`): - It falls back to `gtimeout`, or prints a notice, since stock macOS has no `timeout`. - It uses `timeout -k 5`, so the worst case is 370 s against 380 s. - It sets `GIT_TERMINAL_PROMPT=0`. - A `flock` lock stops concurrent refreshes. - Tests go from 48 to 66. - **Docs** (`641ebca`): - ADR-0019: superseded passages are marked, the neutral lock advice is recorded, `fork` and `reloadSkills` are cited to the Claude Code hooks docs, and there is an amendment for the hook hardening. - ADR-0025's amendment is moved out of the Decision list. - ADR-0022 is amended for create keeping 0.1.0. - ADR-0029 gets its full Enforcement list and a Consequences section. - Also fixed: the `hooks.md` claims about merging and events, the README guard caveat, the gates.md Vale globs, and the research URL pins. ### Verification - **Tests:** - factory-audit bats: 406/406 - skill-author bats: 33/33 - `validate-adapter.bats`: 42/42 - `test-apm-current-hook.sh`: 66/66 - all `tests/test-*.sh` suites pass - **Hooks:** - Pre-commit: clean. - Pre-push: all passed on push, including `apm audit --ci` and `apm pack --check-clean`. ### Open for a maintainer decision - **#94 was closed by hand before merge.** Reopen it so `Fixes #94` closes it on merge, or leave it closed on purpose. - **Squash-merge recommended.** The round 1–3 commits bundle several areas each. - **agent-author's body is 692 words**, over the 600 target. This SUGGESTION predates this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Author
Owner

Closing without merging. We're starting over on #94 and #143 with a different approach, so this branch is being deleted.

Closing without merging. We're starting over on #94 and #143 with a different approach, so this branch is being deleted.
Defame1297 closed this pull request 2026-09-29 20:21:36 +00:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Holocron#144