Skip to content

feat: inject project .dag as ground truth before markdown context#90

Closed
logohere wants to merge 2 commits into
mainfrom
feat/repo-audit
Closed

feat: inject project .dag as ground truth before markdown context#90
logohere wants to merge 2 commits into
mainfrom
feat/repo-audit

Conversation

@logohere

Copy link
Copy Markdown
Contributor

Problem

Agent reads .ts implementation files before .dag spec files — bypasses DAG-first engine entirely. Observed in magic-cabinet-mvp session where agent read 8+ .ts files before any .dag, requiring 4 user interventions.

Root cause

Project .dag files are not pre-injected into context. Agent must explicitly read_file them — same cost as .ts files, but less obviously useful. The .dag has no code pointers, so it doesn't serve as a natural first stop.

Fix

  • prompt_builder.py: _load_project_dag() scans projects/ and specs/ for .dag files, compacts JSON to DAG-path notation (6435→1046 chars, 16%), injects as turn-1 context BEFORE any markdown. Priority: .dag → .dag.md → AGENTS.md → CLAUDE.md → .cursorrules.
  • subdirectory_hints.py: *.dag glob added to hint discovery. When agent navigates to directories with .dag files, they're compacted and injected as [Subdirectory DAG context] blocks.

Before/After

Before: Agent starts session, sees AGENTS.md markdown, then reads .ts files, never touches .dag unless told.

After: Agent wakes up seeing:

[contractor-dashboard]  # DAG ground truth
Contractor→ Project:owns(1:N) | Order:places(1:N) | ...
  states: unregistered → registered → verified → pro
Design2020Import→ Project:imports_via(1:N) | DesignVersion:produces(1:1)
  states: uploaded → parsed → matched → rendered → priced

Gap detection is immediate: DAG says priced state exists, implementation has matchedSku: null.

logohere added 2 commits June 18, 2026 22:22
- prompt_builder.py: _load_project_dag() scans projects/ and specs/
  directories for .dag files, compacts JSON to DAG-path notation,
  injects as first-turn context (before AGENTS.md/CLAUDE.md)
- subdirectory_hints.py: add *.dag glob to HINT_FILENAMES,
  _read_hint_file() + _compact_dag() convert .dag JSON on discovery
- 6435-char .dag → 1046-char compact format (16% of original)
- Fixes DAG-bypass: LLM now has entity graph in context from turn 1
@logohere logohere closed this Jun 19, 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.

1 participant