Skip to content

Commit 6f6608b

Browse files
authored
feat(skill): comprehensive grind rewrite and cross-skill integration (#896)
* refactor: adopt dead helpers across codebase Wire up extracted helpers from Titan runs that existed but were never consumed, reducing boilerplate and improving error specificity. - Adopt named_child_text across 27 sites in 11 Rust extractors - Migrate cpp.rs from hand-rolled find_cpp_parent_class to find_enclosing_type_name - Add toSymbolRef helper in shared/normalize.ts, adopt at 15 mapping sites - Wire ParseError in parser.ts for structured PARSE_FAILED error codes - Wire BoundaryError in boundaries.ts to distinguish config/DB failures from clean results - Add --modules/--threshold flags to codegraph structure command - Wire batchQuery in CLI batch command, removing duplicated routing logic - Route detect-changes pending analysis through unified runAnalyses engine * fix: address review feedback on dead helper adoption (#895) - manifesto.ts: report 'warn' instead of 'pass' when boundary check throws - structure.ts: validate --threshold flag rejects non-numeric input - dependencies.ts: clarify intentional skip of toSymbolRef for callers * feat(skill): add /titan-grind phase and wire into /titan-run pipeline Forge extracts helpers but never completes the adoption loop — dead symbol count inflates with every run. Grind closes the gap by finding dead helpers from forge, classifying them (adopt/re-export/promote/ false-positive/remove), wiring them into consumers, and gating on a non-positive dead-symbol delta. Pipeline is now: recon → gauntlet → sync → forge → grind → close * fix(skill): add resilience and codegraph usage to /titan-grind - Track currentTarget, processedTargets, failedTargets in state for mid-run resume after interruption - Persist grind classifications to grind-targets.ndjson (append-only) so re-runs skip already-analyzed targets - Write titan-state.json after every target, not just at phase end - Add interrupted-mid-target recovery logic in edge cases - Use codegraph audit/context/fn-impact/where/query/ast before edits - Add codegraph diff-impact --staged before commits - Add codegraph build after edits to keep graph current - Add --target flag for retrying individual failures * feat(skill): comprehensive grind rewrite and cross-skill integration Rewrite titan-grind with full resilience (state machine, .bak files, NDJSON persistence, snapshot management), codegraph integration (audit/context/fn-impact/diff-impact), diff review (DR1-DR3), drift detection, false positive tracking via issues.ndjson, and phase timestamps. Update titan-close: grind-targets.ndjson in artifact load list, adoption concern type in PR grouping, grind metrics in before/after comparison, GRIND row in Pipeline Timeline, Grind Results section in report template, grind block in close-summary.json. Update titan-reset: titan-grind-baseline snapshot deletion and grind-targets.ndjson in artifact listing. * fix(skill): align titan-close grind metrics with titan-grind NDJSON schema (#896) titan-close was reading status/deadBefore/deadAfter fields that titan-grind never writes. Updated to read classification field from grind-targets.ndjson and pull metrics from titan-state.json grind block. * fix: restore null guard in batchQuery multi-batch detection (#896) typeof null === 'object' is true in JS, so accessing .command on null would throw TypeError. Added explicit null check before the typeof. * fix(skill): add --start-from grind pre-checks row to titan-run (#896) Without a validation table row for grind, the orchestrator had no guidance on which pre-checks to run when starting directly from grind.
1 parent 3cb4260 commit 6f6608b

File tree

5 files changed

+265
-50
lines changed

5 files changed

+265
-50
lines changed

.claude/skills/titan-close/SKILL.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Your goal: analyze all commits on the current branch, split them into focused PR
6565
- `.codegraph/titan/issues.ndjson` — issue tracker from all phases
6666
- `.codegraph/titan/arch-snapshot.json` — pre-forge architectural snapshot (communities, structure, drift). Use for before/after comparison in the Metrics section. May not exist if capture failed.
6767
- `.codegraph/titan/drift-report.json` — cumulative drift reports from all phases. May not exist if no drift was detected.
68+
- `.codegraph/titan/grind-targets.ndjson` — grind phase adoption targets and outcomes. Each line: `{target, file, phase, classification, reason, consumers, pattern, timestamp}`. May not exist if grind wasn't run.
6869

6970
If `titan-state.json` is missing after the search, stop: "No Titan session found. Run `/titan-recon` first."
7071

@@ -146,6 +147,9 @@ Use `sync.json` execution phases as the primary guide if available:
146147
- Group by domain: `fix: address quality issues in <domain>`
147148
6. **Warning improvements** — commits addressing warn-level issues
148149
- Group by domain: `refactor: improve code quality in <domain>`
150+
7. **Helper adoption** — commits from grind phase adopting dead helpers into callsites
151+
- PR title: `refactor: adopt dead helpers in <domain>`
152+
- Look for `grind(...)` commit prefixes or commits touching files listed in `grind-targets.ndjson`
149153

150154
### Fallback grouping (if no sync.json)
151155

@@ -164,7 +168,7 @@ Record the grouping plan:
164168
{
165169
"pr": 1,
166170
"title": "...",
167-
"concern": "dead_code|abstraction|cycle_break|decomposition|quality_fix|warning",
171+
"concern": "dead_code|abstraction|cycle_break|decomposition|quality_fix|warning|adoption",
168172
"domain": "<domain name>",
169173
"commits": ["<sha1>", "<sha2>"],
170174
"files": ["<file1>", "<file2>"],
@@ -202,6 +206,17 @@ codegraph complexity --health --sort mi -T --json --limit 10
202206

203207
If `.codegraph/titan/arch-snapshot.json` was captured before forge, compare its `structure` data against current `codegraph structure --depth 2 --json` output. Report cohesion changes per directory (improved / degraded / unchanged). Include in the "Metrics: Before & After" section of the report.
204208

209+
### Grind metrics (if grind-targets.ndjson exists)
210+
211+
If `.codegraph/titan/grind-targets.ndjson` exists, parse it and cross-reference with `titan-state.json → grind`:
212+
- **Targets processed:** count entries in `grind.processedTargets` (from titan-state.json)
213+
- **Targets failed:** count entries in `grind.failedTargets` (from titan-state.json)
214+
- **False positives identified:** count entries with `classification: "false-positive"` in grind-targets.ndjson (or from `grind.falsePositives` in titan-state.json)
215+
- **Adopted:** count entries with `classification: "adopt"` in grind-targets.ndjson
216+
- **Dead symbol delta:** from `grind.deadSymbolDelta` in titan-state.json (or compute from baseline vs final dead symbol counts)
217+
218+
Include these in the Metrics: Before & After section and the Grind Results report section.
219+
205220
### Compute deltas
206221

207222
Compare final metrics against `titan-state.json` baseline:
@@ -342,7 +357,8 @@ Read `titan-state.json → phaseTimestamps` for real wall-clock data. If `phaseT
342357
| GAUNTLET | <computed from phaseTimestamps.gauntlet> | <iterations count if resuming> |
343358
| SYNC | <computed from phaseTimestamps.sync> ||
344359
| FORGE | <computed from phaseTimestamps.forge> | <commit count>, first at <time>, last at <time> |
345-
| GATE | across forge | <total runs> inline with forge commits |
360+
| GRIND | <computed from phaseTimestamps.grind> | <targets processed>, <adoptions made> |
361+
| GATE | across forge/grind | <total runs> inline with forge/grind commits |
346362
| CLOSE | <computed from phaseTimestamps.close> ||
347363
| **Total** | <sum of all phases> ||
348364

@@ -393,6 +409,22 @@ Read `titan-state.json → phaseTimestamps` for real wall-clock data. If `phaseT
393409

394410
---
395411

412+
## Grind Results (if grind ran)
413+
414+
**Targets processed:** <N> | **Adopted:** <N> | **Failed:** <N> | **False positives:** <N>
415+
416+
### Adoption Summary
417+
418+
<Table: target name, dead symbols before, dead symbols after, delta, files modified>
419+
420+
### False Positives Logged
421+
422+
<Table: target name, reason (dynamic import / re-export / closure-local / type noise), logged to issues.ndjson>
423+
424+
> Omit this section entirely if `grind-targets.ndjson` does not exist.
425+
426+
---
427+
396428
## Changes Made
397429

398430
### Commits: <total count>
@@ -551,6 +583,7 @@ Write `.codegraph/titan/close-summary.json`:
551583
},
552584
"audit": { "totalAudited": 0, "pass": 0, "warn": 0, "fail": 0, "decompose": 0 },
553585
"gate": { "totalRuns": 0, "pass": 0, "warn": 0, "fail": 0, "rollbacks": 0 },
586+
"grind": { "targetsProcessed": 0, "adopted": 0, "failed": 0, "falsePositives": 0, "deadSymbolDelta": 0 },
554587
"issues": { "codegraph": 0, "tooling": 0, "process": 0, "codebase": 0 },
555588
"prs": [
556589
{ "number": 0, "url": "<url>", "title": "<title>", "concern": "<type>", "domain": "<domain>", "commits": 0 }

0 commit comments

Comments
 (0)