Decapod Docs
Edit on GitHub

Closed-Loop Metacognitive Governance

Closed-loop metacognitive governance turns AI coding agent intent, reflection, trajectory feedback, and exact-commit validation into durable repo state.

The agent supplies intelligence. Decapod governs convergence. Validation demands proof.

A coding agent must interpret an evolving request, act on a real repository, detect when its work no longer satisfies its commitments, and correct course. Decapod makes that process observable and governable through repository-native state and agent-facing feedback. The model has two coupled mechanisms with different authority.

1. Inside the loop: govern the trajectory

original prompt + accepted subsequent instructions
                       ↓
            agent interprets intent
                       ↓
         scopes tasks and proof obligations
                       ↓
             implements the work
                       ↓
   Decapod evaluates governed state and transitions
                       ↓
         feedback → revise → retry ↺

Decapod is called at consequential decision and state-transition boundaries. An invocation may approve the requested operation, reject it, or describe the missing precondition and supported remedy. The agent interprets the feedback and changes its work accordingly. It does not need a human to rephrase a routine error as a new prompt.

The recorded intent baseline evolves through accepted instructions. The agent records its interpretation of the original request and subsequent clarifications in governed state. A Git commit can establish when that interpretation was recorded; it cannot authenticate who originally spoke, or prove that the agent understood them. Until independently sourced request provenance is available, the distinction remains explicit. Task custody, scope and recorded decisions survive sessions and harnesses. See intent provenance and tracking issue #1761.

The loop is metacognitive because the agent repeatedly evaluates its own plan and implementation against explicit expectations and feedback. Decapod supplies the constraints and durable state that make those comparisons consequential. It does not expose or claim to control every private thought or token generated by a model.

2. At the validation boundary: execute proof obligations

As part of fulfilling the request, the agent also designs falsifiable checks that can demonstrate whether the outcome meets the accepted intent. Decapod requires the relevant claims, checks, and evidence to become explicit, under the Constitution and project policy.

The validation boundary runs the required gates against the identified artifact, under the applicable configured rules. It evaluates the evidence and determines whether completion or publication requirements are satisfied.

agent-authored implementation + proof obligations
                       ↓
        required validation gates execute
                       ↓
      current evidence for the exact artifact
                       ↓
         admissible / blocked / unresolved

The gates are distinct from the agent's conversational confidence. A proposed test is not an executed test. A completed task is not an accepted artifact. A prior successful check is not automatically proof for a changed commit. An agent may write a flawed requirement and a test that faithfully passes against the wrong behavior. Green checks prove only what their covered obligations and accepted validation policy actually establish; fidelity to unexpressed human intent remains not_proven. See independent falsifier work.

A rejected validation result can return to the agent as another feedback event; the agent must revise and resubmit its actual work. Iteration is the mechanism of convergence. Validation is the test of that convergence.

One instruction contract across the lifecycle

The kernel already distinguishes governance rule authority (Constitution, project override, task constraints, kernel invariant), phase (pre-execution, during execution, validation, publication), severity (advisory, warning, error, critical), and verdict (pass, fail, unverifiable, stale). Each rule carries evidence and, where available, an actionable remediation contract. These are orthogonal dimensions, not competing kinds of validation.

BoundaryWhat Decapod examinesConsequence
PreparationRecorded intent, unanswered questions, contradictions, accepted plan, applicable rulesUnresolved instructions cannot approve the plan; provenance is retained
ImplementationScope, custody, worktree, task/phase status, required evidence, recorded trajectoryInvalid Decapod transitions are refused with corrective feedback
ValidationApplicable constitutional and project rules, test/build/security checks where configured, artifact provenance, current proof, stale or missing evidenceAll required gates contribute to the actual verdict; passing tests alone are insufficient
PublicationExact candidate and accepted target, current governance document, required receipts, policy and remote admissionStale or incomplete proof cannot authorize governed publication

The same recorded instruction obligations are checked at each boundary. When the plan changes, earlier acceptance and affected proof may become stale. Native validation remains broader than test completion; a model assertion, a generated specification, or a green badge cannot replace the applicable source-bound evidence.

The intent record lives within the existing .decapod/governance.json alongside its plan, claims, trajectory and validation records. Its raw_intent is the recorded origin and refined_intent is the agent's interpretation. They are deliberately different. The same intent ID cannot silently rewrite the recorded origin; later human instructions require explicit identity and provenance. Git establishes the recorded history, while actual human identity needs an authenticated host where required.

Where enforcement actually lives

Decapod can refuse a Decapod-mediated operation or publication transition when a prerequisite is unsatisfied; actionable errors return control to the agent for repair. The kernel is daemonless and does not intercept an unrestricted process editing files or directly calling Git/GitHub. Such bypasses require explicit host hooks, OS permissions, or remote branch protection and must not be described as kernel-forced compliance.

An APPROVED plan is a declared execution-contract state, and the CLI alone does not authenticate a human approver. The required distinction is between agent/caller plan acceptance, genuine human decision evidence when policy demands it, executed validation, PR publication, and remote admission/merge. A PR's existence is not proof of admission, much less semantic correctness. See enforcement boundary hardening.

Cold-context continuation

Consider the user instruction “Continue PR #1234.” It is a product-level acceptance test for Decapod's durable state model, not a special syntax that the kernel currently guarantees.

An agent with no access to the earlier chat should be able to consult the repository and actual Git/forge state to reconstruct the recorded original and later instructions, task ownership, permitted scope, plan, workunit/trajectory, earlier failed checks and attempted corrections, outstanding proof obligations, and current PR head/base. It must verify what remains applicable now, select a permissible repair, and execute fresh validation before claiming the PR is ready. Merely retrieving a summary or repeating the previous agent's “done” claim would fail that test.

This design unites three existing concerns:

  1. Durability: Request, custody, trajectory, rules, and evidence survive outside the model context in established canonical storage.
  2. Corrective feedback: A rejected Decapod-mediated transition should identify the specific applicable obligation and supported next action so the agent can repair rather than repeat an equivalent failed attempt.
  3. Adjudication: Required validation and publication checks judge the exact candidate against the current governing conditions. An agent cannot turn previous good intentions into fresh proof.

The kernel supplies durable records and source-backed guidance at supported boundaries. It does not automatically intercept every inference call, direct shell command, or private model thought. A new agent cannot recover information that was never recorded. The end-to-end cold-agent PR continuation is being tested under #1367 and #1758; do not label that complete until an independently observed real-agent run succeeds.

Assurance and claim discipline

ClaimEvidence required
ProvenAccepted implementation, reproducible negative and positive checks, and evidence bound to the actual candidate
PartialWorking mechanism with a named unverified seam, missing external observation, or bounded coverage
TargetA desired autonomous workflow or integration awaiting falsifiable end-to-end evidence

A check may prove an operation executed without proving a human's unexpressed intention. A valid repository journal may preserve recorded context without establishing that a new agent used it correctly. An actual admitted PR is a stronger result than an agent's completion message.

Why the sequence matters

An agent can take several individually authorized steps and still produce an unsatisfactory result. A trustworthy outcome needs more than isolated permission checks: it needs a recorded trajectory from intent to implementation, clear proof expectations, and validation of the final candidate.

Decapod governs recorded work and state transitions, with defined policy and evidence boundaries. It does not claim to infer every internal reasoning step. Likewise, validation establishes what the configured proofs actually demonstrate; it cannot establish semantic correctness that the proof obligations fail to express. When the intent remains ambiguous or evidence is inadequate, the correct outcome is not proven, with an explicit blocker or a decision gate.

In practice

A user asks an agent to change an API, then clarifies a backward-compatibility requirement. The agent records both the request and the clarification, scopes the change, and proposes checks that demonstrate the new behavior and compatibility. Decapod rejects unsupported transitions or missing obligations and gives the agent actionable feedback. The agent amends its work and proof design, then submits the candidate to validation. Required gates execute the checks. The resulting evidence is associated with the exact repository state; a failing or missing gate leaves completion unresolved.

This is closed-loop metacognitive agent governance with proof-backed checks on recorded intent convergence. Verification of the exact artifact is concrete; confidence about the human's intended meaning must remain bounded by the available independent evidence.

Agent-first architecture · Proof · Error handling · Mental model