Fix output modifier positioning and add arch health subcommands#20
Fix output modifier positioning and add arch health subcommands#20darko-mijic merged 3 commits intomainfrom
Conversation
Output modifiers (--names-only, --count, --fields, --full, --format) were silently ignored when placed after the subcommand because parseArgs() stopped parsing flags once a subcommand was encountered. Moved these to position- independent parsing (same pattern as --help/--version). Also removed arch graph which was a strict subset of arch neighborhood and would collide with the planned DataAPIRelationshipGraph spec.
Surface pre-computed graph health data through three new arch subcommands that replace the removed arch graph with genuinely new capabilities: - arch dangling: broken references from ValidationSummary (already computed) - arch orphans: patterns with no relationships via findOrphanPatterns() - arch blocking: patterns blocked by incomplete deps via buildOverview() Switched CLI from transformToMasterDataset() to transformToMasterDatasetWithValidation() to expose ValidationSummary. Updated CLAUDE.md, docs, and planning plugin references.
📝 WalkthroughWalkthroughIntroduces arch "graph health" subcommands (dangling, orphans, blocking), adds orphan-detection logic, and threads a ValidationSummary through the CLI pipeline so handlers can return dataset validation alongside the master dataset. Changes
Sequence DiagramsequenceDiagram
participant Client
participant CLI
participant Pipeline
participant Transformer
participant ArchHandler
participant Dataset
Client->>CLI: run arch <subcommand>
CLI->>Pipeline: buildPipeline(config)
Pipeline->>Transformer: transformToMasterDatasetWithValidation(...)
Transformer->>Transformer: produce RuntimeMasterDataset + ValidationSummary
Transformer-->>Pipeline: { dataset, validation }
Pipeline-->>ArchHandler: RouteContext { dataset, validation }
ArchHandler->>ArchHandler: dispatch subcommand
alt dangling
ArchHandler->>ArchHandler: return validation.danglingReferences
else orphans
ArchHandler->>Dataset: findOrphanPatterns(dataset)
else blocking
ArchHandler->>Dataset: buildOverview(dataset).blocking
end
ArchHandler-->>Client: JSON array result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@src/api/arch-queries.ts`:
- Around line 398-402: The OrphanEntry interface's file property can be an empty
string when findPatternByName returns undefined (see findPatternByName usage
around where file is set to ''), so add a brief JSDoc comment to
OrphanEntry.file clarifying that it will be an empty string if pattern metadata
is unavailable (e.g., "empty string if pattern metadata is unavailable") to make
downstream behavior explicit.
In `@src/cli/process-api.ts`:
- Around line 726-733: The early returns in handleArch are correct —
dangling/orphans/blocking must bypass the archIndex gate — but avoid recomputing
the full overview just to read .blocking: replace the direct call
buildOverview(ctx.dataset).blocking with a lightweight helper (e.g.,
getBlockingOverview(ctx.dataset) or buildOverview(ctx.dataset, { fields:
['blocking'] })) or add memoization/caching inside buildOverview so fetching
.blocking is cheap; keep the early return logic in handleArch and only change
how blocking is obtained to a cheaper path.
In `@tests/features/cli/process-api.feature`:
- Around line 320-375: The new Rule blocks for "Output Modifier Position
Independence" and "Graph Health Subcommands" are missing the structured metadata
and one scenario is asymmetric: add the standard sections (**Invariant:**,
**Rationale:**, **Verified by:**) to each new Rule block (the blocks beginning
with "Rule: Output modifiers work..." and "Rule: CLI arch health
subcommands...") and enhance the "Arch blocking" scenario (the scenario starting
"Arch blocking returns blocked patterns") to assert a known response field
(e.g., check that stdout JSON data contains an entry with a "pattern" or
"blockedBy" field) so it matches the stronger checks used in the "dangling" and
"orphans" scenarios.
In `@tests/steps/cli/process-api.steps.ts`:
- Around line 1049-1135: The 'Arch blocking returns blocked patterns'
RuleScenario sets up fixtures via writePatternFiles and runs the CLI via
runCLICommand but only asserts that parsed.data is an array; update that
scenario (the RuleScenario named "Arch blocking returns blocked patterns") to
mirror the other scenarios by parsing getResult().stdout into { data:
Array<Record<string, unknown>> }, asserting the array has length > 0, and
asserting the first entry has a specific expected field (use the same field name
used in the other scenarios' field check), e.g., check arr.length > 0 and
expect(arr[0]).toHaveProperty(<field>), so tests are consistent with
writePatternFiles and runCLICommand usage.
- Document OrphanEntry.file empty string fallback - Add Invariant/Rationale/Verified by sections to Rule 15 and 16
Summary
--names-only,--count,--fields,--full, and--formatnow work regardless of where they appear in the command (before or after the subcommand). Previously, placing modifiers after the subcommand (e.g.,list --count) caused them to be silently ignored.arch dangling,arch orphans, andarch blockingfor detecting graph quality issues in the architecture relationship model.arch graphsubcommand — superseded by the more comprehensivearch neighborhoodcommand added in Replace 11 static recipe files with codec-driven reference generation #19.Changes
Bug Fix: Output Modifier Position Independence
Moved output modifier parsing (
--names-only,--count,--fields,--full,--format) out of the flag-onlyswitchblock to an earlier position-independent section inparseArgs(). This ensures modifiers work in natural command order:# These now both work identically: pnpm process:query -- --count list --status completed pnpm process:query -- list --status completed --countNew Feature: Architecture Health Subcommands
arch danglingValidationSummary.danglingReferencesarch orphansfindOrphanPatterns()in arch-queriesarch blockingbuildOverview().blockingThe pipeline now returns a
ValidationSummaryalongside theMasterDataset(viatransformToMasterDatasetWithValidation) to power thearch danglingcommand without recomputation.Removed:
arch graphSubcommandarch graph <pattern>returned raw dependency and relationship names but provided less value thanarch neighborhood <pattern>, which returns uses, usedBy, and same-context siblings — a strictly superior view. Removed to reduce API surface area.Files Changed
src/api/arch-queries.tsfindOrphanPatterns()function andOrphanEntryinterfacesrc/cli/process-api.tsarch graph, threadValidationSummarytests/features/cli/process-api.featurearch graphscenariotests/steps/cli/process-api.steps.tsdocs/PROCESS-API.mdCLAUDE.mdTest Plan
pnpm test)list --count,list --names-only,list --status completed --count)arch dangling,arch orphans, andarch blockingreturn valid JSON arrays with expected fieldsarch graphscenario to match CLI changepnpm build)Summary by CodeRabbit
New Features
graphsubcommand.Documentation
Tests