Skip to content

feat(api): wiki compose P5 dynamic routing and maintenance graph (#953) - #970

Merged
otomatty merged 4 commits into
developfrom
cursor/wiki-compose-p5-dynamic-routing-7d9d
May 25, 2026
Merged

feat(api): wiki compose P5 dynamic routing and maintenance graph (#953)#970
otomatty merged 4 commits into
developfrom
cursor/wiki-compose-p5-dynamic-routing-7d9d

Conversation

@otomatty

@otomatty otomatty commented May 25, 2026

Copy link
Copy Markdown
Owner

概要

Wiki Compose P5(#953)として、wikiComposeGraph に動的 conditional edge を追加し、新規 wiki-maintenance graph を GraphRegistry に登録しました。

変更点

  • Brief 後分岐 (routeAfterBrief): Brief 0 件、または chatSeed.outline がある場合は skip_research → Structure へ直行
  • Research 後分岐 (routeAfterResearch): 採用 1 件以上かつ却下 2 件以上で conflict_resolution interrupt → Structure
  • wiki-maintenance graph: scan_broken_linksscan_stub_pagesplan_maintenance(lint ルール + content_preview ヒューリスティック)
  • wiki-compose graph version を 1.1.0 に bump

変更の種類

  • ✨ 新機能 (New feature)
  • 🧪 テスト (Tests)

テスト方法

cd server/api && bun install && bun run test:run -- src/__tests__/agents/graphs/wikiCompose src/__tests__/agents/graphs/wikiMaintenance

チェックリスト

  • テストがすべてパスする(該当 Vitest 11 件 + agents 一式 106 件)
  • Lint / Prettier(pre-commit 通過)
  • 必要に応じてドキュメントを更新した(TSDoc を routing / graph モジュールに追加済み)
  • コミットメッセージが Conventional Commits に従っている

関連 Issue

Closes #953

受け入れ条件(Issue #953

  • 最低 2 つの conditional edge 分岐が wikiComposeGraph に追加
  • 分岐ごとに Vitest(wikiComposeRouting.test.ts + graph 統合)
  • 新 graph が GraphRegistry パターンに従って追加(wiki-maintenance
  • TSDoc に非目標・拡張ポイントを記載(routing.ts, wikiComposeGraph.ts, wikiMaintenanceGraph.ts

意図的にスコープ外(P5 非目標)

  • media_curator subgraph、Draft 失敗時の escalate_to_orchestrator、セッション 30 日 TTL、checkpoint GC
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Tests

    • Added coverage for compose routing, interrupt/resume behavior, conflict-resolution, and the new maintenance workflow.
  • New Features

    • Conflict-resolution flow for research results with a UI acknowledgement step and new "conflict" phase.
    • Option to skip the research phase when briefing supplies no questions or an outline.
    • New wiki maintenance workflow that scans issues and emits a maintenance plan.
    • Compose workflow version bumped to reflect conditional branching.

Review Change Stack

- Add routeAfterBrief and routeAfterResearch conditional edges to wikiComposeGraph
- Add skip_research and conflict_resolution nodes with Vitest coverage
- Register wiki-maintenance graph (broken links + stub page scan)
- Bump wiki-compose graph version to 1.1.0

Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds conditional routing and conflict-resolution interrupts to Wiki Compose, implements skipResearch/conflictResolution nodes and resume validation, introduces a linear Wiki Maintenance graph (scan → plan), updates state/types/UI/hooks/projections, integrates exports and app registration, and adds unit/integration tests.

Changes

Wiki Compose P5 & Wiki Maintenance Orchestration

Layer / File(s) Summary
Graph integration and tests
server/api/src/__tests__/agents/graphs/wikiCompose/wikiComposeGraph.test.ts, server/api/src/__tests__/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.test.ts, server/api/src/__tests__/agents/graphs/wikiCompose/wikiComposeRouting.test.ts, server/api/src/__tests__/routes/composeSessionProjection.test.ts
Integration and unit tests validate brief-skip, conflict-resolution interrupt/resume, routing predicates, and wiki-maintenance graph execution with mocked scans.
Routing helpers & interrupt types
server/api/src/agents/graphs/wikiCompose/routing.ts, server/api/src/agents/graphs/wikiCompose/types.ts, server/api/src/agents/graphs/wikiCompose/resumeSchemas.ts
Adds pure routing predicates (routeAfterBrief, shouldResolveResearchConflicts, routeAfterResearch), route union types, ResearchConflictSummary, and conflictResumeSchema/inferred resume type.
Compose state & briefDialogue fallback
server/api/src/agents/graphs/wikiCompose/state.ts, server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts
Adds briefDegraded and researchConflicts channels; briefDialogue sets briefDegraded when LLM fallback emits zero questions.
Skip Research & Conflict Resolution nodes
server/api/src/agents/graphs/wikiCompose/nodes/skipResearch.ts, server/api/src/agents/graphs/wikiCompose/nodes/conflictResolution.ts, server/api/src/agents/graphs/wikiCompose/nodes/index.ts
Implements skipResearch (bypass research) and conflictResolution (HITL interrupt with summary, resume validation, clearing conflicts); barrel re-exports updated.
Wiki Compose graph wiring & version
server/api/src/agents/graphs/wikiCompose/wikiComposeGraph.ts, server/api/src/agents/graphs/wikiCompose/index.ts
Wires conditional edges after brief (plan_queries vs skip_research) and after research (structure vs conflict_resolution → structure), registers nodes, bumps graph version to 1.1.0, and updates public re-exports.
Resume schema & exit reason
server/api/src/agents/graphs/wikiCompose/resumeSchemas.ts, server/api/src/agents/subgraphs/research/types.ts
Adds conflictResumeSchema and extends ExitReason with brief_skip.
Wiki Maintenance types & state
server/api/src/agents/graphs/wikiMaintenance/types.ts, server/api/src/agents/graphs/wikiMaintenance/state.ts
Defines MaintenanceFinding and MaintenancePlan types and WikiMaintenanceState with finding arrays and optional maintenancePlan.
Maintenance scan nodes, planner & graph
server/api/src/agents/graphs/wikiMaintenance/nodes/scanBrokenLinks.ts, server/api/src/agents/graphs/wikiMaintenance/nodes/scanStubPages.ts, server/api/src/agents/graphs/wikiMaintenance/nodes/planMaintenance.ts, server/api/src/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.ts, server/api/src/agents/graphs/wikiMaintenance/index.ts
Implements scan nodes querying lint rules and DB, planMaintenance aggregates findings into a plan, and registers a linear wiki-maintenance graph.
Public exports & app integration
server/api/src/agents/index.ts, server/api/src/app.ts, server/api/src/routes/composeSessions.ts, server/api/src/agents/graphs/wikiCompose/index.ts
Barrel exports updated to expose routing helpers and maintenance graph surface; registerWikiMaintenanceGraph() added to app startup; recursion limit for maintenance graph set to 40.
Projection, UI, hook, and page wiring
server/api/src/routes/composeSessionProjection.ts, src/components/wikiCompose/ConflictResolutionSection.tsx, src/components/wikiCompose/ComposePanel.tsx, src/components/wikiCompose/PhaseStepper.tsx, src/hooks/useWikiComposeSession.ts, src/pages/WikiComposePage.tsx, src/lib/wikiCompose/types.ts
Projects conflict_resolution interrupts to UI phase: "conflict" with researchConflictSummary; adds ConflictResolutionSection UI, integrates submit handler, maps conflict to research in PhaseStepper, extends hook with researchConflictSummary, SSE handler, and submitConflictAck.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • otomatty/zedi#961: Related—adds chatSeed plumbing used by routeAfterBrief to detect outlines and skip research.
  • otomatty/zedi#959: Related—earlier wikiCompose orchestrator work that this PR extends with conditional routing and interrupts.
  • otomatty/zedi#956: Possibly related—changes to compose session/graph plumbing that intersect with recursion/interrupt logic.

"From my burrow I sniff the flow,
Briefs that skip where outlines show,
Conflicts flagged, a human nod —
Structure waits, then on we go,
Maintenance hunts what's gone below."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.87% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main changes: adding P5 dynamic routing to wiki compose graph and implementing a new maintenance graph, directly matching the changeset's primary features.
Linked Issues check ✅ Passed The PR fulfills all acceptance criteria from #953: adds 2+ conditional edges with routing tests, implements new wiki-maintenance graph registered via GraphRegistry, and includes TSDoc documenting non-goals.
Out of Scope Changes check ✅ Passed All changes align with PR objectives. Client-side changes (ConflictResolutionSection, UI hooks) support the conflict_resolution interrupt, and no modifications target explicitly out-of-scope items like media_curator or escalate_to_orchestrator.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/wiki-compose-p5-dynamic-routing-7d9d

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

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request enhances the wikiComposeGraph with conditional routing logic to skip research or handle source conflicts through human-in-the-loop intervention. Additionally, it introduces a new wikiMaintenanceGraph designed to identify broken links and stub pages. A review comment identifies a potential non-determinism issue in the stub page scanning query due to a missing orderBy clause when a limit is applied.

Comment on lines +22 to +35
const rows = await ctx.db
.select({ id: pages.id, title: pages.title })
.from(pages)
.where(
and(
eq(pages.ownerId, ctx.userId),
eq(pages.isDeleted, false),
or(
isNull(pages.contentPreview),
sql`length(trim(${pages.contentPreview})) < ${STUB_PREVIEW_MAX_LEN}`,
),
),
)
.limit(200);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The query results are non-deterministic because there is no orderBy clause. When a limit is applied without an explicit sort order, the database may return different sets of rows across executions. To ensure consistent results for the maintenance scan, especially when the 200-row limit is reached, consider adding an explicit sort order (e.g., by id or updatedAt).

Suggested change
const rows = await ctx.db
.select({ id: pages.id, title: pages.title })
.from(pages)
.where(
and(
eq(pages.ownerId, ctx.userId),
eq(pages.isDeleted, false),
or(
isNull(pages.contentPreview),
sql`length(trim(${pages.contentPreview})) < ${STUB_PREVIEW_MAX_LEN}`,
),
),
)
.limit(200);
const rows = await ctx.db
.select({ id: pages.id, title: pages.title })
.from(pages)
.where(
and(
eq(pages.ownerId, ctx.userId),
eq(pages.isDeleted, false),
or(
isNull(pages.contentPreview),
sql`length(trim(${pages.contentPreview})) < ${STUB_PREVIEW_MAX_LEN}`,
),
),
)
.orderBy(pages.id)
.limit(200);

@otomatty
otomatty marked this pull request as ready for review May 25, 2026 08:01
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c9039160a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +53 to +54
export function routeAfterResearch(state: WikiComposeStateType): ResearchRoute {
return shouldResolveResearchConflicts(state) ? "conflict_resolution" : "structure";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate conflict branch until clients can resume it

This new branch can route human_review_research to conflict_resolution, but the current UI/reload handlers only understand human_review_brief, human_review_research, and human_review_outline (see src/hooks/useWikiComposeSession.ts and server/api/src/routes/composeSessionProjection.ts). When a user approves at least one source and rejects two or more, the graph now emits a conflict_resolution interrupt that requires { acknowledged: true }, yet the client has no path to render/submit that payload, so sessions can get stuck or fail on resume.

Useful? React with 👍 / 👎.

* clear) or when the session was seeded from chat with a pre-approved outline.
*/
export function routeAfterBrief(state: WikiComposeStateType): BriefRoute {
if (state.briefQuestions.length === 0) return "skip_research";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve research path for Brief-generation failures

Treating briefQuestions.length === 0 as an unconditional skip_research conflates two different cases: an intentional no-question Brief and the existing error fallback in briefDialogue (which sets questions: [] when the LLM call throws). With this condition, transient model/backend failures now bypass research entirely and proceed to outline/draft without any sources, which is a behavioral regression from the prior fail-open-to-research flow.

Useful? React with 👍 / 👎.

@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: 4

🧹 Nitpick comments (7)
server/api/src/agents/graphs/wikiMaintenance/nodes/scanBrokenLinks.ts (1)

1-3: ⚡ Quick win

Add Japanese text to the node docblock.

The exported node’s documentation is currently English-only; please make it bilingual (JP/EN) like other graph-module docs.

As per coding guidelines: **/*.{ts,tsx,js,jsx,md}: Include both Japanese and English comments/documentation in code and documentation files to maintain project tone consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/src/agents/graphs/wikiMaintenance/nodes/scanBrokenLinks.ts` around
lines 1 - 3, Update the top docblock for the exported node scan_broken_links to
include Japanese alongside the existing English description (i.e., a bilingual
JP/EN docblock similar to other graph-module docs); locate the comment block
above the exported node (the /** ... */ immediately preceding scan_broken_links
export in scanBrokenLinks.ts) and add a concise Japanese translation line or
paragraph that mirrors the English text while keeping both languages clearly
labeled or separated.
server/api/src/__tests__/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.test.ts (1)

92-99: ⚡ Quick win

Assert plannedAt as part of the plan contract in this integration test.

The test validates counts and findings length, but not the required timestamp field. Adding a lightweight assertion tightens the spec coverage.

Suggested update
     const out = result.output as {
-      maintenancePlan?: { brokenLinkCount: number; stubPageCount: number; findings: unknown[] };
+      maintenancePlan?: {
+        brokenLinkCount: number;
+        stubPageCount: number;
+        findings: unknown[];
+        plannedAt: string;
+      };
       phase?: string;
     };
@@
     expect(out.maintenancePlan?.brokenLinkCount).toBe(1);
     expect(out.maintenancePlan?.stubPageCount).toBe(1);
     expect(out.maintenancePlan?.findings).toHaveLength(2);
+    expect(typeof out.maintenancePlan?.plannedAt).toBe("string");
+    expect(Number.isNaN(Date.parse(out.maintenancePlan!.plannedAt))).toBe(false);

As per coding guidelines: **/*.{test,spec}.{ts,tsx,js,jsx}: Tests serve as a source of truth for specifications alongside implementation code TSDoc/JSDoc.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@server/api/src/__tests__/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.test.ts`
around lines 92 - 99, The test currently asserts phase, brokenLinkCount,
stubPageCount, and findings length but misses the required timestamp field;
update the assertion block that checks the result.output (the local variable out
and its maintenancePlan property) to also assert that maintenancePlan.plannedAt
exists and is a valid timestamp (e.g., non-null/defined and parsable as a Date
or matches ISO format). Locate the assertions around the variable named out in
wikiMaintenanceGraph.test.ts and add a concise expectation that
maintenancePlan.plannedAt is present and valid to tighten the plan contract.
server/api/src/agents/graphs/wikiMaintenance/types.ts (1)

8-24: ⚡ Quick win

Make exported interface docblocks bilingual for consistency.

Line 8 and Line 17 docblocks are English-only; please add Japanese counterparts to match the repository’s JP/EN documentation tone.

Suggested update
-/** One lint-style finding projected into graph state. */
+/**
+ * One lint-style finding projected into graph state.
+ * LangGraph state に投影される lint 形式の検出結果。
+ */
 export interface MaintenanceFinding {
@@
-/**
- * Aggregated maintenance plan emitted at the end of the graph.
- */
+/**
+ * Aggregated maintenance plan emitted at the end of the graph.
+ * グラフ終端で生成される集約メンテナンスプラン。
+ */
 export interface MaintenancePlan {

As per coding guidelines: **/*.{ts,tsx,js,jsx,md}: Include both Japanese and English comments/documentation in code and documentation files to maintain project tone consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/src/agents/graphs/wikiMaintenance/types.ts` around lines 8 - 24,
Update the docblocks for the exported interfaces MaintenanceFinding and
MaintenancePlan to include Japanese translations alongside the existing English
descriptions; locate the comment above the MaintenanceFinding declaration ("One
lint-style finding projected into graph state.") and add a concise Japanese
equivalent, and do the same for the MaintenancePlan docblock ("Aggregated
maintenance plan emitted at the end of the graph.") plus the plannedAt
comment—ensure both English and Japanese appear for each comment to match
repository bilingual documentation style.
server/api/src/agents/graphs/wikiCompose/nodes/conflictResolution.ts (1)

16-24: ⚡ Quick win

Add TSDoc for helper function.

The buildConflictSummary helper function lacks TSDoc documentation. While it's not exported, documenting significant helper functions improves code maintainability.

📝 Suggested TSDoc
+/**
+ * Build conflict summary payload from approved/rejected research.
+ * 
+ * 採用・却下ソースから矛盾サマリペイロードを構築。
+ */
 function buildConflictSummary(state: WikiComposeStateType): ResearchConflictSummary {
   return {
     approved: state.approvedResearch.map((s) => ({ id: s.id, title: s.title })),
     rejected: state.rejectedResearch.map((s) => ({ id: s.id, title: s.title })),
     rationale:
       "Multiple sources were rejected while others were kept. Confirm you want to proceed " +
       "with the approved set before generating the outline.",
   };
 }

As per coding guidelines: Include both Japanese and English comments/documentation to maintain project tone consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/src/agents/graphs/wikiCompose/nodes/conflictResolution.ts` around
lines 16 - 24, The helper function buildConflictSummary (accepting
WikiComposeStateType and returning ResearchConflictSummary) is missing TSDoc;
add a brief TSDoc block immediately above the function that describes its
purpose, parameters, and return value in both English and Japanese, mentioning
that it constructs an approved/rejected summary and the rationale string; ensure
the tag syntax (/** ... */) includes `@param` for state and `@returns` for the
ResearchConflictSummary and mirrors project comment style.
server/api/src/agents/graphs/wikiCompose/types.ts (1)

203-208: ⚡ Quick win

Add proper TSDoc block with bilingual documentation.

The exported ResearchConflictSummary interface lacks a proper TSDoc block with bilingual comments. Per coding guidelines, all exported interfaces should have TSDoc comments with both Japanese and English.

📝 Suggested TSDoc format
-/** Lightweight conflict summary for the P5 `conflict_resolution` interrupt. */
+/**
+ * Lightweight conflict summary for the P5 `conflict_resolution` interrupt.
+ * 
+ * P5 矛盾解消 interrupt 用の軽量サマリ。採用・却下ソースのid/title と理由を含む。
+ */
 export interface ResearchConflictSummary {
   approved: Array<{ id: string; title: string }>;
   rejected: Array<{ id: string; title: string }>;
   rationale: string;
 }

As per coding guidelines: Include TSDoc/JSDoc comments for all exported functions, types, and interfaces; Include both Japanese and English comments/documentation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/src/agents/graphs/wikiCompose/types.ts` around lines 203 - 208,
Add a TSDoc block above the exported ResearchConflictSummary interface that
documents the interface in both English and Japanese, and include short
bilingual descriptions for each field (approved, rejected, rationale) and the
shape of approved/rejected entries (id and title); update the comment to follow
the project TSDoc/JSDoc style (/** ... */) so the interface and its members are
fully documented for both languages.
server/api/src/agents/graphs/wikiCompose/routing.ts (2)

25-26: ⚡ Quick win

Add TSDoc block for exported type.

The exported ResearchRoute type alias lacks a TSDoc block. Per coding guidelines, all exported types should have TSDoc comments.

📝 Suggested TSDoc format
-/** Edge label after `human_review_research`. */
-export type ResearchRoute = "structure" | "conflict_resolution";
+/**
+ * Edge label after `human_review_research`.
+ * 
+ * Research 完了後の分岐ラベル。
+ */
+export type ResearchRoute = "structure" | "conflict_resolution";

As per coding guidelines: Include TSDoc/JSDoc comments for all exported functions, types, and interfaces.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/src/agents/graphs/wikiCompose/routing.ts` around lines 25 - 26,
Add a TSDoc block immediately above the exported type alias ResearchRoute
describing its purpose as the edge label after `human_review_research`, listing
the allowed literal values ("structure" and "conflict_resolution") and intended
usage in routing/graph logic; update the comment to follow TSDoc style (/** ...
*/) and mention that it is an exported type used for routing decisions to
satisfy the project's documentation guidelines.

22-23: ⚡ Quick win

Add TSDoc block for exported type.

The exported BriefRoute type alias lacks a TSDoc block. Per coding guidelines, all exported types should have TSDoc comments.

📝 Suggested TSDoc format
-/** Edge label after `human_review_brief`. */
-export type BriefRoute = "research" | "skip_research";
+/**
+ * Edge label after `human_review_brief`.
+ * 
+ * Brief 完了後の分岐ラベル。
+ */
+export type BriefRoute = "research" | "skip_research";

As per coding guidelines: Include TSDoc/JSDoc comments for all exported functions, types, and interfaces.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/src/agents/graphs/wikiCompose/routing.ts` around lines 22 - 23,
Add a TSDoc comment for the exported type alias BriefRoute describing its
purpose and the allowed literal values; update the declaration for BriefRoute to
be preceded by a TSDoc block that briefly states it represents the edge label
after `human_review_brief` and documents the two possible routes ("research" and
"skip_research") and any usage notes or examples as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@server/api/src/__tests__/agents/graphs/wikiCompose/wikiComposeRouting.test.ts`:
- Around line 1-3: The file-level header comment in wikiComposeRouting.test.ts
is English-only; add a Japanese translation alongside the existing English line
so the top-of-file doc comment is bilingual (e.g., keep "Wiki Compose P5 routing
predicates (`#953`)." and append a Japanese equivalent on the next line), ensuring
both languages appear in the file-level comment block to comply with the
repository tone rules.

In `@server/api/src/agents/graphs/wikiMaintenance/index.ts`:
- Around line 1-3: Add a Japanese translation for the file-level header comment
in index.ts by appending or inserting a Japanese line alongside the English
header "Wiki maintenance graph — public barrel (`#953`)"; update the top-of-file
JSDoc block so it contains both the English and a concise Japanese counterpart
(e.g., 「ウィキ保守グラフ — パブリックバレル(#953)」) preserving the existing comment style and
punctuation.

In `@server/api/src/agents/graphs/wikiMaintenance/nodes/scanStubPages.ts`:
- Around line 42-43: The maintenance finding text emitted from scanStubPages.ts
currently uses English-only values for the title and suggestion fields; update
the emitted strings (referencing the title property and the suggestion field in
the stub creation logic) to include both Japanese and English variants (matching
the JP/EN phrasing used elsewhere), e.g. provide a Japanese translation followed
by the English text for the suggestion and any default title text so downstream
consumers receive bilingual output.

In `@server/api/src/agents/graphs/wikiMaintenance/state.ts`:
- Around line 24-25: Add TSDoc/JSDoc comments (both English and Japanese) for
the two exported type aliases WikiMaintenanceStateType and
WikiMaintenanceStateUpdate so the public contract is documented; update the
declarations near WikiMaintenanceStateType and WikiMaintenanceStateUpdate to
include a brief English sentence describing what each alias represents (e.g.,
"Current state shape for wiki maintenance") followed by a Japanese translation,
plus any param/usage notes if applicable, ensuring the comment blocks are
standard /** ... */ TSDoc style above each export.

---

Nitpick comments:
In
`@server/api/src/__tests__/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.test.ts`:
- Around line 92-99: The test currently asserts phase, brokenLinkCount,
stubPageCount, and findings length but misses the required timestamp field;
update the assertion block that checks the result.output (the local variable out
and its maintenancePlan property) to also assert that maintenancePlan.plannedAt
exists and is a valid timestamp (e.g., non-null/defined and parsable as a Date
or matches ISO format). Locate the assertions around the variable named out in
wikiMaintenanceGraph.test.ts and add a concise expectation that
maintenancePlan.plannedAt is present and valid to tighten the plan contract.

In `@server/api/src/agents/graphs/wikiCompose/nodes/conflictResolution.ts`:
- Around line 16-24: The helper function buildConflictSummary (accepting
WikiComposeStateType and returning ResearchConflictSummary) is missing TSDoc;
add a brief TSDoc block immediately above the function that describes its
purpose, parameters, and return value in both English and Japanese, mentioning
that it constructs an approved/rejected summary and the rationale string; ensure
the tag syntax (/** ... */) includes `@param` for state and `@returns` for the
ResearchConflictSummary and mirrors project comment style.

In `@server/api/src/agents/graphs/wikiCompose/routing.ts`:
- Around line 25-26: Add a TSDoc block immediately above the exported type alias
ResearchRoute describing its purpose as the edge label after
`human_review_research`, listing the allowed literal values ("structure" and
"conflict_resolution") and intended usage in routing/graph logic; update the
comment to follow TSDoc style (/** ... */) and mention that it is an exported
type used for routing decisions to satisfy the project's documentation
guidelines.
- Around line 22-23: Add a TSDoc comment for the exported type alias BriefRoute
describing its purpose and the allowed literal values; update the declaration
for BriefRoute to be preceded by a TSDoc block that briefly states it represents
the edge label after `human_review_brief` and documents the two possible routes
("research" and "skip_research") and any usage notes or examples as needed.

In `@server/api/src/agents/graphs/wikiCompose/types.ts`:
- Around line 203-208: Add a TSDoc block above the exported
ResearchConflictSummary interface that documents the interface in both English
and Japanese, and include short bilingual descriptions for each field (approved,
rejected, rationale) and the shape of approved/rejected entries (id and title);
update the comment to follow the project TSDoc/JSDoc style (/** ... */) so the
interface and its members are fully documented for both languages.

In `@server/api/src/agents/graphs/wikiMaintenance/nodes/scanBrokenLinks.ts`:
- Around line 1-3: Update the top docblock for the exported node
scan_broken_links to include Japanese alongside the existing English description
(i.e., a bilingual JP/EN docblock similar to other graph-module docs); locate
the comment block above the exported node (the /** ... */ immediately preceding
scan_broken_links export in scanBrokenLinks.ts) and add a concise Japanese
translation line or paragraph that mirrors the English text while keeping both
languages clearly labeled or separated.

In `@server/api/src/agents/graphs/wikiMaintenance/types.ts`:
- Around line 8-24: Update the docblocks for the exported interfaces
MaintenanceFinding and MaintenancePlan to include Japanese translations
alongside the existing English descriptions; locate the comment above the
MaintenanceFinding declaration ("One lint-style finding projected into graph
state.") and add a concise Japanese equivalent, and do the same for the
MaintenancePlan docblock ("Aggregated maintenance plan emitted at the end of the
graph.") plus the plannedAt comment—ensure both English and Japanese appear for
each comment to match repository bilingual documentation style.
🪄 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: CHILL

Plan: Pro

Run ID: 8ad417b5-9319-4694-94c7-faa9bf362889

📥 Commits

Reviewing files that changed from the base of the PR and between e846cde and 4c90391.

📒 Files selected for processing (24)
  • server/api/src/__tests__/agents/graphs/wikiCompose/wikiComposeGraph.test.ts
  • server/api/src/__tests__/agents/graphs/wikiCompose/wikiComposeRouting.test.ts
  • server/api/src/__tests__/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.test.ts
  • server/api/src/agents/graphs/wikiCompose/index.ts
  • server/api/src/agents/graphs/wikiCompose/nodes/conflictResolution.ts
  • server/api/src/agents/graphs/wikiCompose/nodes/index.ts
  • server/api/src/agents/graphs/wikiCompose/nodes/skipResearch.ts
  • server/api/src/agents/graphs/wikiCompose/resumeSchemas.ts
  • server/api/src/agents/graphs/wikiCompose/routing.ts
  • server/api/src/agents/graphs/wikiCompose/state.ts
  • server/api/src/agents/graphs/wikiCompose/types.ts
  • server/api/src/agents/graphs/wikiCompose/wikiComposeGraph.ts
  • server/api/src/agents/graphs/wikiMaintenance/index.ts
  • server/api/src/agents/graphs/wikiMaintenance/nodes/index.ts
  • server/api/src/agents/graphs/wikiMaintenance/nodes/planMaintenance.ts
  • server/api/src/agents/graphs/wikiMaintenance/nodes/scanBrokenLinks.ts
  • server/api/src/agents/graphs/wikiMaintenance/nodes/scanStubPages.ts
  • server/api/src/agents/graphs/wikiMaintenance/state.ts
  • server/api/src/agents/graphs/wikiMaintenance/types.ts
  • server/api/src/agents/graphs/wikiMaintenance/wikiMaintenanceGraph.ts
  • server/api/src/agents/index.ts
  • server/api/src/agents/subgraphs/research/types.ts
  • server/api/src/app.ts
  • server/api/src/routes/composeSessions.ts

Comment thread server/api/src/agents/graphs/wikiMaintenance/index.ts
Comment thread server/api/src/agents/graphs/wikiMaintenance/nodes/scanStubPages.ts Outdated
Comment thread server/api/src/agents/graphs/wikiMaintenance/state.ts
…ng (#953)

- Add briefDegraded flag so LLM fallback still runs research
- Wire conflict_resolution through projection, hook, and ComposePanel UI
- Stabilize stub scan query with orderBy; bilingual maintenance strings

Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/api/src/routes/composeSessionProjection.ts`:
- Around line 27-28: The doc comment for the new field researchConflictSummary
is only in English; add a Japanese translation so comments are bilingual per
guidelines. Update the JSDoc block above researchConflictSummary to include both
Japanese and English descriptions (e.g., Japanese line followed by the existing
English line or vice versa), matching surrounding comment style and formatting
for other fields in the file.

In `@src/components/wikiCompose/ConflictResolutionSection.tsx`:
- Around line 14-21: Add TSDoc/JSDoc comments in both English and Japanese for
the exported interface ConflictResolutionSectionProps and the exported component
ConflictResolutionSection: document each property in
ConflictResolutionSectionProps (conflicts, isStreaming, onSubmit) with types and
purpose, and add a short bilingual description for the ConflictResolutionSection
component (including expected behavior and return type/React.FC usage). Ensure
comments follow TSDoc format (/** ... */), include Japanese translation
alongside English sentences, and place them immediately above the interface and
component declarations.

In `@src/components/wikiCompose/PhaseStepper.tsx`:
- Around line 34-35: The inline English-only comment in PhaseStepper.tsx ("// P5
conflict interrupt sits between Research and Structure on the graph, but the
stepper keeps five labels — highlight Research while resolving conflicts.") must
include a Japanese translation per repo guidelines; update the same comment
(near the PhaseStepper component) to add a concise Japanese sentence conveying
the same meaning immediately before or after the English sentence so both
languages are present.

In `@src/hooks/useWikiComposeSession.ts`:
- Line 40: Add TSDoc/JSDoc comments for the exported type ComposePhase and
update the docstring for submitConflictAck to include both English and Japanese;
specifically, above the export type ComposePhase = "brief" | "research" |
"conflict" | "structure" | "draft" | "completed"; add a short TSDoc describing
the purpose and allowed phases (in English then Japanese), and modify the
existing documentation/comment for the submitConflictAck function to include a
bilingual description, parameter notes, and return details (English first,
Japanese second) following the project's TSDoc/JSDoc style conventions.
- Around line 480-485: The conflict_resolution branch currently expects to
preserve prior approvals but resume hydration calls
reduceInterrupt(INITIAL_STATE, ...), which wipes approvedSources; update the
resume/hydration callsite to pass the actual current state (not INITIAL_STATE)
into reduceInterrupt so the case "conflict_resolution" can read
prev.approvedSources, or alternatively change the conflict_resolution return to
defensively use payload or a fallback (e.g., approvedSources:
prev?.approvedSources ?? payload.approvedSources) — adjust either the
reduceInterrupt invocation or the case "conflict_resolution" logic so
approvedSources are not reset during resume.

In `@src/lib/wikiCompose/types.ts`:
- Around line 121-126: Update the TSDoc for the ResearchConflictSummary
interface to include both English and Japanese descriptions: add a Japanese
sentence (or short paragraph) that mirrors the existing English docstring so the
comment is bilingual, and ensure the fields (approved, rejected, rationale) are
briefly described in both languages; target the comment above the
ResearchConflictSummary interface declaration to keep docs consistent with repo
guidelines.
- Around line 129-135: The ComposeSseEvent type's compose_phase.phase union is
missing the "conflict" member and must be updated to match the phase union added
in the wikiCompose types (the union that includes "brief" | "research" |
"conflict" | "structure" | "draft" | "completed"); update the ComposeSseEvent
definition (and any other SSE/wire event type that defines compose_phase.phase)
to include "conflict" so the runtime wire contract matches the
projected/interrupt flows.
🪄 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: CHILL

Plan: Pro

Run ID: 72b98da7-124d-4c26-9962-46d2f1b18edc

📥 Commits

Reviewing files that changed from the base of the PR and between 4c90391 and 349f78a.

📒 Files selected for processing (15)
  • server/api/src/__tests__/agents/graphs/wikiCompose/wikiComposeRouting.test.ts
  • server/api/src/__tests__/routes/composeSessionProjection.test.ts
  • server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts
  • server/api/src/agents/graphs/wikiCompose/routing.ts
  • server/api/src/agents/graphs/wikiCompose/state.ts
  • server/api/src/agents/graphs/wikiMaintenance/index.ts
  • server/api/src/agents/graphs/wikiMaintenance/nodes/scanStubPages.ts
  • server/api/src/agents/graphs/wikiMaintenance/state.ts
  • server/api/src/routes/composeSessionProjection.ts
  • src/components/wikiCompose/ComposePanel.tsx
  • src/components/wikiCompose/ConflictResolutionSection.tsx
  • src/components/wikiCompose/PhaseStepper.tsx
  • src/hooks/useWikiComposeSession.ts
  • src/lib/wikiCompose/types.ts
  • src/pages/WikiComposePage.tsx
✅ Files skipped from review due to trivial changes (1)
  • server/api/src/agents/graphs/wikiMaintenance/index.ts

Comment thread server/api/src/routes/composeSessionProjection.ts Outdated
Comment thread src/components/wikiCompose/ConflictResolutionSection.tsx
Comment thread src/components/wikiCompose/PhaseStepper.tsx
Comment thread src/hooks/useWikiComposeSession.ts
Comment thread src/hooks/useWikiComposeSession.ts
Comment thread src/lib/wikiCompose/types.ts Outdated
Comment thread src/lib/wikiCompose/types.ts
)

- Seed interrupt context from checkpoint approvedResearch on resume
- Add conflict to compose_phase SSE unions (client + server)
- Bilingual TSDoc for review nits

Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/hooks/useWikiComposeSession.ts`:
- Around line 505-507: The inline comment above the spread that preserves
approvals (the line with ...(prev.approvedSources.length > 0 ? {
approvedSources: prev.approvedSources } : {})) is English-only; add a Japanese
translation directly alongside it so the comment is bilingual. Keep the original
English sentence about keeping approvals from `prev` (SSE) or checkpoint context
(resume) and append a concise Japanese equivalent mentioning
`prev.approvedSources` and `reduceResumeOutput` to match repository guidelines.
🪄 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: CHILL

Plan: Pro

Run ID: bc10806f-697d-4f8a-be0a-d22642c341a9

📥 Commits

Reviewing files that changed from the base of the PR and between 349f78a and ce24b19.

📒 Files selected for processing (6)
  • server/api/src/agents/core/types/sseEvents.ts
  • server/api/src/routes/composeSessionProjection.ts
  • src/components/wikiCompose/ConflictResolutionSection.tsx
  • src/components/wikiCompose/PhaseStepper.tsx
  • src/hooks/useWikiComposeSession.ts
  • src/lib/wikiCompose/types.ts
✅ Files skipped from review due to trivial changes (1)
  • src/components/wikiCompose/PhaseStepper.tsx

Comment on lines +505 to +507
// Keep approvals from `prev` (SSE) or checkpoint context (resume); do not
// overwrite with an empty array when `reduceResumeOutput` seeds context.
...(prev.approvedSources.length > 0 ? { approvedSources: prev.approvedSources } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Keep the new inline comment bilingual.

Line 505-507 adds an English-only inline comment; please add a Japanese counterpart to match repo documentation tone.

Suggested patch
-        // Keep approvals from `prev` (SSE) or checkpoint context (resume); do not
-        // overwrite with an empty array when `reduceResumeOutput` seeds context.
+        // Keep approvals from `prev` (SSE) or checkpoint context (resume); do not
+        // overwrite with an empty array when `reduceResumeOutput` seeds context.
+        // `prev`(SSE)または checkpoint 文脈(resume)の承認を保持し、
+        // `reduceResumeOutput` の context seed で空配列に上書きしない。
         ...(prev.approvedSources.length > 0 ? { approvedSources: prev.approvedSources } : {}),

As per coding guidelines: **/*.{ts,tsx,js,jsx,md}: Include both Japanese and English comments/documentation in code and documentation files to maintain project tone consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/hooks/useWikiComposeSession.ts` around lines 505 - 507, The inline
comment above the spread that preserves approvals (the line with
...(prev.approvedSources.length > 0 ? { approvedSources: prev.approvedSources }
: {})) is English-only; add a Japanese translation directly alongside it so the
comment is bilingual. Keep the original English sentence about keeping approvals
from `prev` (SSE) or checkpoint context (resume) and append a concise Japanese
equivalent mentioning `prev.approvedSources` and `reduceResumeOutput` to match
repository guidelines.

@otomatty
otomatty merged commit 589c224 into develop May 25, 2026
18 checks passed
@otomatty
otomatty deleted the cursor/wiki-compose-p5-dynamic-routing-7d9d branch May 25, 2026 09:38
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.

feat(api): Wiki Compose P5 — 動的分岐・Wiki メンテ graph 高度化

2 participants