# How the Intent Provenance System Distinguishes Agent vs. Inferred Intent in No-Mistakes

> Learn how the intent provenance system distinguishes agent vs inferred intent in No-Mistakes. Understand which user intents are authoritative for reliable operation.

- Repository: [Kun Chen/no-mistakes](https://github.com/kunchenguid/no-mistakes)
- Tags: deep-dive
- Published: 2026-07-13

---

**The intent provenance system tracks whether a user intent originates from an explicit command-line argument or an LLM summary, treating explicit "agent" intent as authoritative binding criteria while handling inferred intent as low-confidence hints.**

The `kunchenguid/no-mistakes` repository implements a robust intent provenance system to ensure that automated code changes respect the user's original goals. This system records the origin of every intent string in the database, allowing the pipeline to enforce strict conformance checks only when the user has deliberately supplied requirements via the CLI. By distinguishing between explicit agent-supplied intent and inferred LLM-generated summaries, the framework prevents unintended behaviors from being treated as binding constraints.

## What Is the Intent Provenance System?

The **intent provenance system** records the source of every user-intent string so that downstream pipeline steps can apply the appropriate level of authority. When a run is initiated, the system captures whether the intent was provided directly by the user or extracted from an agent transcript. This provenance metadata determines whether the intent is treated as mandatory acceptance criteria or as a suggestive hint.

## Explicit vs. Inferred Intent Sources

The system recognizes two distinct provenance categories that dictate how strictly the pipeline validates conformance.

### Explicit Agent-Supplied Intent

When a user runs `axi run --intent "description"`, the CLI stores the intent with `Source==db.RunIntentSourceAgent`, which corresponds to the constant value `"agent"`. The system treats this as **authoritative acceptance criteria**. The pipeline prepends a detailed notice to the prompt indicating that the intent is binding, and it adds a hard conformance clause that forces user review if the change violates any aspect of the stated goal.

### Inferred LLM-Summarized Intent

If the user runs an agent without the `--intent` flag, the system extracts the intent from the LLM transcript and records sources such as `"claude"` or `"codex"`. The pipeline treats these as **low-confidence hints**, prepending warnings that the intent is untrusted and should not be obeyed verbatim. No hard conformance clause is appended, allowing the system greater flexibility when the inferred intent might misrepresent the user's actual requirements.

## The Authority Check Implementation

The distinction between these sources lives in the helper function `intentSourceIsAuthoritative`, defined in [`internal/pipeline/steps/intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/intent_prompt.go):

```go
func intentSourceIsAuthoritative(sctx *pipeline.StepContext) bool {
    return sctx != nil && sctx.IntentSource == db.RunIntentSourceAgent
}

```

This function returns `true` only when `sctx.IntentSource` equals the constant `db.RunIntentSourceAgent` (the string `"agent"`). The pipeline uses this boolean to branch between strict and lenient handling.

When building the user-intent prompt section, the code consults this authority check (lines 45–50 of [`intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/intent_prompt.go)):

```go
if intentSourceIsAuthoritative(sctx) {
    // prepend authoritative notice and add a conformance clause
    ...
} else {
    // prepend a hint-only notice
    ...
}

```

The **conformance clause**—which forces an "ask-user" finding if the change violates the intent—is only emitted for authoritative sources (lines 72–82 of [`intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/intent_prompt.go)):

```go
if !intentSourceIsAuthoritative(sctx) || cleanedUserIntent(sctx) == "" {
    return ""
}

```

## Where Provenance Is Defined and Stored

The authoritative source constant is defined in [`internal/db/run.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/db/run.go) at line 220:

```go
// RunIntentSourceAgent is the intent_source value stamped when the driving
// agent (`axi run --intent`) supplies an explicit intent.
const RunIntentSourceAgent = "agent"

```

When a run is created, the intent persistence logic in [`internal/pipeline/steps/intent.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/intent.go) captures both the intent string and its source. The executor in [`internal/pipeline/executor.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/executor.go) then propagates these values into the step context (`sctx`), making them available to all downstream processing steps.

## Practical Usage Examples

To set an explicit intent from the command line:

```bash
axi run --intent "Add a new public function Foo() that returns a sorted list"

```

To inspect the stored provenance in Go:

```go
run, _ := db.GetRun(runID)               // fetch the Run record
fmt.Println("Intent source:", *run.IntentSource) // prints "agent"

```

To conditionally apply strict checks in a custom pipeline step:

```go
func someStep(sctx *pipeline.StepContext) {
    if intentSourceIsAuthoritative(sctx) {
        // Apply strict conformance checks
    } else {
        // Treat intent as a hint only
    }
}

```

## Summary

- The **intent provenance system** tracks whether intent originates from explicit CLI arguments or LLM inference.
- **Explicit intent** (`"agent"` source) triggers authoritative treatment with binding conformance clauses.
- **Inferred intent** (e.g., `"claude"`, `"codex"`) is treated as a low-confidence hint without enforcement mechanisms.
- The `intentSourceIsAuthoritative` function in [`internal/pipeline/steps/intent_prompt.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/pipeline/steps/intent_prompt.go) centralizes the authority logic.
- The constant `RunIntentSourceAgent` in [`internal/db/run.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/db/run.go) defines the authoritative source value.

## Frequently Asked Questions

### How does the system determine if an intent is authoritative?

The system checks if `sctx.IntentSource` equals the constant `db.RunIntentSourceAgent` (the string `"agent"`). This comparison occurs in the `intentSourceIsAuthoritative` function, which returns `true` only for explicit command-line intents supplied via `axi run --intent`.

### What happens when an inferred intent conflicts with safety constraints?

When the source is inferred (e.g., `"claude"`), the system treats the intent as an untrusted hint. The pipeline omits the hard conformance clause that would otherwise force user review, allowing the change to proceed provided it satisfies baseline safety checks rather than the specific inferred wording.

### Where is the intent source constant defined?

The constant `RunIntentSourceAgent` is defined in [`internal/db/run.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/db/run.go) at line 220. It represents the value `"agent"` and is used throughout the pipeline to identify explicit, user-supplied intent strings.

### Can the pipeline handle custom intent sources?

While the system primarily recognizes `"agent"` for explicit intent and LLM names like `"claude"` for inferred intent, any string can technically be stored as an intent source. However, only the `RunIntentSourceAgent` value triggers the authoritative code path; all other sources receive non-authoritative treatment.