# Canonical Rules Registry
# Defines all enterprise rules with their scope and rendering targets.

schema_version: "1.0"
last_updated: "2026-07-20"

rules:

  - rule_id: authoritative-governance-mandatory
    display_name: Authoritative Governance (Mandatory)
    version: "2.0.0"
    status: active
    scope: global
    always_apply: true
    source: rules/authoritative-governance-mandatory.mdc
    description: >
      Authority pack loading, preflight resolution, pre-code gate,
      model handoff, skill dedup prevention. Applied on every response.
    activation_tags:
      - always
    adapter_rendering:
      cursor: "~/.cursor/rules/authoritative-governance-mandatory.mdc"
      claude: "CLAUDE.md header section"
      cli: "preflight check step"
    architect_os_eligible: true

  - rule_id: model-governance
    display_name: Model Governance Routing
    version: "1.1.0"
    status: active
    scope: project
    always_apply: true
    source: null  # Generated per-project by bootstrap-ai-governance (see Step 7 template)
    description: >
      Single canonical workspace surface for model routing: strategy vs implementation,
      optional per-turn [MODEL ROUTING] advisory, primary-author anti-drift, token
      guidance. Merge with MODEL_ROUTING.yaml when using authority packs. Do not
      add parallel rule files for the same concern — extend this rule via bootstrap
      skill or pack profiles.
    activation_tags:
      - governance
    adapter_rendering:
      cursor: ".cursor/rules/model-governance.mdc"
      claude: "CLAUDE.md model routing section"
      cli: "model selection flag"
    architect_os_eligible: true

  - rule_id: project-identity
    display_name: Project Identity
    version: "1.0.0"
    status: active
    scope: project
    always_apply: true
    source: null  # Generated per-project
    description: >
      Defines project role in the IP pipeline (proving ground / hub /
      product). Generated with project-specific context.
    activation_tags:
      - pipeline
    adapter_rendering:
      cursor: ".cursor/rules/project-identity.mdc"
      claude: "CLAUDE.md identity section"
      cli: "environment variable"
    architect_os_eligible: false

  - rule_id: proactive-skill-coordinator
    display_name: Proactive Skill Coordinator
    version: "1.0.0"
    status: active
    scope: global
    always_apply: true
    source: rules/proactive-skill-coordinator.mdc
    description: >
      Always-on rule that detects context signals in user messages and
      suggests matching canonical skills automatically. Includes passive
      cost tracking, session lifecycle hints, and skill discovery menu.
      Makes the skills ecosystem discoverable without trigger phrases.
    activation_tags:
      - always
      - coordination
      - discovery
    adapter_rendering:
      cursor: ".cursor/rules/proactive-skill-coordinator.mdc"
      claude: "CLAUDE.md skill coordinator section"
      cli: "proactive suggestions"
    architect_os_eligible: true

  - rule_id: authority-pack-enforcement
    display_name: Authority Pack Enforcement
    version: "1.0.0"
    status: active
    scope: global
    always_apply: true
    source: rules/authority-pack-enforcement.mdc
    description: >
      Thin enforcement shim that loads .project-ai/ authority pack,
      prevents duplicate skill creation via registry check, and
      directs candidate skills to .project-ai/candidates/.
      Gracefully no-ops if no authority pack exists.
    activation_tags:
      - always
      - governance
    adapter_rendering:
      cursor: ".cursor/rules/authority-pack-enforcement.mdc"
      claude: "CLAUDE.md authority pack section"
      cli: "preflight authority check"
    architect_os_eligible: true

  - rule_id: report-accuracy
    display_name: Report Accuracy Protocol
    version: "1.0.0"
    status: active
    scope: global
    always_apply: true
    source: rules/report-accuracy.mdc
    description: >
      Mandatory output verification protocol for agent-generated reports.
      Enforces computed values over estimates, methodology consistency,
      aggregation integrity, attribution confidence levels, and
      self-verification passes before delivery. Output-side counterpart
      to the Pre-Code Gate.
    activation_tags:
      - always
      - governance
      - accuracy
      - audit
    adapter_rendering:
      cursor: ".cursor/rules/report-accuracy.mdc"
      claude: "CLAUDE.md report accuracy section"
      cli: "post-analysis verification check"
    architect_os_eligible: true

  - rule_id: metadata-evidence
    display_name: Metadata vs. Evidence Protocol
    version: "2.0.0"
    status: active
    scope: global
    always_apply: true
    source: rules/metadata-evidence.mdc
    description: >
      Global always-apply guardrail. Declarative artifacts (profiles,
      summaries, checkpoints, docs, todo lists) are hypotheses until
      verified against executable evidence (git, filesystem, runtime,
      authenticated MCP, platform CLIs). Gates any Vector 1 -> action
      path across all skills. Root-cause fix for failure classes G3
      (metadata-over-evidence), G4 (distribution drift), G5 (resume-work
      blindness), G6 (tool affordance mismatch), and G7 (external-state
      drift). v2.0.0 adds Trigger D External State Claim Discipline:
      Action Verb Taxonomy (D.1), Mandatory Claim Block template (D.2),
      Forbidden Phrases enumeration (D.3), Self-Check Protocol (D.4),
      canonical probe library reference (D.5), audit trail spec (D.6),
      and failure-mode documentation (D.7). Paired with a project
      addendum template (rules/metadata-evidence-PROJECT-TEMPLATE.mdc),
      a canonical probe library (tools/probes/), an agentTurnEnd hook
      template (templates/cursor-hooks/scan-external-state-claims.ps1),
      and a Pester test suite (tests/MetadataEvidence.Tests.ps1).
    activation_tags:
      - always
      - governance
      - accuracy
      - hallucination-prevention
      - external-state-claims
    adapter_rendering:
      cursor: ".cursor/rules/metadata-evidence.mdc"
      claude: "CLAUDE.md metadata-vs-evidence section"
      cli: "pre-action evidence probe"
    architect_os_eligible: true
    coordinates_with:
      - anti-hallucination-agent
      - agent-post-mortem
      - governance-enforcement
      - report-verifier
    related_artifacts:
      - templates/cursor-rules/metadata-evidence-PROJECT-TEMPLATE.mdc
      - tools/probes/probe-deploy-state.ps1
      - tools/probes/lib/
      - templates/cursor-hooks/scan-external-state-claims.ps1
      - tests/MetadataEvidence.Tests.ps1

  - rule_id: model-autopilot
    display_name: Model Autopilot (IDE-aware switch banner)
    version: "1.2.0"
    status: active
    scope: project
    always_apply: true
    source: .cursor/rules/model-autopilot.mdc
    description: >
      When MODEL_AUTOPILOT.yaml is enabled, agents finish one step and emit
      STOP — SWITCH MODEL with handoff text and IDE-specific picker labels.
      Supports both new-chat and same-chat continuity modes plus a per-task
      scope gate that prevents silent review_only/design_only escalation into
      code_and_test work. Picker labels per IDE come from
      @enterprise-skills/core IDE_MODEL_MAPS (run
      `enterprise-skills autopilot ides --ide <ide>` for the current map).
    activation_tags:
      - always
      - model-routing
    adapter_rendering:
      cursor: ".cursor/rules/model-autopilot.mdc + .cursor/rules/model-autopilot-cursor.mdc"
      vscode: ".github/copilot-instructions.md (autopilot section) + docs/MODEL_AUTOPILOT_VSCODE.md"
      claude: "CLAUDE.md (autopilot section)"
      windsurf: ".windsurfrules (autopilot section)"
      jetbrains: ".idea/enterprise-skills/MODEL_AUTOPILOT.md"
      neovim: ".nvim/enterprise-skills/MODEL_AUTOPILOT.md"
      xcode: ".enterprise-skills/MODEL_AUTOPILOT.md"
      cli: "docs/MODEL_AUTOPILOT_GUIDE.md"
    architect_os_eligible: true
    coordinates_with:
      - model-governance
      - governance-enforcement
    related_artifacts:
      - .project-ai/MODEL_AUTOPILOT.yaml
      - docs/MODEL_AUTOPILOT.md
      - docs/MODEL_AUTOPILOT_USER_GUIDE.md
      - scripts/model-autopilot.ps1
      - packages/core/src/ide-model-map.ts
      - packages/adapters/src/model-autopilot-section.ts

  - rule_id: model-transition-enforcement
    display_name: Model Transition Enforcement
    version: "1.0.0"
    status: active
    scope: project
    always_apply: true
    source: rules/model-transition-enforcement.mdc
    description: >
      Model-transition enforcement: successor models must load the handoff stack
      (canonical state -> handoff overlay -> engineering charter -> live state ->
      history) before any work, treat the engineering charter as binding (amend
      only with operator approval + recorded evidence), and never re-derive or
      duplicate the handoff. Deployed with placeholders filled by the
      model-transition-handoff skill. Distinct from model-autopilot (per-task
      model routing) and model-governance (strategy-vs-implementation routing).
    activation_tags:
      - governance
      - model-transition
    adapter_rendering:
      cursor: ".cursor/rules/model-transition-enforcement.mdc"
      claude: "CLAUDE.md model-transition section"
      cli: "session-start transition check"
    architect_os_eligible: true
    coordinates_with:
      - governance-enforcement
      - model-transition-handoff

  - rule_id: model-conditioning-precedence
    display_name: Model-Conditioning Precedence
    version: "1.0.0"
    status: active
    scope: project
    always_apply: true
    source: rules/model-conditioning-precedence.mdc
    description: >
      Two-tier prompt-conditioning precedence: the Tier-1 operating posture is
      constant and binding across every model; Tier-2 per-model conditioning is
      subordinate, swaps with the active model, and can never override a Tier-1
      standard. Re-render Tier 2 on a model switch via
      `enterprise-skills autopilot conditioning`; an unrecognized model resolves
      to the generic profile (dataset may be behind) — never invent guidance.
      Deployed by bootstrap-ai-governance Step 7D.
    activation_tags:
      - governance
      - model-conditioning
    adapter_rendering:
      cursor: ".cursor/rules/model-conditioning-precedence.mdc"
      claude: "CLAUDE.md model-conditioning section"
      cli: "autopilot conditioning output"
    architect_os_eligible: true
    coordinates_with:
      - governance-enforcement
      - model-autopilot
      - model-transition-handoff

  - rule_id: test-first-implementation
    display_name: Test-First Implementation
    version: "1.0.0"
    status: active
    scope: global
    always_apply: true
    source: rules/test-first-implementation.mdc
    description: >
      Test-first discipline for agent-written code: specify behavior in a
      failing test before implementing; every behavior change ships with a
      test change or an explicit stated reason; bug fixes start with a
      reproducing test. Pairs with the release classifier's
      code-without-tests flag (risk policy 1.2.0) — the flag lands in the
      signed decision record. Deliberately guidance-plus-flag, never claimed
      as TDD enforcement (test-first ordering is unverifiable from a diff).
    activation_tags:
      - always
      - testing
    adapter_rendering:
      cursor: "~/.cursor/rules/test-first-implementation.mdc"
      claude: "CLAUDE.md testing discipline section"
      cli: "classifier code-without-tests label in govern output"
    architect_os_eligible: true
    coordinates_with:
      - governance-enforcement
      - test-gap-analyzer
      - bootstrap-testing
