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
merge into: Mortis:main
Mortis:main
Mortis:research/copilot-cli-agents
Mortis:research/team-structures
Mortis:research/enforcement-hooks
Mortis:research/team-patterns
Mortis:research/existing-infra-skills
Mortis:feat/66-wire-gitea-mcp-config
No Reviewers
Labels
Clear labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Status/Needs Triage
Status/Ready for Agent
Status/Ready for Human
Wayfinder/Grilling
Wayfinder/Map
Wayfinder/Prototype
Wayfinder/Research
Wayfinder/Task
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Maintainer needs to evaluate this issue
Fully specified, ready for an AFK agent
Requires human implementation
Wayfinder ticket (HITL): decision made in conversation
Wayfinder map: index of decisions for an effort
Wayfinder ticket (HITL): cheap artifact to react to
Wayfinder ticket (AFK): research a fact a decision waits on
Wayfinder ticket: work that unblocks a decision (or build work when the map's Notes allow)
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Milestone
No items
No Milestone
Skills & Agents
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mortis/Holocron#144
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Closes the gap #94 describes: kyberforge had no author or audit support for three apm primitives (hooks, instructions and prompts), and
forgehad no route for them.primitive-author(new skill). It authors and improves hooks, instructions and prompts.SKILL.md.references/{hook,instruction,prompt}.mdhold each primitive's boundary gate and Must/Should checklist, andassets/templates/holds.templatefiles.factory-auditinline, then a local-pathapm installinto a scratchmktemp -ddirectory with--targetset 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.scripts/lib-checks-primitive.sh. Judgment checks are in the flow references.forgegains a route for apm hooks, instructions and prompts toprimitive-author, using the same two-tier clean audit. Its description and body are back within budget.CONTEXT.mdgains the terms apm primitive, Prompt, Instruction and Hook.plugins/kyberforge/docs/research/docs/microsoft-apm/) are completed and corrected against apm 0.28.0 (pinned upstream atv0.28.0):.claude/settings.jsonis overwritten on install.${PLUGIN_ROOT}. The deployed.claude/settings.jsonentry is unchanged; this was checked byte for byte against scratch installs.CLAUDE_PROJECT_DIRis set, with no cwd fallback, so Copilot and Codex do not runapm update.gtimeoutand prints a notice when neither timeout tool exists, kills after a 5 s grace (worst case 370 s against the 380 s limit), setsGIT_TERMINAL_PROMPT=0, and usesflockto stop concurrent sessions refreshing at once.docs/hooks.mdare corrected.new-skill.shis portable and safe to retry: it builds in dot-prefixed staging and fails loudly when a repair fails. New skills stay at0.1.0, and ADR-0022 is amended to match.primitive-author.lib-boundary-resolver.shandvalidate-adapter.batsare now Python unicode escape sequences, which silences apm's hidden-character warning.Versions
executables.allowkey moves with it.marketplace.jsonregenerated.factory-audit1.1.1forge1.0.2skill-author1.0.6apm-workflow1.0.2agent-author1.0.4primitive-authoris new at 0.1.0Verification
factory-auditon every changed skill and on the hook, plus code, docs and PR-intent review. Every finding is resolved in9285b29..641ebca.factory-auditbats: 406/406skill-authorbats: 33/33validate-adapter.bats: 42/42test-apm-current-hook.sh: 66/66tests/test-*.shsuite passesapm 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
*.instructions.mdand*.prompt.md. The repo has none of these files yet, socheck-hooks-applyandtest-vale-wrap.shcase 32 reject a hook that matches nothing. The gap is recorded indocs/spec/gates.md.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
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_01KkT7RSDwDbmrM9T34b6sTiSwitch 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_01KkT7RSDwDbmrM9T34b6sTideployment-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- 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_01KkT7RSDwDbmrM9T34b6sTiReview and audit loop: 3 rounds
I ran three rounds of review and fixes on this PR. Each round had:
factory-auditof every changed primitive:primitive-author,factory-audit,forge,skill-author,apm-workflow, and kyberforge'shooks.json,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.df28351965208b5d0f988After 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
CLAUDE_PROJECT_DIRis set.apm update --yesin Copilot and Codex sessions.docs/hooks.mdare corrected, and there are new tests for the variable being unset or empty.bash -e,sh -c "…");${PLUGIN_ROOT}path with the quotes split or a space in it, which apm does not rewrite;_HOOK_EVENT_MAP).npx prettier ./srcandprintf '.\n'no longer FAIL, and Claude-plugin layouts (plugin.jsonwith noapm.yml) are accepted.apm install --dry-runreplaced. 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.0.1.0(ADR-0022).new-skill.shworks with both GNU and BSDsed. A failed run no longer leaves a half-built scaffold, and re-running it on a finished skill changes nothing.primitive-author, so the two skills no longer overlap.Verification
tests/run-tests.shpasses 21/21 suites.apm audit --ci,apm pack --check-clean, the provenance corpus check and the version-bump check..claude/settings.jsonnorapm.lock.yamlwas touched.Decisions worth a look
sources.md. These lists will need updating when those docs change.userPromptSubmitted, but apm renames it touserPromptSubmit. The audit accepts apm's name because authors cannot change the rename. This may be an apm bug worth reporting upstream.If named, use instead: skill -> …, at exactly 250 characters. That fits the budget and keeps the "already named" qualifier.Still open
.claude/skills/factory-auditstays stale until this merges tomainand is reinstalled.🤖 Generated with Claude Code
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_01KkT7RSDwDbmrM9T34b6sTiReview round 4: findings resolved
Ten parallel reviewers covered this round:
factory-auditon every changed skill (factory-audit, primitive-author, skill-author, forge, apm-workflow) and on the kyberforge hooklib-checks-primitive.shThere 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
$PLUGIN_ROOTand${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.shrepair ran inside$(...), so a failingsedemptied the file and the script still exited 0.36723ae: writes go through a tmp file and the script aborts on failure, with a failing-sedstub test.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.Fixes #143added.Minors and nits by area
9285b29):-cstring;env NAME=valueprefixes are skipped when looking for bare relative paths;input:and empty-frontmatter messages are corrected;applyTois walked by depth;targets:values get an INFO.rtkis gone from the instruction flow.36723ae):new-skill.sh: it re-checks for the target before themv, builds in dot-prefixedmktempstaging, and its repair message is honest about what it did.deployment-modes.mdare now sourced.fd86ee4):-cstring.agentsmd-authoris missing, and anapm-workflowboundary.06b01f8):apm hookso pre-commit hook requests stay withpc-author.origin/main.1e8f057):${VAR}secrets rule now reaches the compile flow, and the Gotcha remedy is restored.primitive-author.primitive-authorboundary and the skip when the branch already bumped (1.0.4).4a4b598):gtimeout, or prints a notice, since stock macOS has notimeout.timeout -k 5, so the worst case is 370 s against 380 s.GIT_TERMINAL_PROMPT=0.flocklock stops concurrent refreshes.641ebca):forkandreloadSkillsare cited to the Claude Code hooks docs, and there is an amendment for the hook hardening.hooks.mdclaims about merging and events, the README guard caveat, the gates.md Vale globs, and the research URL pins.Verification
validate-adapter.bats: 42/42test-apm-current-hook.sh: 66/66tests/test-*.shsuites passapm audit --ciandapm pack --check-clean.Open for a maintainer decision
Fixes #94closes it on merge, or leave it closed on purpose.🤖 Generated with Claude Code
https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
Closing without merging. We're starting over on #94 and #143 with a different approach, so this branch is being deleted.
Pull request closed