Repository navigation
feat(extract): add CLI flags for extraction modes and enrichment orchestrator - #227
Conversation
…estrator Co-Authored-By: Claude <[email protected]>
Deploying living-architecture with
|
| Latest commit: |
39f974b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://92cb404d.living-architecture.pages.dev |
| Branch Preview URL: | https://issue-166-m2-d2-6-add-cli-fl.living-architecture.pages.dev |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds a rule-driven enrichment engine and integrates it into the CLI: new Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI as rgba(52,122,183,0.5)
participant Config as rgba(46,204,113,0.5)
participant FS as rgba(231,76,60,0.5)
participant Enricher as rgba(155,89,182,0.5)
participant Matcher as rgba(241,196,15,0.5)
User->>CLI: run extract --enrich drafts.json -o out.json
CLI->>Config: loadAndValidateConfig()
Config->>FS: read extract.yaml
FS-->>Config: config
Config-->>CLI: resolved config
CLI->>FS: readFile(drafts.json)
FS-->>CLI: drafts JSON
CLI->>Enricher: enrichComponents(drafts, config, project, globMatcher, configDir)
Enricher->>Matcher: findMatchingModule / findDetectionRule
loop per draft component
Enricher->>Enricher: evaluateRule(s) (literal, fromFilePath, fromClassName, fromProperty)
Enricher-->>Enricher: accumulate metadata / failures / _missing
end
Enricher-->>CLI: EnrichmentResult {components, failures}
alt failures && not --allow-incomplete
CLI->>CLI: exit ExitCode.ExtractionFailure (1)
else
CLI->>FS: writeFileSync(out.json, results) or stdout
FS-->>User: out.json / stdout
CLI-->>User: exit 0
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
ⓘ Your approaching your monthly quota for Qodo. Upgrade your plan PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
…estrator Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In
`@packages/riviere-cli/src/features/extract/entrypoint/extract.enrichment.spec.ts`:
- Around line 145-294: Add a test to the existing "enrich flag" suite that
verifies the CLI rejects providing both --components-only and --enrich together:
create configWithLiteralExtract and a draftPath JSON file, call
createProgram().parseAsync with args including '--components-only' and
'--enrich' plus the draftPath, assert the promise rejects with an exitCode
indicating validation error (e.g. 2), then use
parseErrorOutput(ctx.consoleOutput) to assert the error message contains
"mutually exclusive"; place this test near the other enrich flag tests so it
uses the same TestContext and helpers (createProgram, parseErrorOutput,
configWithLiteralExtract, draftPath).
- Around line 22-27: Replace the local DraftComponent interface with an import
from `@living-architecture/riviere-extract-ts`: remove the locally declared
"interface DraftComponent { type: string; name: string; domain: string;
location: ComponentLocation }" and add an import for DraftComponent (and
ComponentLocation if not already imported) from the package so tests use the
canonical type; mirror the pattern used in the sibling test
extract.dry-run.spec.ts to locate the correct import name and update any
references to DraftComponent in the file accordingly.
- Around line 162-166: Update the test's expected location so the enrichment
finds the class declaration: in the location object inside
extract.enrichment.spec.ts (the entry that uses join(srcDir,
'order-service.ts')), change the line property from 2 to 3 so it points at the
actual class declaration line (`export class PlaceOrder {`) rather than the
JSDoc line.
In `@packages/riviere-cli/src/features/extract/entrypoint/extract.ts`:
- Around line 211-217: The catch in parseJsonFile swallows the JSON parse error;
update parseJsonFile to capture the thrown error (e.g., catch (err)) and pass
the error message/details into exitWithRuntimeError so the runtime error
includes the original JSON parse error and the file path, making debugging
easier; reference the parseJsonFile function and the exitWithRuntimeError call
when implementing this change.
Convention rules now have unique IDs (SD, AP, SP, TS, CS, CR, BS prefixes) enabling per-rule audit trails in code reviews. Review agents produce structured verdicts with evidence for every rule instead of category checkboxes. PR feedback rejection rules added to prevent blanket dismissals. Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.claude/agents/bug-scanner.md (1)
8-216:⚠️ Potential issue | 🟠 MajorOver-constrained, machine-parsed output format violates agent prompt guidance.
This file is in
.claude/agents/, and the new PASS/FAIL first-line requirement plus strict template/table mandates enforce a rigid, machine-parsed format. That conflicts with the guidance to keep these prompts flexible and not deterministically parsed. Please relax these requirements (e.g., make them “preferred/encouraged” with examples rather than mandatory).As per coding guidelines, “In the .claude/agents/ directory, for all LLM agent prompt files (e.g., bug-scanner.md, code-review.md), do not enforce rigid, machine-parsed output format specifications. These prompts are consumed by LLMs that can handle flexible formats, and over-constraining the expected output provides no benefit since the output is not parsed deterministically by code.”
.claude/agents/code-review.md (1)
111-124: 🧹 Nitpick | 🔵 TrivialRedundant reminders: PASS/FAIL requirement repeated 4 times.
The requirement for "PASS" or "FAIL" on the first line is stated at:
- Line 8 (CRITICAL instruction)
- Line 40 (Verdict section)
- Line 114 (Pre-response checklist)
- Line 122 (REMINDER section)
While emphasis is valuable, this level of repetition adds noise and maintenance burden. Consider consolidating to 2 mentions: once in the main instructions (line 8-10) and once in the pre-response checklist (line 114).
🤖 Fix all issues with AI agents
In @.claude/agents/code-review.md:
- Around line 8-10: There is a contradiction between the hard requirement line
"CRITICAL: Your very first output line MUST be exactly `PASS` or `FAIL`." and
the learning statement that says not to enforce rigid, machine-parsed output
formats; resolve by choosing one approach and updating the doc: either
remove/soften the "CRITICAL: Your very first output line MUST be exactly `PASS`
or `FAIL`." clause (or make it optional/annotated with why an orchestrator needs
it), or update the learning statement to acknowledge the orchestrator
requirement; ensure you change the exact quoted rule text and the learning
sentence so both are consistent and include brief rationale for the chosen
design.
- Around line 58-78: The "Full Audit Trail" requirement forces every PR to
include verdict rows for all 54 rules (SD-001..SD-021, AP-001..AP-006,
SP-001..SP-002, TS-001..TS-011, CS-001..CS-008, CR-001..CR-006), creating
excessive noise; change this to a scoped-audit policy that evaluates only
applicable rule sets based on changed files: detect file types/paths in the PR
and map them to rule groups (e.g., docs → CR-only, tests → TS + relevant SD/AP,
production code → full audit), generate verdict rows only for rules in the
selected groups, and mark other groups as intentionally out-of-scope (no
per-rule N/A rows) while keeping at least a summary line stating which rule sets
were evaluated; update the "Full Audit Trail" section and any code that renders
the audit table to implement this mapping and selection logic.
In `@docs/conventions/software-design.md`:
- Line 7: The document contains a duplicate "SD-001" heading which creates
conflicting anchors/TOC links; locate the second "SD-001" heading and either
rename it to a distinct title (suggestion: "SD-001: Fail-Fast Error Handling
(Details)") or convert it into a subheading beneath the primary SD-001 section,
then update any internal links/TOC references that point to the old duplicate
anchor so they reference the new unique heading.
- Line 365: The heading "SD-021: YAGNI - You Aren't Gonna Need It" uses informal
wording; update the title and any occurrences of "gonna" in the SD-021 section
to the formal phrase "going to" (e.g., change "You Aren't Gonna Need It" to "You
Aren't Going to Need It" or "You Are Not Going to Need It") to match the
conventions document tone and ensure consistency across the SD-021 section.
Sonnet was hardcoded but fails to comply with strict audit output format. Opus is more reliable at following verdict-first output constraints. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Agents narrate before outputting PASS/FAIL. Scan first 5 lines for verdict instead of requiring it on line 1 exactly. Co-Authored-By: Claude Opus 4.5 <[email protected]>
watchCI returned success immediately when check_runs was empty, treating it as "no CI configured". In practice, checks take time to register after push. Now polls until checks appear. Also fixes pre-existing test failure: missing GITHUB_TOKEN in watchCI test setup. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…dule Moves validation logic (file loading, JSON parsing, format checking) from extract.ts into draft-component-loader.ts with DraftComponentLoadError. Replaces 4 slow integration tests with fast unit tests. Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tools/dev-workflow/platform/infra/external-clients/github-rest-client.spec.ts (1)
303-318:⚠️ Potential issue | 🟡 MinorRestore the original GITHUB_TOKEN after tests.
Deleting unconditionally can erase a pre-set token and affect other suites. Restore to the prior value instead.
🔧 Suggested fix
describe('github.watchCI', () => { + const originalToken = process.env.GITHUB_TOKEN beforeEach(() => { vi.clearAllMocks() process.env.GITHUB_TOKEN = 'test-token' @@ }) afterEach(() => { - delete process.env.GITHUB_TOKEN + if (originalToken === undefined) { + delete process.env.GITHUB_TOKEN + } else { + process.env.GITHUB_TOKEN = originalToken + } })
Write per-step and total duration to reviews/{branch}/timings.md
after each workflow execution. Timing data collected in the generic
workflow runner, written to file by run-workflow.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@docs/conventions/software-design.md`:
- Line 299: Locate the run-on sentence in the documentation section flagged by
the reviewer (the sentence that joins two independent clauses without proper
punctuation) and fix it by either adding a coordinating conjunction with a comma
(e.g., ", and" or ", but") between the clauses or by splitting it into two
separate sentences; ensure the second clause is capitalized and punctuation/verb
agreement remains correct after the change.
In `@tools/dev-workflow/platform/domain/workflow-execution/run-workflow.ts`:
- Around line 14-23: The exported function runWorkflow references non-exported
types WorkflowOptions, ContextBuilder, and ResultFormatter which causes
declaration emit errors; fix this by exporting those type declarations (add the
export keyword to the WorkflowOptions interface and to the ContextBuilder and
ResultFormatter type/interface declarations or re-export them from this module)
so the public signature only uses exported symbols, and update any
imports/exports if those types live in another file.
…emit ContextBuilder, ResultFormatter, and WorkflowOptions were not exported, preventing TypeScript from emitting declarations for exported runWorkflow. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|



Closes #166
Deliverable: CLI flags for strict/lenient modes, two-pass workflow, and output control
Context
PRD:
docs/project/PRD/active/PRD-phase-11-metadata-extraction.md— Milestone 2, Deliverable D2.6The extraction CLI needs flags to control strictness (fail vs warn on missing fields), enable two-pass workflows (components-only then enrich), and manage output.
Traceability
Acceptance Criteria
--allow-incompleteflag: warn and continue, output includes_missingarrays--components-onlyflag: skip metadata extraction (Phase 10 behavior)--enrich <file>flag: read draft components from file, apply extraction rules--dry-runflag: validate config, report what would be extracted, no output file-o <file>flag: output to file instead of stdoutError: [CATEGORY] CODE\n Description.\n Location: file:line\n Suggestion: how to fixEdge Case Scenarios
--allow-incompletewith all fields present → no_missingarray, exit 0--allow-incompletewith missing fields →_missingarray populated, warnings printed, exit 0--enrichwith invalid JSON → exit 3 (runtime error)--enrichwith file not found → exit 3 (runtime error)--dry-runwith invalid config → exit 2 (config validation)-oto read-only path → exit 3 (runtime error)--components-only --enrich→ error (mutually exclusive)Implementation Guidelines
packages/riviere-cli/src/commands/extract/extract.ts_missing: string[]to component outputEmbedded Reasoning
Why: Different workflows need different strictness. CI wants strict (fail fast). Incremental adoption wants lenient. Two-pass enables AI-assisted completion.
What: 5 new flags controlling extraction behavior and output.
How: Commander.js options, conditional logic in extract command, structured error handling.
Testing Strategy
Dependencies
Depends on #165
Verification
Amendment
Amendment: The acceptance criteria for error message format and categories should reflect the existing JSON output pattern used by the CLI (formatError/formatSuccess in output.ts). The codebase uses structured JSON output ({success, error: {code, message, suggestions}}) rather than human-readable text. The CliErrorCode enum already defines error categories (ConfigNotFound, ValidationError). The --help output is auto-generated by Commander.js from option definitions and requires no separate implementation.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.