Skip to content

feat(claude): user_config defaults in command/agent prompts + governance alignment scan#396

Open
ErbolTakhirov wants to merge 1 commit into
tractorjuice:mainfrom
ErbolTakhirov:feat/userconfig-wiring-v2
Open

feat(claude): user_config defaults in command/agent prompts + governance alignment scan#396
ErbolTakhirov wants to merge 1 commit into
tractorjuice:mainfrom
ErbolTakhirov:feat/userconfig-wiring-v2

Conversation

@ErbolTakhirov
Copy link
Copy Markdown

Summary

This PR is a scoped v2 follow-up to the previous feat/userconfig-wiring attempt, rebuilt from current main to avoid cross-PR regressions.

It keeps only the intended architecture:

  • Add user_config-based defaulting guidance in Claude command bodies.
  • Add the same defaulting guidance in Claude agent bodies.
  • Add arckit-claude/hooks/governance-scan.mjs checks for plugin default alignment gaps (Classification / Owner).

Included in This PR

1) Command Body Updates (Claude)

Command text now includes guidance to:

  • Default [CLASSIFICATION] and [OWNER_NAME_AND_ROLE] from \${user_config.*} where available.
  • Prompt the user when a default is unavailable.
  • Apply Governance Framework Mode logic (UK Gov vs Generic) in body instructions.

2) Agent Body Updates (Claude)

Agent prompts follow the same pattern:

  • Use \${user_config.*} defaults in prompt body logic.
  • Fall back to user prompt when defaults are missing.
  • Preserve governance-mode behavior in agent instructions.

3) Governance Scan Hook

Introduces arckit-claude/hooks/governance-scan.mjs behavior that:

  • Reads plugin defaults from CLAUDE_PLUGIN_OPTION_* environment variables.
  • Adds a Plugin Default Alignment Gaps section.
  • Flags artifact-level metadata mismatches for:
    • Classification
    • Owner

Explicitly Out of Scope

To keep this PR merge-safe and aligned with prior review feedback, the following are intentionally excluded:

  • Template-level \${user_config.*} substitution changes.
  • Bulk template rewrites across plugin trees.
  • scripts/converter.py placeholder rewrite/copy flows.
  • Any arckit-paperclip/ script reintroductions or related regressions.
  • Changes to:
    • arckit-claude/commands/pages.md
    • arckit-claude/templates/pages-template.html
    • arckit-claude/hooks/allow-mcp-tools.mjs
  • Deletions/overwrites of recently merged guide/docs work.

Rationale

user_config interpolation is reliable in command/agent body text, but not in arbitrary template file contents loaded at runtime.
This PR therefore applies defaults only where substitution is guaranteed and avoids template-level substitution risk.

Validation Notes

  • Rebuilt from current main to avoid silent reverts.
  • Diff intentionally constrained to:
    • Claude command bodies
    • Claude agent bodies
    • governance scan hook
  • No template/converter/paperclip regression surface included.

Copy link
Copy Markdown
Owner

@tractorjuice tractorjuice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes — must not merge as-is

The intent (default Document Control fields from user_config) is sensible, but this PR is based on a 112-commit-stale tip of main despite claiming "rebuilt from current main to avoid cross-PR regressions." Merging would silently revert four shipped features.

Blockers

  1. Stale base — reverts large amounts of merged work. Merge-base with main is 7f34c35c (between v4.7/v4.8). The diff against hooks.json undoes:

    • PR #467 / v4.20.0 — args: string[] exec-form migration (all 25+ entries flipped back to shell-string form, contradicting the v2.1.139+ floor we declared).
    • PR #470continueOnBlock: true on observational PostToolUse hooks (stripped).
    • PR #475 / issue #472PostCompactpostcompact-rehydrate.mjs event registration (deleted).
    • PR #446 / v4.18.2 — PreToolUse: Agentinject-agent-context.mjs (deleted; this is the fix for the Skill/Agent-dispatch context-injection gap).
    • PR #430 — telemetry on .* PostToolUse + the entire TaskCreated event (deleted).
    • Provenance stamping for Write/Edit on projects/** (deleted).
    • `allow-plugin-internals.mjs` PreToolUse entry (deleted).

    Plus the curated `description` in `hooks.json` is reverted to a stale string. Rebase onto current `main` before any other review can be meaningful.

  2. Dead 748-line hook. `arckit-claude/hooks/governance-scan.mjs` is added but never registered in `hooks.json` — no matcher block for it exists. The script will never run. Substantively, ~700 of those 748 lines duplicate the existing analyze pre-processor logic in `graph-inject.mjs` (coverage tables, requirements inventory, vendor scan, risk severity). Only the ~30-line "Plugin Default Alignment Gaps" block is novel; that section, if we want it, belongs inside `graph-inject.mjs`, not as a new top-level hook.

  3. Wrong `user_config` field for owner. Across ~40 commands and 8 agents, `[OWNER_NAME_AND_ROLE]` is being defaulted to `${user_config.organisation_name}`. The schema in `plugin.json` defines `organisation_name` as the org string (e.g. "HM Revenue & Customs"); `[OWNER_NAME_AND_ROLE]` is a person + role (e.g. "Jane Doe, Chief Architect"). They're not interchangeable. Either (a) drop this default and keep the prompt-the-user path, or (b) add a new `default_owner` field to `userConfig`. The same misuse appears in the new hook's "Owner missing or does not reference configured organisation" check (`governance-scan.mjs:694–700`).

Important issues

  1. Generic mode on UK-by-definition commands is meaningless. `tcop`, `service-assessment`, `secure`, `atrs`, `ai-playbook` are UK-specific commands by name and purpose. Adding an "if Generic, skip GDS/TCoP/NCSC CAF references" branch hollows them out (a TCoP review with TCoP removed isn't a thing). Generic-mode toggles make sense on the framework-neutral commands (`requirements`, `adr`, `principles`, `risk`, `sobc`, `data-model`, `diagram`, etc.) but not the UK-compliance commands — non-UK jurisdictions are already served by the community overlays. Drop the mode block from the UK-compliance commands.

  2. `secure.md` Step-10 numbering collision. Two steps are renumbered to `10.` after the edits (existing "Government Cyber Security Profession alignment" and "Cyber Security Standard compliance"). Verify the numbered list still renders cleanly.

Minor

  1. The PR body's "rebuilt from current `main`" claim should be removed or corrected — it materially misled reviewers on first pass.
  2. Consider gating the `user_config.organisation_name` default behind explicit user consent on first use — silently stamping an org name into every doc owner field is a surprise.

What I'd want before re-review

  • Rebase onto current `main` and re-diff `hooks.json` (should be zero lines changed there unless you're actually adding a new registered hook).
  • Either register `governance-scan.mjs` or fold its novel "Plugin Default Alignment Gaps" section into `graph-inject.mjs` (and delete the rest as duplication).
  • Decide on `[OWNER_NAME_AND_ROLE]`: drop the `organisation_name` default, or add a new `default_owner` field. Don't conflate the two.
  • Strip the governance-mode block from the UK-compliance commands; keep it on the framework-neutral ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants