T-QIBD-audit-memoizes-parsed-frontmatter
Status: closed/done · Impact: low · Complexity: small
Auto-generated from a /sdlc:task-work post-mortem. Review and
promote to ready before picking up.
audit_entities.py parses every entity’s frontmatter twice — once per file
in the main per-file audit, and again inside collect_depends_on_graph when
building the cycle-detection adjacency. The corpus is tiny today so it does
not matter, but the structural waste is in the hot path of every future
/sdlc:entities-audit invocation. Closing this gap is a one-line refactor
that future-proofs the audit before someone notices it as a slow command.
Cited by T-J2CW-add-epic-entity-task-depends-on-dependencies.
From the originating post-mortem:
audit_entities.pyre-parses every task file insidecollect_depends_on_graphbecauseFileReportdoesn’t carry the parsed frontmatter forward. Acceptable today (corpus is tiny), but worth memoizing if the audit ever grows to thousands of entries.
Script: plugin/scripts/audit_entities.py. Look for collect_depends_on_graph
and the FileReport dataclass / structure.
Proposed
Section titled “Proposed”collect_depends_on_graph reads parsed frontmatter from the existing
FileReport (or whatever carrier object the per-file pass returned) rather
than re-opening and re-parsing each file from disk. After the change, an
audit run touches each file’s bytes exactly once.
Approach
Section titled “Approach”- Inspect
audit_entities.pyfor the structure that carries per-file audit results. Add afrontmatter(or similar) attribute that captures the already-parsed mapping. - Update
collect_depends_on_graph(and any other multi-pass consumer that re-parses) to read from the carrier instead of re-opening the file. - Run
plugin/skills/entities-audit/tests/run_evals.pyand confirm all eval cases still pass.
Files to touch
Section titled “Files to touch”plugin/scripts/audit_entities.py— extendFileReport(or equivalent) to carry parsed frontmatter; switchcollect_depends_on_graphto consume it.
Acceptance criteria
Section titled “Acceptance criteria”- AC-1:
plugin/skills/entities-audit/tests/run_evals.pycontinues to pass after the refactor. - AC-2: A single audit run opens each entity file at most once (verified by, e.g., instrumenting the file open or a structural code review).
Out of scope
Section titled “Out of scope”- Performance tuning beyond the duplicate parse (e.g. parallelizing file reads).
- Changes to the audit’s reporting shape.
Dependencies
Section titled “Dependencies”- none
Discovery context
Section titled “Discovery context”Spawned by /sdlc:task-work post-mortem of T-J2CW-add-epic-entity-task-depends-on-dependencies on 2026-05-19.
Post-mortem
Section titled “Post-mortem”Captured by /sdlc:task-work on 2026-05-19. PR: pending.
Acceptance criteria coverage
Section titled “Acceptance criteria coverage”- AC-1: auto —
python3 plugin/skills/entities-audit/tests/run_evals.pyreports7/7 eval case(s) passedboth before and after the refactor. - AC-2: agent-manual — structural code review of
audit_entities.pyconfirms only one entity-instance file-open site (audit_fileat the call topath.read_text(encoding="utf-8")); the otherread_textis for schema templates, not entity instances.collect_depends_on_graphno longer reads files at all — it consumes the cachedreport.frontmattermapping.
What worked
Section titled “What worked”- The task spec was precise enough that the refactor required zero design judgment — the carrier object, the consumer, and the contract (every file opened at most once) were named explicitly.
- The eval suite gave a fast pre/post baseline, and re-running it confirmed behaviour was preserved in seconds.
Friction and automation gaps
Section titled “Friction and automation gaps”- The
task-workskill’s Step 4 mandatesmise trust && just setup-worktree, but this repo has nojustfile— the command fails noisily and the skill has no graceful fallback. The skill should detect “no justfile / no lefthook” and skip the setup step rather than asking the implementer to absorb the error and decide whether it matters. - This repo also has no
just full-checkorjust citargets, so Step 7’s “quality gate” reduces to “run the eval suite manually”. The skill assumes a project-level meta-CI that does not always exist; a per-project quality-gate config (or atask-work --no-justflag) would make Step 7 honest. node_pathincollect_depends_on_graphis reconstructed fromreport.pathafter the refactor — an absolute Path is rebuilt for every task withdepends_on. A small follow-up could push the absolute path ontoFileReportdirectly so cross-file passes never recompute it, but that’s a micro-optimisation and almost certainly not worth a dedicated task.