Skip to content

feat(dev-workflow-v2): route reviews through record-review - #366

Merged
NTCoding merged 6 commits into
mainfrom
issue-363
Apr 26, 2026
Merged

NTCoding merged 6 commits into
mainfrom
issue-363

Conversation

@NTCoding

@NTCoding NTCoding commented Apr 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • replace custom dev-workflow-v2 review recording commands with the platform record-review flow
  • fold REVIEWING gate decisions from review-recorded events, including required task-check handling and latest-review-wins behavior
  • update review agent contracts and tests so valid PASS and FAIL reviews are recorded while invalid review JSON is rejected

Summary by CodeRabbit

  • New Features

    • Added unified review recording system that consolidates multiple review operations into a single command.
    • Introduced conditional task-check review requirement based on GitHub issue presence.
  • Improvements

    • Standardized review agent output format to consistent JSON schema across all review types.
    • Enhanced review tracking with new methods to list and retrieve recorded review history.

@coderabbitai

coderabbitai Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@NTCoding has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 24 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 59 minutes and 24 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 54ae1be1-0da7-4f72-9ded-5334e3daa72c

📥 Commits

Reviewing files that changed from the base of the PR and between d1240b3 and fa4986c.

📒 Files selected for processing (16)
  • tools/dev-workflow-v2/agents/architecture-review.md
  • tools/dev-workflow-v2/agents/task-check.md
  • tools/dev-workflow-v2/src/features/workflow/domain/fixtures/review-command-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fixtures/workflow-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fold-review-recorded.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fold.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/output-messages.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-event-types.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-reviewing-submitting.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli-transitions.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/infra/persistence/workflow-definition.ts
  • tools/dev-workflow-v2/states/reviewing.md
📝 Walkthrough

Walkthrough

This PR consolidates review outcome recording into a unified platform mechanism, replacing multiple agent-specific record-*-passed/failed operations with a single record-review operation that handles verdict-based state updates via review-recorded events. Review agents now output structured JSON (verdict, summary, findings) instead of file-based reports.

Changes

Cohort / File(s) Summary
Release & Dependencies
tools/dev-workflow-v2/.claude-plugin/plugin.json, tools/dev-workflow-v2/package.json
Plugin version bumped to 0.0.40; workflow agent dependencies upgraded from 0.3.4 to 0.3.6.
Agent Documentation
tools/dev-workflow-v2/agents/architecture-review.md, tools/dev-workflow-v2/agents/bug-scanner.md, tools/dev-workflow-v2/agents/code-review.md, tools/dev-workflow-v2/agents/task-check.md
Agent output contracts changed from file-based audit reports to structured JSON: verdict, one-sentence summary, and findings array (empty on PASS).
Platform & State Documentation
tools/dev-workflow-v2/PRD-platform-cli-layer.md, tools/dev-workflow-v2/states/reviewing.md
Platform record-review route now unifies review outcome handling; SUBMITTING_PR gate extends to conditionally require task-check when githubIssue is present.
Event System
tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts, tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.spec.ts, tools/dev-workflow-v2/src/features/workflow/domain/workflow-types.ts
New review-recorded event discriminant added; new exports parseWorkflowEvent and getKnownWorkflowEventTypes; new LivingArchitectureReviewType enum consolidates architecture-review, code-review, bug-scanner, task-check types; record-review operation replaces granular record-*-passed/failed variants.
Event Folding & Processing
tools/dev-workflow-v2/src/features/workflow/domain/fold.ts, tools/dev-workflow-v2/src/features/workflow/domain/fold-review-recorded.spec.ts, tools/dev-workflow-v2/src/features/workflow/infra/persistence/workflow-definition.ts
New applyRecordedReviewVerdict logic parses review-recorded events and updates corresponding state flags; event validation switched from schema-driven to function-based parsing; new test coverage for review verdict application.
State Machine & Review Handling
tools/dev-workflow-v2/src/features/workflow/domain/states/implementing.ts, tools/dev-workflow-v2/src/features/workflow/domain/states/reviewing.ts, tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts, tools/dev-workflow-v2/src/features/workflow/domain/workflow-predicates.ts, tools/dev-workflow-v2/src/features/workflow/domain/output-messages.spec.ts
Implementing state initializes taskCheckPassed: false; reviewing state consolidates record operations to single record-review; task-check requirement now conditional on githubIssue presence; workflow gains review listing/retrieval methods; WorkflowDeps extended with listSessionReviews.
Domain Fixtures & Tests
tools/dev-workflow-v2/src/features/workflow/domain/fixtures/workflow-test-fixtures.ts, tools/dev-workflow-v2/src/features/workflow/domain/workflow-implementing.spec.ts, tools/dev-workflow-v2/src/features/workflow/domain/workflow-reviewing-submitting.spec.ts
New reviewRecorded helper emits unified review-recorded events; test fixtures updated to use review-recorded events; reviewing-submitting tests refactored to verify review storage integration and validate transition guards.
CLI Routes & Commands
tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.ts, tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.spec.ts, tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli-transitions.spec.ts
Removed recording routes for individual review types; new record-review command with --type argument; tests refactored to use unified review recording with task-check coverage and negative path validation.
CLI Fixtures & Infrastructure
tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts, tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-state-steps-test-fixtures.ts, tools/dev-workflow-v2/src/shell/cli.ts, tools/dev-workflow-v2/src/shell/opencode-plugin.ts, tools/dev-workflow-v2/src/features/workflow/infra/persistence/workflow-definition.spec.ts
New runReviewCommand and runReviewCommandWithInput helpers for testing; state step fixtures updated to use record-review --type; CLI and plugin wiring added listSessionReviews dependency propagation.

Sequence Diagram

sequenceDiagram
    actor Agent as Review Agent
    participant CLI as Workflow CLI
    participant Engine as Workflow Engine
    participant Store as Platform Store

    Agent->>CLI: Output review JSON<br/>(verdict, summary, findings)
    CLI->>Engine: record-review --type <type><br/>(via stdin)
    Engine->>Store: listSessionReviews()
    Store-->>Engine: []
    Engine->>Store: Create review record
    Store-->>Engine: StoredReview
    Engine->>Engine: Emit review-recorded event
    Engine->>Engine: applyRecordedReviewVerdict()<br/>Update state flag
    Engine-->>CLI: Success
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Suggested labels

Review effort 4/5

Poem

🐰 Review records hop along,
Unified paths where verdicts belong,
No more scattered reports to keep—
One record-review makes the state leap,
Task-check joins the harmony song!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(dev-workflow-v2): route reviews through record-review' accurately and concisely describes the main change: consolidating multiple review recording commands into a single unified review recording mechanism.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-363

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Deploying living-architecture with  Cloudflare Pages  Cloudflare Pages

Latest commit: fa4986c
Status: ✅  Deploy successful!
Preview URL: https://228bf77e.living-architecture.pages.dev
Branch Preview URL: https://issue-363.living-architecture.pages.dev

View logs

coderabbitai[bot]
coderabbitai Bot previously requested changes Apr 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
tools/dev-workflow-v2/agents/task-check.md (1)

92-113: ⚠️ Potential issue | 🟡 Minor

Same response/written-report ambiguity as architecture-review.md.

Line 94 says "Your response must include:" followed by a criteria checklist and PRD compliance section (Markdown), while Line 105 ("Output Format") then prescribes a JSON-only response. The agent receives two contradictory instructions about what its actual reply contains. Clarify that lines 96-101 describe the contents of the verification report written to "Report Path", not the JSON response.

📝 Suggested wording
-## Verification Report
-
-Your response must include:
+## Verification Report (written to Report Path)
+
+The report file you write must contain:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/dev-workflow-v2/agents/task-check.md` around lines 92 - 113, Clarify
the ambiguity between the human-readable "Verification Report" checklist section
and the machine "Output Format" JSON by updating the document so it explicitly
states that the checklist, PRD compliance section, and unmet-criteria details
are the contents of the separate verification report written to the Report Path
(the human-readable report), while the agent's immediate response must be the
JSON object matching the schema under "Output Format"
(verdict/summary/findings); reference the section headings "Verification Report"
and "Output Format" so reviewers can find and verify the change.
tools/dev-workflow-v2/agents/architecture-review.md (1)

51-98: ⚠️ Potential issue | 🟡 Minor

Audit Report section conflicts with JSON-only response contract.

Line 29 instructs the agent to "return review JSON" after writing the report file, but Line 53 introduces this section with "Your response must include, in this exact order:" followed by Findings, Audit Trail, and Audit Summary. Read literally, the agent is told to return both Markdown sections and JSON, which will likely cause it to emit free-form text alongside or instead of the parseable JSON payload that record-review consumes.

Reword this header so it is unambiguous that this describes the contents of the file written to "Report Path", not the agent's response.

📝 Suggested wording
-## Audit Report
-
-Your response must include, in this exact order:
+## Audit Report (written to Report Path)
+
+The report file you write must contain, in this exact order:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/dev-workflow-v2/agents/architecture-review.md` around lines 51 - 98,
The "Audit Report" header creates a conflict with the JSON-only response
contract by instructing both free-form sections and "return review JSON"; update
the phrasing around the block that starts with "Your response must include, in
this exact order:" so it clearly states that those sections (Findings, Full
Audit Trail, Audit Summary) are the expected contents of the file written to
"Report Path" and not the agent's HTTP response; specifically, change the
sentence that references "return review JSON" and the header text to explicitly
say "Write the following content to Report Path (the report file) in this exact
order; the agent's API response must still return only the JSON payload as
specified elsewhere," and ensure the literal strings "return review JSON" and
"Your response must include, in this exact order:" are adjusted to remove
ambiguity (affecting the Audit Report header and surrounding instructions).
tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts (1)

119-138: 🧹 Nitpick | 🔵 Trivial

LGTM, with a minor note on step shape coupling.

progressToState reads step[2] as the review type but doesn't assert step[1] === '--type', so a future change to the step format in STATE_STEPS could silently misinterpret arguments. Given this is a private test fixture and the only writers are also internal, this is fine — but a one-line invariant check (or destructuring with a runtime guard) would make the contract explicit.

♻️ Optional tightening
-    if (step[0] === 'record-review') {
-      const reviewType = step[2]
-      if (reviewType === undefined) {
-        throw new WorkflowStateError('Expected review type for record-review test step.')
-      }
+    if (step[0] === 'record-review') {
+      if (step[1] !== '--type' || step[2] === undefined) {
+        throw new WorkflowStateError(
+          "Expected record-review test step shape ['record-review', '--type', <reviewType>].",
+        )
+      }
+      const reviewType = step[2]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts`
around lines 119 - 138, The function progressToState should validate the shape
of 'record-review' steps from STATE_STEPS before reading step[2]; update
progressToState to assert or guard that for steps where step[0] ===
'record-review' the step array has at least three elements and step[1] ===
'--type' (or destructure like const [cmd, flag, reviewType] and check flag ===
'--type' && reviewType), and if the check fails throw a WorkflowStateError with
a clear message; then continue to call runReviewCommand(ctx, reviewType, ...) as
before so malformed STATE_STEPS cannot silently misinterpret arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@tools/dev-workflow-v2/src/features/workflow/domain/fixtures/workflow-test-fixtures.ts`:
- Around line 84-95: The fixture reviewRecorded currently hardcodes reviewId: 1
which makes events share the same ID; change reviewRecorded to assign a unique
incremental ID per call (e.g., introduce a module-level counter like
nextReviewId and use/increment it inside reviewRecorded) so each returned
WorkflowEvent has a distinct reviewId; update references to reviewId in the
function signature/return only, leaving reviewType and verdict unchanged.

In `@tools/dev-workflow-v2/src/features/workflow/domain/fold.spec.ts`:
- Around line 233-270: The test suite is missing coverage for the code-review
and bug-scanner branches in applyRecordedReviewVerdict invoked via applyEvent;
add tests similar to the existing ones that create WorkflowEvent objects with
reviewType 'code-review' and 'bug-scanner' (each with verdict 'PASS' and 'FAIL'
where applicable), call applyEvent(EMPTY_STATE, event) or with a pre-set state,
and assert the corresponding state flags or fields updated by
applyRecordedReviewVerdict (mirror how taskCheckPassed and
architectureReviewPassed are asserted) to ensure both PASS and FAIL behavior for
code-review and bug-scanner are covered.

In `@tools/dev-workflow-v2/src/features/workflow/domain/fold.ts`:
- Around line 4-32: The switch in applyRecordedReviewVerdict is not exhaustive
and can return undefined for new review types; add an explicit exhaustiveness
assertion fallback (e.g., a default case that calls an assertNever-like helper
or throws with the unexpected reviewType) so every branch returns a
WorkflowState; reference applyRecordedReviewVerdict and the event.reviewType
discriminant, and either import/define assertNever or throw an Error including
the unexpected event.reviewType to ensure the function never silently returns
undefined.

In `@tools/dev-workflow-v2/src/features/workflow/domain/output-messages.spec.ts`:
- Around line 14-16: The test title "handles three-word operations" is
misleading because it asserts getOperationBody('record-review') (two words);
update the spec so the test name matches behavior: either remove this redundant
it-block entirely, or change the asserted input to a true 3+ word operation
(e.g., pass a hyphenated string like 'record-feedback-clean' to
getOperationBody) and update the expectation accordingly; locate the test in
output-messages.spec.ts referencing getOperationBody to apply the change.

In `@tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.spec.ts`:
- Around line 256-289: Add negative test cases to the existing REVIEW block to
assert enum validation on WORKFLOW_EVENT_SCHEMA: inside the
describe('WORKFLOW_EVENT_SCHEMA — review-recorded') add tests that call
WORKFLOW_EVENT_SCHEMA.parse with an unknown verdict (e.g. verdict: 'MAYBE' or
'pass') and with an unknown reviewType (e.g. reviewType: 'arch-review') and
assert they throw (use expect(() =>
WORKFLOW_EVENT_SCHEMA.parse(...)).toThrow(...) or a toThrow matching the Zod
error). This targets the enum constraints for verdict and reviewType so
malformed review JSON is rejected; keep the same surrounding fields (type:
'review-recorded', at: AT, reviewId) in each test.

In
`@tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli-transitions.spec.ts`:
- Around line 153-304: Duplicate review setup across tests should be extracted
into a reusable helper: create a fixture helper (e.g., function
applyStandardReviewBatch or recordStandardReviews) that accepts the test context
(ctx) and an optional task-check verdict, and inside calls runReviewCommand for
'architecture-review', 'code-review', 'bug-scanner' (all PASS) and conditionally
runReviewCommand for 'task-check' with the provided verdict; replace the
repeated blocks in the five tests with a single call to this helper and move the
helper into a new fixtures module alongside the spec so other tests can import
it.

In `@tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.spec.ts`:
- Around line 218-231: Update the "blocks workflow without recording review when
reviewer omits required fields" test to mirror the invalid-JSON test by also
asserting that no "review-recorded" event was appended; after calling
runReviewCommandWithInput and the existing assertions on
exitCode/output/listSessionReviews, add an assertion against
ctx.engineDeps.store's event list (the same event-check used in the invalid-JSON
test) to ensure it does not contain a review-recorded event (use the same helper
or expectation pattern as in the invalid-JSON test so the test fails if a bogus
review-recorded event is persisted).

---

Outside diff comments:
In `@tools/dev-workflow-v2/agents/architecture-review.md`:
- Around line 51-98: The "Audit Report" header creates a conflict with the
JSON-only response contract by instructing both free-form sections and "return
review JSON"; update the phrasing around the block that starts with "Your
response must include, in this exact order:" so it clearly states that those
sections (Findings, Full Audit Trail, Audit Summary) are the expected contents
of the file written to "Report Path" and not the agent's HTTP response;
specifically, change the sentence that references "return review JSON" and the
header text to explicitly say "Write the following content to Report Path (the
report file) in this exact order; the agent's API response must still return
only the JSON payload as specified elsewhere," and ensure the literal strings
"return review JSON" and "Your response must include, in this exact order:" are
adjusted to remove ambiguity (affecting the Audit Report header and surrounding
instructions).

In `@tools/dev-workflow-v2/agents/task-check.md`:
- Around line 92-113: Clarify the ambiguity between the human-readable
"Verification Report" checklist section and the machine "Output Format" JSON by
updating the document so it explicitly states that the checklist, PRD compliance
section, and unmet-criteria details are the contents of the separate
verification report written to the Report Path (the human-readable report),
while the agent's immediate response must be the JSON object matching the schema
under "Output Format" (verdict/summary/findings); reference the section headings
"Verification Report" and "Output Format" so reviewers can find and verify the
change.

In
`@tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts`:
- Around line 119-138: The function progressToState should validate the shape of
'record-review' steps from STATE_STEPS before reading step[2]; update
progressToState to assert or guard that for steps where step[0] ===
'record-review' the step array has at least three elements and step[1] ===
'--type' (or destructure like const [cmd, flag, reviewType] and check flag ===
'--type' && reviewType), and if the check fails throw a WorkflowStateError with
a clear message; then continue to call runReviewCommand(ctx, reviewType, ...) as
before so malformed STATE_STEPS cannot silently misinterpret arguments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 862fe2a0-2f1d-4153-ab79-134deb661a9c

📥 Commits

Reviewing files that changed from the base of the PR and between ac51e7d and a862615.

📒 Files selected for processing (24)
  • tools/dev-workflow-v2/.claude-plugin/plugin.json
  • tools/dev-workflow-v2/PRD-platform-cli-layer.md
  • tools/dev-workflow-v2/agents/architecture-review.md
  • tools/dev-workflow-v2/agents/bug-scanner.md
  • tools/dev-workflow-v2/agents/code-review.md
  • tools/dev-workflow-v2/agents/task-check.md
  • tools/dev-workflow-v2/src/features/workflow/domain/fixtures/workflow-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fold.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fold.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/output-messages.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/states/implementing.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/states/reviewing.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-implementing.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-reviewing-submitting.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-types.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-state-steps-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli-transitions.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.ts
  • tools/dev-workflow-v2/states/reviewing.md
💤 Files with no reviewable changes (2)
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/workflow-cli.ts

Comment thread tools/dev-workflow-v2/src/features/workflow/domain/fold.spec.ts Outdated
Comment thread tools/dev-workflow-v2/src/features/workflow/domain/fold.ts
Comment thread tools/dev-workflow-v2/src/features/workflow/domain/output-messages.spec.ts Outdated
Comment thread tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.spec.ts Outdated
Comment thread tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts Outdated
@NTCoding
NTCoding dismissed coderabbitai[bot]’s stale review April 26, 2026 15:07

Stale automated review after follow-up changes on issue-363.

@NTCoding

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]
coderabbitai Bot previously requested changes Apr 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

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-v2/src/features/workflow/domain/fold.ts (1)

56-72: 🧹 Nitpick | 🔵 Trivial

Optional: the stateOverrides === undefined early return is a no-op vs the prior spread.

Spreading undefined (...stateOverrides when stateOverrides is undefined) is a no-op in JS, so the new branch produces an object identical to the original return block. The fork is harmless but adds a path to keep in sync; if there's no other reason for the split, you can drop it and keep the single return. Not blocking.

♻️ Optional simplification
-  const stateOverrides = event.stateOverrides
-  if (stateOverrides === undefined) {
-    return {
-      ...state,
-      currentStateMachineState: event.to,
-      preBlockedState: newPreBlockedState,
-    }
-  }
-
-  return {
-    ...state,
-    ...stateOverrides,
-    currentStateMachineState: event.to,
-    preBlockedState: newPreBlockedState,
-  }
+  return {
+    ...state,
+    ...(event.stateOverrides ?? {}),
+    currentStateMachineState: event.to,
+    preBlockedState: newPreBlockedState,
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/dev-workflow-v2/src/features/workflow/domain/fold.ts` around lines 56 -
72, The conditional branch that checks stateOverrides === undefined is redundant
because spreading undefined is a no-op; simplify fold by removing the if/early
return and replace both returns with a single return that spreads ...state,
...stateOverrides, sets currentStateMachineState to event.to and preBlockedState
to newPreBlockedState (keep the existing newPreBlockedState computation and the
stateOverrides variable), so update the function around
newPreBlockedState/stateOverrides to return one consolidated object instead of
two branches.
♻️ Duplicate comments (1)
tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts (1)

128-131: 🧹 Nitpick | 🔵 Trivial

getKnownWorkflowEventTypes is structurally fragile to future option shapes.

schema.shape.type.value assumes every union option is a z.object with a literal type. Today it is, but Zod's discriminatedUnion permits nested discriminated unions and z.object().extend(...) chains where .shape exposure varies. Since this list is consumed by workflow-definition.ts to decide whether an event is "known" (and therefore whether to throw vs. pass through unknown platform events), a silent breakage here would mis-route real engine events as "unknown" — the opposite of fail-safe.

Consider deriving the names from the source-of-truth literals you control (the z.literal('...') discriminator strings), or adding a tiny unit test that asserts the returned set against the expected list so a future schema swap breaks loudly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts` around
lines 128 - 131, getKnownWorkflowEventTypes currently assumes each
WORKFLOW_EVENT_SCHEMA option exposes schema.shape.type.value (i.e., a flat
z.object with a z.literal), which is fragile for nested discriminated unions or
extended objects; update it to derive the discriminator values from a stable
source-of-truth instead of depending on .shape: either (A) maintain and read
from an explicit constant list of allowed event type strings (use that constant
in workflow-definition.ts and here), or (B) implement a robust extractor that
walks WORKFLOW_EVENT_SCHEMA options to locate the z.literal discriminator
(handling nested unions/extends) and returns those literal values; also add a
unit test that asserts getKnownWorkflowEventTypes() equals the expected list of
discriminators so schema changes fail loudly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@tools/dev-workflow-v2/src/features/workflow/domain/fixtures/workflow-test-fixtures.ts`:
- Line 31: The fixture's makeDeps().listSessionReviews currently always returns
an empty array, diverging from fixture methods that emit review-recorded events
(reviewRecorded(...), allReviewsPassed()), so update the fixture to maintain an
internal in-memory review log that those helper functions append to and have
makeDeps().listSessionReviews return a readonly snapshot of that log;
specifically modify the helpers (reviewRecorded, allReviewsPassed) to push
StoredReview entries into the fixture-side array and change
makeDeps().listSessionReviews to return that array (or a shallow copy) so
Workflow.getRecordedReviews() and getLatestReviewByType() see the same reviews
emitted by the fixture while still allowing tests to override listSessionReviews
when needed.

In
`@tools/dev-workflow-v2/src/features/workflow/domain/workflow-reviewing-submitting.spec.ts`:
- Around line 118-137: The test directly calls
getReviewingTransitionGuard()/reviewingState.transitionGuard with a handcrafted
TransitionContext and asserts the exact human-readable reason string, which
makes the spec brittle; update the test to either (a) drive the transition
through the engine using the existing spec.given(...).when(...) pattern used
elsewhere (so engine-level checks like currentStateMachineState/from/to are
exercised consistently), or (b) keep the unit guard call to
getReviewingTransitionGuard() but stop asserting the full prose in result.reason
— instead assert result.pass === false and assert on a structured marker (e.g.,
inspect result.unmetReviews or that result.reason contains the specific unmet
review identifiers such as 'architecture-review', 'code-review', 'bug-scanner')
so the test verifies behavior without being tied to exact copyedits of the human
message.
- Line 31: The createdAt timestamp template in createStoredReview embeds the raw
id into the seconds field, which breaks for ids >= 10; update the createdAt
construction in workflow-reviewing-submitting.spec.ts (the createStoredReview
test helper) to produce a valid ISO-8601 seconds value by zero-padding the id to
two digits (e.g., use String(id).padStart(2, '0')) or by building the Date/ISO
string from a Date object so seconds are always two digits and valid for all
ids.

In `@tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts`:
- Around line 204-209: getLatestReviewByType currently picks the last element
from reviewsOfType using reviewsOfType.at(-1), which is unsafe if the source
ordering isn't guaranteed; update getLatestReviewByType to sort reviewsOfType by
their createdAt timestamp (e.g., ascending) and then return the last element so
the function deterministically returns the most recent StoredReview; reference
the getLatestReviewByType method and the RecordedReview/StoredReview.createdAt
field (or the output of getRecordedReviews()/WorkflowDeps.listSessionReviews)
when implementing the sort.

In
`@tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts`:
- Around line 124-136: The loop handling 'record-review' in progressToState
currently always sets verdict: 'PASS' when calling runReviewCommand(ctx,
reviewType, ...), which hides non-passing scenarios; update this branch to (a)
read an optional verdict from step[3] (e.g., const verdict = step[3] ?? 'PASS')
and pass that verdict through to runReviewCommand, or if you intend to only
create passing reviews, rename the branch to recordPassingReview and add a JSDoc
comment on progressToState/runReviewCommand usage to document the enforced PASS
behavior so callers aren’t surprised.

In
`@tools/dev-workflow-v2/src/features/workflow/infra/persistence/workflow-definition.ts`:
- Line 47: The Set construction for known workflow event types is being
recreated inside the hot fold path; hoist it to module scope by creating a
single top-level constant (e.g., a module-scoped Set built from
getKnownWorkflowEventTypes()) and replace the local const knownTypes = new
Set(getKnownWorkflowEventTypes()) usage inside the fold routine with that
module-scoped constant so events are checked against the prebuilt Set instead of
allocating a new one per call.

In `@tools/dev-workflow-v2/states/reviewing.md`:
- Around line 60-62: The current transition rules deadlock because the "Cannot
transition to IMPLEMENTING if all 3 reviews passed (go to SUBMITTING_PR
instead)" rule is unconditional; change it to only redirect to SUBMITTING_PR
when the task-check requirement (when githubIssue exists) is satisfied. In other
words, keep the SUBMITTING_PR guard that requires architecture-review,
code-review, bug-scanner and, if githubIssue is present, the latest task-check
to be passed, but modify the IMPLEMENTING guard so it only blocks when the core
3 reviews passed AND (githubIssue is absent OR the latest task-check passed); if
githubIssue exists and task-check failed allow transitioning to IMPLEMENTING.

---

Outside diff comments:
In `@tools/dev-workflow-v2/src/features/workflow/domain/fold.ts`:
- Around line 56-72: The conditional branch that checks stateOverrides ===
undefined is redundant because spreading undefined is a no-op; simplify fold by
removing the if/early return and replace both returns with a single return that
spreads ...state, ...stateOverrides, sets currentStateMachineState to event.to
and preBlockedState to newPreBlockedState (keep the existing newPreBlockedState
computation and the stateOverrides variable), so update the function around
newPreBlockedState/stateOverrides to return one consolidated object instead of
two branches.

---

Duplicate comments:
In `@tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts`:
- Around line 128-131: getKnownWorkflowEventTypes currently assumes each
WORKFLOW_EVENT_SCHEMA option exposes schema.shape.type.value (i.e., a flat
z.object with a z.literal), which is fragile for nested discriminated unions or
extended objects; update it to derive the discriminator values from a stable
source-of-truth instead of depending on .shape: either (A) maintain and read
from an explicit constant list of allowed event type strings (use that constant
in workflow-definition.ts and here), or (B) implement a robust extractor that
walks WORKFLOW_EVENT_SCHEMA options to locate the z.literal discriminator
(handling nested unions/extends) and returns those literal values; also add a
unit test that asserts getKnownWorkflowEventTypes() equals the expected list of
discriminators so schema changes fail loudly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 19203bed-b61b-46a2-a7f4-83bae8bbd00c

📥 Commits

Reviewing files that changed from the base of the PR and between a862615 and d1240b3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • tools/dev-workflow-v2/agents/architecture-review.md
  • tools/dev-workflow-v2/agents/bug-scanner.md
  • tools/dev-workflow-v2/agents/code-review.md
  • tools/dev-workflow-v2/agents/task-check.md
  • tools/dev-workflow-v2/package.json
  • tools/dev-workflow-v2/src/features/workflow/domain/fixtures/workflow-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fold-review-recorded.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/fold.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-events.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-predicates.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow-reviewing-submitting.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts
  • tools/dev-workflow-v2/src/features/workflow/entrypoint/fixtures/workflow-cli-test-fixtures.ts
  • tools/dev-workflow-v2/src/features/workflow/infra/persistence/workflow-definition.spec.ts
  • tools/dev-workflow-v2/src/features/workflow/infra/persistence/workflow-definition.ts
  • tools/dev-workflow-v2/src/shell/cli.ts
  • tools/dev-workflow-v2/src/shell/opencode-plugin.ts
  • tools/dev-workflow-v2/states/reviewing.md

Comment thread tools/dev-workflow-v2/src/features/workflow/domain/workflow.ts
Comment thread tools/dev-workflow-v2/states/reviewing.md Outdated
@NTCoding
NTCoding dismissed coderabbitai[bot]’s stale review April 26, 2026 15:28

Stale automated review after follow-up changes in c58c215.

@sonarqubecloud

Copy link
Copy Markdown

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