Skip to content

fix: make codemap's model of agent sessions truthful - #84

Open
JordanCoin wants to merge 1 commit into
mainfrom
fix/agent-truth-batch
Open

fix: make codemap's model of agent sessions truthful#84
JordanCoin wants to merge 1 commit into
mainfrom
fix/agent-truth-batch

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

Summary

Five accuracy fixes, all TDD (failing test first), all sourced from running codemap on its own repo during a real agent session and catching it being wrong:

  1. Resolver truth — stdlib/third-party Go imports no longer fuzzy-match local files. scanner/astgrep.go's stdlib "context" import was resolving to cmd/context.go, fabricating its 10-importer hub status (same for "embed"skills/embed.go, rendered as a self-edge in --deps). Go package index keys are now slash-normalized so module lookups also work on Windows.
  2. Hub honesty — hub status counts only non-test importers and test files never rank as hubs (mcp/main_test.go was a "top-5 hub"). Centralized in scanner.HubThreshold / CountHubImporters / IsTestFile, applied across CLI, hooks, and MCP.
  3. Intent gating — confidence below 0.5 emits no intent marker and no Next codemap: advice. A PR-merge prompt previously got category: feature, confidence: 0 plus "run codemap --deps — feature work tends to cross existing dependencies". New vcs category recognizes merge/review/release prompts and suggests --diff.
  4. Edit provenance — the post-edit hook records agent edits (.codemap/agent_edits.jsonl); working-set/session output now separates "this agent edited" from "changed on disk". A git merge observed by the watch daemon no longer reports as "25 files edited (+649 lines in watch/events.go)".
  5. CLI polish--importers explains empty results (same-package Go files never import each other) while blast-radius bundles keep omitting empty sections; codemap drift says "path does not exist, see --help" instead of lstat drift; --help lists every subcommand; config init stops auto-including log/pid/gitignore-class residue.

After this change, codemap-on-codemap reports exactly one hub — internal/buildinfo/version.go — which is the true answer.

Type of change

  • Bug fix

Verification

  • Full go test -race ./... green on macOS
  • GOOS=windows and GOOS=linux builds pass; new code uses filepath/ToSlash normalization and O_APPEND-safe appends only
  • End-to-end re-run of every previously-broken command on this repo (importers, deps hubs line, drift, prompt-submit probe)

🤖 Generated with Claude Code

Five accuracy fixes, each driven by a failing test captured from running
codemap on its own repo during a real agent session:

- Resolver: Go imports that aren't relative or under the module path are
  stdlib/third-party and no longer fall through to fuzzy suffix matching.
  Previously stdlib "context" resolved to cmd/context.go (and "embed" to
  skills/embed.go), fabricating hub status. Also slash-normalize Go package
  index keys so module lookups work on Windows.
- Hubs: hub status now counts only non-test importers, and test files never
  rank as hubs (mcp/main_test.go was a "top-5 hub"). Centralized in
  scanner.HubThreshold/CountHubImporters/IsTestFile and applied across CLI,
  hooks, and MCP surfaces.
- Intent: zero/low-confidence classifications no longer emit intent markers
  or "Next codemap:" advice (a PR-merge prompt used to get feature-work
  advice from a confidence-0 guess). New vcs category recognizes
  merge/review/release workflows and suggests --diff instead.
- Provenance: the post-edit hook records agent edits to
  .codemap/agent_edits.jsonl; working-set and session-progress output now
  separate "this agent edited" from "changed on disk", so git merges and
  checkouts observed by the watch daemon stop being reported as 25 files
  the agent supposedly edited.
- CLI: --importers explains empty results (same-package Go files never
  import each other) without leaking into token-budgeted blast-radius
  bundles; bare-word typos like 'codemap drift' get a friendly error;
  --help lists all subcommands; config init stops auto-including runtime
  residue extensions (log, pid, gitignore, ...).

Cross-platform: verified with GOOS=windows and GOOS=linux builds; new code
uses filepath/ToSlash normalization and O_APPEND-safe logging throughout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 27, 2026 19:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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