Skip to content

feat: lint planned intents against the repository before queueing them - #50

Merged
Defilan merged 1 commit into
mainfrom
agent/intent-lint
Nov 27, 2026
Merged

Defilan merged 1 commit into
mainfrom
agent/intent-lint

Conversation

@defilan-agent

@defilan-agent defilan-agent Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

What

A deterministic lint (pkg/cli/intents_lint.go) runs in planOne after ParsePlanVerdict and before the intent and queue item are written. Two checks:

  1. unknown paths: every repository path the intent names is tracked (a file or a directory), or is in the header's files: list (a file to create), or is a directory one of those files creates. This also covers "a file the intent says to create is listed in files:": a new path the body names but the header leaves out is unknown.
  2. files the intent never mentions: every header file that already exists is named in the intent, by its path or its base name.

A failed lint parks the issue as needs-decision with reason intent failed lint: <check> (the check names only, joined with , when both fail) and evidence lint (each failed check, its paths, the intent lines that name them) and intent (the intent, capped). With --hold, a failed lint's report is printed before the park line, and a planned intent's line ends with lint passed (N repository paths checked).

Why

Fixes #44

ParsePlanVerdict checks format only, so an intent built on a path the planner guessed was queued and dispatched. The lint catches that class without model judgement and parks it before a coder run is spent.

How

Tuned for precision, since a false park costs a maintainer more than a missed one:

  • Only a word shaped like a repository-relative path under a top-level directory the repository tracks is checked. Root-level names without a slash (CHANGES.md), import paths (github.com/...), untracked outputs (bin/..., .meitheal/...), absolute and home paths, $VAR paths, flags and globs (docs/*.md, pkg/**/x.go) are never checked.
  • A :line suffix, a #anchor and everything after a URL's scheme are dropped; ./ prefixes, trailing / and Go package patterns (./pkg/cli/...) are normalized; --flag=value is checked by its value; Markdown emphasis and sentence punctuation are trimmed; a Go symbol in a tracked package (pkg/cli.ParsePlanVerdict) counts as known.
  • The park reason is built from fixed check names only: it reaches the public park comment, and no model text may (same rule as the other planner parks).
  • The tracked-path index is built once per planning run, not per issue.
  • runIntents is split at the forge (planAndReport) so the end-to-end test can drive meitheal intents --hold with a stub forge and a real HTTP planner server.
  • A /meitheal decide answer re-plans the issue and the new intent is linted again; there is no lint override.

Out of scope, as the issue marks them optional or repository-specific: (3) command-scope checks (flagging whole-workspace builds) and (4) rule hooks declared in a rules file. Neither is trivial to do without false positives or a new rules-file syntax; they can follow in their own issue.

The existing tests built intents whose header listed files the body never named (plannedAnswer); the tests that need such a header now use namingAnswer, which adds a step naming each file. No assertion was weakened.

Testing

  • TestLintIntent: table tests against a fixture git repository: the forms an intent writes paths in, URLs / import paths / globs / flags / absolute paths, root-level names, files and directories to create, base-name mentions, and each failure.
  • TestLintIntent_ReasonIsFixedAndEvidenceNamesLines: the reason carries no intent text; the report names each offending line once.
  • TestIntents_HoldParksAnIntentThatFailsLint: end to end through planAndReport with an HTTP planner: an intent naming a missing file is parked (decision file, reason, evidence), not written and not queued, while a clean one is queued; --hold prints the lint result and no --hold does not.
  • Mutation checks (via go test -overlay, 13 mutants of the lint and its wiring: removing the lint call, the --hold wiring, the glob, top-level-directory, header-directory, base-name, existing-file, Go-symbol, anchor, : cut, emphasis trim and = split handling, and the offending-line logic): all killed.
  • go test ./pkg/cli/..., make fmt vet, make lint (0 issues). The full envtest make test was not run; nothing outside pkg/cli and one doc line changed.

Checklist

  • Tests added/updated
  • make test passes locally (ran go test ./pkg/cli/... only)
  • make lint passes locally
  • Commit messages follow conventional commits
  • All commits are signed off: agent PR, a maintainer adds the sign-off
  • AI assistance is disclosed below
  • Documentation updated (meitheal intents help, docs/run-loop.md park table)

Assisted-by: Claude Code (Claude Opus 5.5) wrote the lint, its wiring, the help and doc text, and the tests; the tests were checked against 13 hand-written mutants (all killed), and go test ./pkg/cli/..., make fmt vet and make lint were run.

@Defilan
Defilan enabled auto-merge November 27, 2026 22:30
@Defilan
Defilan added this pull request to the merge queue Nov 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 27, 2026
ParsePlanVerdict checks only the format of a planner answer, so an intent
that names a file the repository does not have, or whose header lists
files its body never mentions, was queued and spent a coder run.

planOne now lints every planned intent against the tracked file list
before writing it. A repository path the intent names must be tracked or
be in the header's files list (a file to create), and an existing header
file must be mentioned in the intent. Only words shaped like a path under
a tracked top-level directory are checked, so URLs, import paths, globs,
flags and absolute paths never fail it. A failed lint parks the issue as
needs-decision with the fixed reason "intent failed lint: <check>" and the
offending paths and lines in the evidence; --hold prints each result.

Signed-off-by: Christopher Maher <chris@mahercode.io>
@Defilan
Defilan enabled auto-merge November 27, 2026 23:16
@Defilan
Defilan added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 92d6d58 Nov 27, 2026
6 checks passed
@Defilan
Defilan deleted the agent/intent-lint branch November 27, 2026 23:27
@github-actions github-actions Bot mentioned this pull request Nov 27, 2026
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.

[FEATURE] Lint planned intents against the repository before queueing them

1 participant