Skip to content

Finish cycle activation naming quick wins#394

Merged
cmbays merged 4 commits intomainfrom
codex-quick-wins-20260321
Mar 21, 2026
Merged

Finish cycle activation naming quick wins#394
cmbays merged 4 commits intomainfrom
codex-quick-wins-20260321

Conversation

@cmbays
Copy link
Owner

@cmbays cmbays commented Mar 21, 2026

Summary

Testing

  • npm run lint
  • npm run build
  • npm run test:arch
  • npm run test:acceptance
  • npm run test:crap
  • npm run test:coverage:unit
  • npx vitest run src/features/cycle-management/cycle-name-suggester.test.ts src/features/cycle-management/cycle-activation-name-resolver.test.ts src/domain/services/cycle-manager.test.ts src/cli/commands/cycle.test.ts src/cli/commands/execute.test.ts src/cli/integration.test.ts

Review Notes

  • I did a final code review on the naming/activation diff and did not find additional correctness issues after the heuristic cleanup.
  • Focused mutation testing still shows weak helper-level mutation coverage in src/features/cycle-management/cycle-name-suggester.ts; the functional gates are green, but that file still needs deeper mutation-oriented tests as follow-up.

Closes #371
Closes #373
Closes #379

Summary by CodeRabbit

  • New Features

    • Added --name option for cycle prepare/start; JSON/text outputs include resolved cycleName.
    • Automatic human-readable cycle name resolution (LLM suggestion or heuristic) with optional prompting.
  • Bug Fixes

    • Activation now requires a non-empty cycle name; whitespace-only names are rejected and validated across flows.
  • Documentation

    • Reorganized docs links and clarified orchestration model (sensei → delegated workers).
  • Chores

    • Added scoped repo rules and updated VCS ignores for Claude config.

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

Warning

Rate limit exceeded

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

⌛ 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 54921cac-a8b7-4471-b99a-5cc152166fb6

📥 Commits

Reviewing files that changed from the base of the PR and between e186028 and deb3221.

📒 Files selected for processing (2)
  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
📝 Walkthrough

Walkthrough

Adds activation-time cycle naming (optional --name, LLM/heuristic suggestion, and optional prompt), normalizes/validates names across CLI, bridge, and domain layers, updates session-bridge to require persisted names for activation, expands tests/features, and refactors/docs to a sensei/delegated-worker orchestration model.

Changes

Cohort / File(s) Summary
Cycle Activation Naming
src/features/cycle-management/cycle-activation-name-resolver.ts, src/features/cycle-management/cycle-name-suggester.ts, src/cli/cycle-name-prompt.ts, src/domain/services/cycle-name.ts
New resolver, LLM-backed suggester, interactive prompt, and normalization helper that compute/validate activation names; exports/types added.
Cycle Manager & Domain Tests
src/domain/services/cycle-manager.ts, src/domain/services/cycle-manager.test.ts, src/domain/services/cycle-manager.feature, src/domain/services/cycle-manager.steps.ts, src/domain/types/cycle.ts
Normalize names on create, thread optional name through startCycle, enforce non-empty name for planning→active transition; tests and features updated.
SessionExecutionBridge & Tests
src/infrastructure/execution/session-bridge.ts, src/infrastructure/execution/session-bridge.test.ts, src/infrastructure/execution/session-bridge.unit.test.ts, src/infrastructure/execution/session-bridge.feature, src/infrastructure/execution/session-bridge.steps.ts
prepareCycle now resolves/normalizes activation name, throws when missing/empty, and persists resolved name; tests and BDD feature steps updated.
CLI Commands & Tests
src/cli/commands/cycle.ts, src/cli/commands/cycle.test.ts, src/cli/commands/execute.ts, src/cli/commands/execute.test.ts, src/cli/integration.test.ts, src/cli/cycle-name-prompt.ts
Added --name option and integrated resolver/prompt/suggester flows into cycle start/execute prepare paths; refactored execute command handlers into helpers; extensive tests and Claude stubs added.
Acceptance & Feature Tests
src/acceptance/setup.ts, src/features/cycle-management/*.feature, src/features/cycle-management/*.steps.ts, src/features/cycle-management/*.test.ts
Registers new acceptance steps and adds feature/test suites for activation name resolution and name-suggester behavior.
Docs: Orchestration & Links
docs-site/agents/*, docs-site/architecture/*, docs-site/guides/*, docs-site/product-design/*, docs-site/methodology/*
Reframes orchestration from “bet teammate/sub-agents” → “sensei/delegated workers”, updates narrative/diagrams, and rewrites many internal relative links.
Repo Rules, CLAUDE & Ignore
.claude/rules/*.md, CLAUDE.md, .claude/settings.local.json, .gitignore
Adds scoped rule files, updates CLAUDE.md guidance, removes local Claude settings file, and adjusts .gitignore to ignore .claude/* with tracked exceptions.
Tooling & Scripts
.dependency-cruiser.cjs, scripts/run-crap-diff.mjs
Resilient dependency-cruiser config discovery via upward traversal; adds findUp helper for resolving tool entrypoints.
Misc Tests & Cleanup
src/cli/commands/execute.test.ts, various test files
Expanded test harnesses (PATH isolation, Claude stubs), updated assertions, and numerous new/updated unit and integration tests across cycle/execute areas.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as CLI Handler<br/>(cycle/execute)
    participant Resolver as CycleActivationName<br/>Resolver
    participant Suggester as CycleNameSuggester
    participant LLM as Claude LLM
    participant Prompt as User Prompt
    participant Bridge as SessionExecution<br/>Bridge
    participant Manager as CycleManager

    User->>CLI: cycle start <id> [--name]
    CLI->>CLI: Determine prompting (TTY & !JSON)
    alt Name explicitly provided
        CLI->>Resolver: resolveCycleActivationName(cycle, providedName)
        Resolver->>Resolver: Validate & trim
        Resolver-->>CLI: ResolvedCycleActivationName
    else No name & prompt enabled
        CLI->>Resolver: resolveCycleActivationName(cycle, undefined, promptFn)
        Resolver->>Suggester: suggest(cycle)
        Suggester->>LLM: invoke Claude prompt
        LLM-->>Suggester: raw response
        Suggester->>Suggester: parse/sanitize or heuristic fallback
        Suggester-->>Resolver: CycleNameSuggestion
        Resolver->>Prompt: promptForName(suggestion)
        Prompt->>User: ask for name
        User-->>Prompt: enters name
        Prompt-->>Resolver: validated trimmed name
        Resolver-->>CLI: ResolvedCycleActivationName (prompted)
    else No name & no prompt
        CLI->>Resolver: resolveCycleActivationName(cycle)
        Resolver->>Suggester: suggest(cycle)
        Suggester->>Suggester: heuristic fallback
        Suggester-->>Resolver: CycleNameSuggestion
        Resolver-->>CLI: ResolvedCycleActivationName
    end
    CLI->>Bridge: prepareCycle(cycleId, agentId, activationName)
    Bridge->>Manager: transitionState(cycleId, 'active', activationName)
    Manager->>Manager: Validate non-empty name & persist
    Manager-->>Bridge: updated cycle
    Bridge-->>CLI: prepared runs
    CLI-->>User: "Cycle '<name>' started!"
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 I nudge a name from Claude's soft hum,
Trim the fluff, persist it firm and true,
Sensei sends workers — tidy chores begun,
IDs bow down as readable names accrue,
Hop, hop — the kata wakes with something new.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Finish cycle activation naming quick wins' directly and specifically summarizes the main work: completing quick-win items related to cycle activation naming, which is the primary theme across the changeset.

✏️ 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 codex-quick-wins-20260321

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: eaee51150b

ℹ️ 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 +69 to +72
const firstContentLine = raw
.split('\n')
.map((line) => line.trim())
.find(Boolean);

Choose a reason for hiding this comment

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

P2 Badge Skip preamble lines when parsing suggested cycle names

parseSuggestedCycleName currently takes the first non-empty line verbatim before cleanup, so if Claude prepends text like Sure, here's a name: or a code-fence marker, that line is accepted as the cycle name and the real suggestion on later lines is ignored. This can activate cycles with unusable names and break name-based UX, even when Claude returns a valid name further down. Parse should iterate lines and select the first line that remains a plausible name after cleanup, rather than the first non-empty raw line.

Useful? React with 👍 / 👎.

coderabbitai[bot]
coderabbitai bot previously requested changes Mar 21, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 12

Caution

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

⚠️ Outside diff range comments (2)
src/domain/services/cycle-manager.test.ts (1)

1-1: 🧹 Nitpick | 🔵 Trivial

Remove unnecessary vitest imports per coding guidelines.

Same issue as other test files — Vitest globals are enabled and should be used directly. As per coding guidelines: "Vitest globals are enabled, so do not import describe, it, or expect — use them directly."

🔧 Proposed fix
-import { describe, it, expect, beforeEach, afterEach } from 'vitest';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/domain/services/cycle-manager.test.ts` at line 1, The test file imports
Vitest globals unnecessarily; remove the import statement that brings in
describe, it, expect, beforeEach, afterEach and rely on Vitest's global
functions directly (i.e., delete the import line in cycle-manager.test.ts so
tests use describe/it/expect/beforeEach/afterEach as globals).
src/infrastructure/execution/session-bridge.unit.test.ts (1)

5-5: 🧹 Nitpick | 🔵 Trivial

Remove unnecessary vitest imports per coding guidelines.

The coding guidelines state that Vitest globals are enabled, so describe, it, expect, and vi should be used directly without importing them. As per coding guidelines: "Vitest globals are enabled, so do not import describe, it, or expect — use them directly."

🔧 Proposed fix
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/infrastructure/execution/session-bridge.unit.test.ts` at line 5, The
import line currently pulls Vitest globals; update it to only import lifecycle
helpers by removing describe, it, expect, and vi from the import statement so
you only import beforeEach and afterEach from 'vitest' and rely on the enabled
Vitest globals (describe, it, expect, vi) used directly in the tests (look for
the import line at the top of session-bridge.unit.test.ts to modify).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/rules/cli-and-cycle-commands.md:
- Line 10: Update the rule text for `cycle new` in
.claude/rules/cli-and-cycle-commands.md so it matches the activation policy:
state that providing a name is optional during creation/planning but a non-empty
persisted name is required before activation/launch. Change the sentence that
currently reads "`cycle new` requires a non-empty cycle name" to explicitly
allow unnamed planning and assert the requirement at activation/launch, and
ensure any surrounding guidance references the "activation" requirement rather
than creation.

In @.claude/rules/execution-bridge-and-cycles.md:
- Around line 1-9: The file's frontmatter lacks a top-level heading which
triggers markdownlint MD041; immediately after the closing frontmatter delimiter
(the --- block shown at the top), add a single H1 line (a top-level heading)
that summarizes the document (e.g., an "Execution bridge and cycles" title) so
the file has a proper first-level heading following the frontmatter.

In @.claude/rules/testing-and-quality.md:
- Around line 1-11: Add a top-level H1 heading immediately after the YAML
frontmatter in testing-and-quality.md to satisfy MD041; locate the frontmatter
block (the leading lines between the initial --- and the closing ---) and insert
a Markdown H1 (for example, "# Testing and Quality") on the first line after
that closing --- so the file begins with frontmatter followed by a top-level
heading.

In @.gitignore:
- Line 39: Remove the negation entry that un-ignores the local settings file
(the line '!.claude/settings.local.json') from .gitignore, ensure the file
pattern for .claude/settings.local.json is ignored (add it if missing), and if
that file is already tracked remove it from the repository index so it stops
being committed and then commit the updated .gitignore; this prevents local
secrets from being tracked.

In `@CLAUDE.md`:
- Line 122: The document uses inconsistent spelling for the same
term—"Colocated" (line 78) vs "co-located" (line 122); pick one canonical
spelling (e.g., "co-located" or "colocated") and update all occurrences to that
form so the CLAUDE.md file is consistent; search for "Colocated", "colocated",
and "co-located" and replace them uniformly (ensure casing matches surrounding
headings or sentence case where used).

In `@docs-site/architecture/sensei-orchestration.md`:
- Line 48: Replace the phrase "Spawn teammates or sub-agents to execute the
selected ryu." with "Spawn delegated worker agents to execute the selected ryu."
to use a single term ("delegated worker agents") consistently; search for other
occurrences of "teammates" or "sub-agents" in this document and standardize them
to "delegated worker agents" so the language matches the centralized model
described elsewhere in this file.

In `@src/cli/cycle-name-prompt.ts`:
- Around line 7-14: The promptForCycleActivationName function currently
validates using value.trim() but returns the raw input, causing inconsistency;
update promptForCycleActivationName so the string returned from input(...) is
trimmed before being returned (e.g., await input(...) then return
result.trim()), keeping the existing default (suggestion.name) and validation
logic intact; reference promptForCycleActivationName, the input prompt call, and
related resolveCycleActivationName/normalizeCycleName for context.

In `@src/cli/integration.test.ts`:
- Line 1: The test imports Vitest globals unnecessarily; remove the imported
symbols describe, it, expect, beforeEach, and afterEach and only import vi from
'vitest' so the suite uses the enabled global functions while still importing
the vi mock helper. Update the import line to reference only vi and ensure any
usages of describe/it/expect/beforeEach/afterEach remain as globals in the file
(no other changes to test code or symbol names like vi).

In `@src/features/cycle-management/cycle-activation-name-resolver.ts`:
- Around line 56-59: The function normalizeCycleName in
cycle-activation-name-resolver.ts duplicates logic found in the session bridge
module; extract this logic into a shared utility function (e.g., export a
normalizeCycleName helper from a new or existing utils module) and import/use
that helper from both cycle-activation-name-resolver and the session bridge so
both call the single shared normalizeCycleName implementation; update imports
and remove the local duplicate function in cycle-activation-name-resolver (and
keep only the shared export in the utils module).

In `@src/features/cycle-management/cycle-name-suggester.ts`:
- Around line 142-148: The defaultInvokeClaude function currently calls
execFileSync('claude', ['--print'], ...) without a timeout, risking indefinite
blocking; modify defaultInvokeClaude to pass a timeout option (e.g., timeout:
30000) into execFileSync's options so the child process is killed after a
reasonable wait, and ensure the existing try/catch fallback still handles the
thrown Error (including TimeoutError) gracefully; reference the
defaultInvokeClaude function and the execFileSync call when making the change.

In `@src/infrastructure/execution/session-bridge.feature`:
- Line 38: Update the Gherkin step text that currently reads "And the prepared
cycle includes 1 runs" to use the correct singular form "And the prepared cycle
includes 1 run"; locate the step in the session-bridge.feature scenario where
the step string "And the prepared cycle includes 1 runs" appears and replace it
with "And the prepared cycle includes 1 run".

In `@src/infrastructure/execution/session-bridge.ts`:
- Around line 46-49: The normalizeCycleName function is duplicated; extract it
into a single shared domain service module (e.g., domain cycle-helpers) as an
exported function normalizeCycleName(name: string | undefined): string |
undefined, then replace the local implementations by importing and using that
exported function in the files that currently define it (the cycle-manager,
session-bridge, and cycle-activation-name-resolver modules) to remove
duplication and ensure a single normalization implementation.

---

Outside diff comments:
In `@src/domain/services/cycle-manager.test.ts`:
- Line 1: The test file imports Vitest globals unnecessarily; remove the import
statement that brings in describe, it, expect, beforeEach, afterEach and rely on
Vitest's global functions directly (i.e., delete the import line in
cycle-manager.test.ts so tests use describe/it/expect/beforeEach/afterEach as
globals).

In `@src/infrastructure/execution/session-bridge.unit.test.ts`:
- Line 5: The import line currently pulls Vitest globals; update it to only
import lifecycle helpers by removing describe, it, expect, and vi from the
import statement so you only import beforeEach and afterEach from 'vitest' and
rely on the enabled Vitest globals (describe, it, expect, vi) used directly in
the tests (look for the import line at the top of session-bridge.unit.test.ts to
modify).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 45940e2c-499d-4bd8-a39b-87f72826c154

📥 Commits

Reviewing files that changed from the base of the PR and between 559c5dd and eaee511.

📒 Files selected for processing (47)
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/docs-and-agent-context.md
  • .claude/rules/execution-bridge-and-cycles.md
  • .claude/rules/testing-and-quality.md
  • .dependency-cruiser.cjs
  • .gitignore
  • CLAUDE.md
  • docs-site/agents/context-flow.md
  • docs-site/agents/kata-sensei.md
  • docs-site/agents/orchestration.md
  • docs-site/architecture/dojo.md
  • docs-site/architecture/kataka.md
  • docs-site/architecture/meta-learning.md
  • docs-site/architecture/sensei-orchestration.md
  • docs-site/getting-started/project-setup.md
  • docs-site/guides/file-structure.md
  • docs-site/guides/skill-overview.md
  • docs-site/guides/system-guide.md
  • docs-site/methodology/reference/app-flow-standard.md
  • docs-site/product-design/design-vision.md
  • docs-site/product-design/interaction-design.md
  • docs-site/product-design/product-design.md
  • docs-site/product-design/user-journeys.md
  • scripts/run-crap-diff.mjs
  • src/acceptance/setup.ts
  • src/cli/commands/cycle.test.ts
  • src/cli/commands/cycle.ts
  • src/cli/commands/execute.test.ts
  • src/cli/commands/execute.ts
  • src/cli/cycle-name-prompt.ts
  • src/cli/integration.test.ts
  • src/domain/services/cycle-manager.feature
  • src/domain/services/cycle-manager.steps.ts
  • src/domain/services/cycle-manager.test.ts
  • src/domain/services/cycle-manager.ts
  • src/domain/types/cycle.ts
  • src/features/cycle-management/cycle-activation-name-resolver.feature
  • src/features/cycle-management/cycle-activation-name-resolver.steps.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-name-suggester.ts
  • src/infrastructure/execution/session-bridge.feature
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/infrastructure/execution/session-bridge.test.ts
  • src/infrastructure/execution/session-bridge.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (10)
src/acceptance/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Register step files for .feature files through src/acceptance/setup.ts

Files:

  • src/acceptance/setup.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: All types must be defined as Zod schemas (using zod/v4 import path), not as separate interface definitions. This is a non-negotiable schema-first approach.
Use path aliases for internal imports: @domain/*src/domain/*, @infra/*src/infrastructure/*, @features/*src/features/*, @shared/*src/shared/*, @cli/*src/cli/*
Use .js file extensions on all internal imports in ESM module context
Respect strict dependency direction: domain → infrastructure → features → shared → cli. No reverse imports allowed.

Files:

  • src/acceptance/setup.ts
  • src/domain/types/cycle.ts
  • src/domain/services/cycle-manager.steps.ts
  • src/infrastructure/execution/session-bridge.ts
  • src/cli/integration.test.ts
  • src/cli/cycle-name-prompt.ts
  • src/infrastructure/execution/session-bridge.test.ts
  • src/domain/services/cycle-manager.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.steps.ts
  • src/domain/services/cycle-manager.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
  • src/cli/commands/cycle.test.ts
  • src/cli/commands/cycle.ts
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/cli/commands/execute.ts
  • src/cli/commands/execute.test.ts
  • src/features/cycle-management/cycle-name-suggester.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Colocate test files as *.test.ts next to the corresponding *.ts source file

Files:

  • src/acceptance/setup.ts
  • src/domain/types/cycle.ts
  • src/domain/services/cycle-manager.steps.ts
  • src/infrastructure/execution/session-bridge.ts
  • src/cli/integration.test.ts
  • src/cli/cycle-name-prompt.ts
  • src/infrastructure/execution/session-bridge.test.ts
  • src/domain/services/cycle-manager.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.steps.ts
  • src/domain/services/cycle-manager.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
  • src/cli/commands/cycle.test.ts
  • src/cli/commands/cycle.ts
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/cli/commands/execute.ts
  • src/cli/commands/execute.test.ts
  • src/features/cycle-management/cycle-name-suggester.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
src/domain/types/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Define all domain types as Zod schemas in the domain/types/ directory, which serves as the source of truth for all types

Files:

  • src/domain/types/cycle.ts
**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

Keep public/private boundaries intact; public repo docs should not point at private ops paths directly

Files:

  • CLAUDE.md
  • docs-site/product-design/design-vision.md
  • docs-site/guides/file-structure.md
  • docs-site/guides/system-guide.md
  • docs-site/agents/kata-sensei.md
  • docs-site/methodology/reference/app-flow-standard.md
  • docs-site/architecture/dojo.md
  • docs-site/product-design/user-journeys.md
  • docs-site/getting-started/project-setup.md
  • docs-site/product-design/product-design.md
  • docs-site/architecture/meta-learning.md
  • docs-site/architecture/kataka.md
  • docs-site/guides/skill-overview.md
  • docs-site/architecture/sensei-orchestration.md
  • docs-site/agents/orchestration.md
  • docs-site/product-design/interaction-design.md
  • docs-site/agents/context-flow.md
**/*.feature

📄 CodeRabbit inference engine (AGENTS.md)

**/*.feature: Co-locate .feature files with the feature they specify
For new behavior or behavior clarification, acceptance scenarios must exist and fail before implementation

Files:

  • src/infrastructure/execution/session-bridge.feature
  • src/domain/services/cycle-manager.feature
  • src/features/cycle-management/cycle-activation-name-resolver.feature
src/domain/services/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use domain/services/ for pipeline composition, manifest building, and cycle management

Files:

  • src/domain/services/cycle-manager.steps.ts
  • src/domain/services/cycle-manager.test.ts
  • src/domain/services/cycle-manager.ts
src/infrastructure/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Place persistence implementations (JsonStore), registries, adapters, and tracking logic in the infrastructure/ directory

Files:

  • src/infrastructure/execution/session-bridge.ts
  • src/infrastructure/execution/session-bridge.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
  • src/infrastructure/execution/session-bridge.steps.ts
src/cli/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use cli/ directory as a thin wrapper using Commander.js, not for complex application logic

Files:

  • src/cli/integration.test.ts
  • src/cli/cycle-name-prompt.ts
  • src/cli/commands/cycle.test.ts
  • src/cli/commands/cycle.ts
  • src/cli/commands/execute.ts
  • src/cli/commands/execute.test.ts
**/*.test.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Vitest globals are enabled, so do not import describe, it, or expect — use them directly

Files:

  • src/cli/integration.test.ts
  • src/infrastructure/execution/session-bridge.test.ts
  • src/domain/services/cycle-manager.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
  • src/cli/commands/cycle.test.ts
  • src/cli/commands/execute.test.ts
🧠 Learnings (23)
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/acceptance/**/*.ts : Register step files for `.feature` files through `src/acceptance/setup.ts`

Applied to files:

  • src/acceptance/setup.ts
  • .claude/rules/testing-and-quality.md
  • src/features/cycle-management/cycle-activation-name-resolver.steps.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/domain/services/**/*.ts : Use `domain/services/` for pipeline composition, manifest building, and cycle management

Applied to files:

  • src/acceptance/setup.ts
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/execution-bridge-and-cycles.md
  • src/domain/services/cycle-manager.test.ts
  • src/domain/services/cycle-manager.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Read `MEMORY.md` before any cross-repo or governance-heavy task

Applied to files:

  • CLAUDE.md
  • .claude/rules/docs-and-agent-context.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to **/*.md : Keep public/private boundaries intact; public repo docs should not point at private `ops` paths directly

Applied to files:

  • CLAUDE.md
  • .claude/rules/docs-and-agent-context.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.ts : Respect strict dependency direction: domain → infrastructure → features → shared → cli. No reverse imports allowed.

Applied to files:

  • CLAUDE.md
  • .claude/rules/testing-and-quality.md
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/execution-bridge-and-cycles.md
  • .dependency-cruiser.cjs
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Follow org testing standards referenced from `MEMORY.md`

Applied to files:

  • CLAUDE.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to **/*.feature : For new behavior or behavior clarification, acceptance scenarios must exist and fail before implementation

Applied to files:

  • src/infrastructure/execution/session-bridge.feature
  • .claude/rules/testing-and-quality.md
  • src/domain/services/cycle-manager.feature
  • src/features/cycle-management/cycle-activation-name-resolver.feature
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: SessionExecutionBridge is NOT an IExecutionAdapter — it splits lifecycle into prepare/complete phases

Applied to files:

  • src/infrastructure/execution/session-bridge.feature
  • src/infrastructure/execution/session-bridge.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/*.command.test.ts : Keep command-level tests focused on wiring and delegation; put parsing/formatting/selection behavior into direct unit tests

Applied to files:

  • .claude/rules/testing-and-quality.md
  • .claude/rules/cli-and-cycle-commands.md
  • src/cli/integration.test.ts
  • .claude/rules/execution-bridge-and-cycles.md
  • src/domain/services/cycle-manager.test.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/cli/commands/cycle.test.ts
  • src/cli/commands/execute.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Drive implementation with unit/integration tests until acceptance scenarios pass as part of the quality loop

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/{cli,orchestrat}*.ts : Prefer extracting pure helpers from CLI/orchestration files before adding more direct tests to large side-effect-heavy modules

Applied to files:

  • .claude/rules/testing-and-quality.md
  • .claude/rules/cli-and-cycle-commands.md
  • src/cli/integration.test.ts
  • .claude/rules/execution-bridge-and-cycles.md
  • src/domain/services/cycle-manager.test.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/cli/commands/execute.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run focused mutation testing on changed behavior-heavy modules

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Focused mutation testing must be run for changed business logic or orchestration seams with meaningful survivors explicitly called out

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run `npm run test:coverage:unit && npm run test:crap` after driving implementation with tests

Applied to files:

  • .claude/rules/testing-and-quality.md
  • scripts/run-crap-diff.mjs
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.test.ts : Vitest globals are enabled, so do not import `describe`, `it`, or `expect` — use them directly

Applied to files:

  • .claude/rules/testing-and-quality.md
  • .claude/rules/cli-and-cycle-commands.md
  • src/cli/integration.test.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/cli/**/*.ts : Use `cli/` directory as a thin wrapper using Commander.js, not for complex application logic

Applied to files:

  • scripts/run-crap-diff.mjs
  • .claude/rules/cli-and-cycle-commands.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/shared/constants/**/*.ts : Define KATA_DIRS path constants in the `shared/constants/` directory

Applied to files:

  • .claude/rules/cli-and-cycle-commands.md
  • docs-site/architecture/kataka.md
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/cli/commands/execute.ts
  • src/cli/commands/execute.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run integration tests using `npm run test:integration`

Applied to files:

  • src/cli/integration.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run unit tests using `npm run test:unit`

Applied to files:

  • src/cli/integration.test.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/infrastructure/**/*.ts : Place persistence implementations (JsonStore), registries, adapters, and tracking logic in the `infrastructure/` directory

Applied to files:

  • .claude/rules/execution-bridge-and-cycles.md
  • src/cli/commands/cycle.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/domain/ports/**/*.ts : Define interfaces (IPersistence, IStageRegistry, IRefResolver) in the `domain/ports/` directory

Applied to files:

  • .claude/rules/execution-bridge-and-cycles.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.ts : Use path aliases for internal imports: `domain/*` → `src/domain/*`, `infra/*` → `src/infrastructure/*`, `features/*` → `src/features/*`, `shared/*` → `src/shared/*`, `cli/*` → `src/cli/*`

Applied to files:

  • .claude/rules/execution-bridge-and-cycles.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Changed unit and integration tests must pass locally before submitting

Applied to files:

  • src/infrastructure/execution/session-bridge.unit.test.ts
🪛 LanguageTool
CLAUDE.md

[uncategorized] ~122-~122: Do not mix variants of the same word (‘co-locate’ and ‘colocate’) within a single text.
Context: ...to forget: worktrees for tracked edits, co-located .feature files, quickpickle, and RE...

(EN_WORD_COHERENCY)

docs-site/architecture/sensei-orchestration.md

[style] ~93-~93: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...h bet or which stage should run next. - It can dispatch work for different bets as...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~94-~94: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... is the right orchestration strategy. - It can also serialize bets when coordinati...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~125-~125: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...cursive agent-management assumptions. - It allows parallelism where Claude Code su...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~126-~126: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...lelism where Claude Code supports it. - It keeps orchestration decisions visible i...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~127-~127: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...of burying them inside a worker agent. It also keeps failure handling simpler: wh...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🪛 markdownlint-cli2 (0.21.0)
.claude/rules/docs-and-agent-context.md

[warning] 12-12: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

.claude/rules/testing-and-quality.md

[warning] 8-8: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

.claude/rules/execution-bridge-and-cycles.md

[warning] 10-10: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

docs-site/agents/context-flow.md

[warning] 9-9: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (84)
scripts/run-crap-diff.mjs (2)

11-27: findUp traversal logic looks correct and robust.

This upward search safely terminates at filesystem root and cleanly returns null when unresolved. Good reliability improvement.


86-95: Runner resolution fallback flow is solid.

Using findUp for both .bin/crap4ts and source CLI fallback is a good resilience improvement across varied local/worktree layouts.

.dependency-cruiser.cjs (2)

4-21: LGTM — robust upward traversal for worktree/monorepo compatibility.

The helper correctly walks up the directory tree, terminates at the filesystem root when parentDir === currentDir, and throws a clear error if the config isn't found. This approach aligns with the PR goal of resolving local tool installations reliably in worktrees.


1-2: Minor observation: node: protocol usage is fine.

The node:fs and node:path imports use the modern Node.js protocol syntax, which is supported in Node.js v16+ and improves clarity that these are core modules. No issues here.

docs-site/guides/file-structure.md (2)

21-21: LGTM — architecturally consistent.

The attribution clarifies that synthesis.md is written directly by the sensei/top-level orchestrator rather than delegated to spawned agents. This aligns with the architectural constraint that execution is one layer deep under sensei.


138-138: LGTM — consistent with line 21.

The description correctly states that synthesis is written directly by sensei, maintaining consistency with the file-tree comment at line 21.

docs-site/product-design/design-vision.md (2)

5-5: LGTM — link target updated to match guide relocation.

The link correctly points to the relocated system guide at ../guides/system-guide.md.


104-104: LGTM — link target updated to match architecture doc naming.

The link correctly points to ../architecture/meta-learning.md (the file is in the same architecture/ directory, so one level up then into architecture/).

docs-site/guides/system-guide.md (4)

6-14: LGTM — companion document links reorganized consistently.

All links updated to reflect the new documentation structure with product-design/, architecture/, and getting-started/ subdirectories.


109-109: LGTM — architecture link updated consistently.

Points to ../architecture/sensei-orchestration.md matching the new structure.


145-145: LGTM — getting-started link updated consistently.

Points to ../getting-started/project-setup.md matching the new structure.


151-151: LGTM — architecture reference updated consistently.

Points to ../architecture/meta-learning.md matching the new structure.

docs-site/product-design/user-journeys.md (1)

6-8: LGTM — companion links updated consistently.

Links correctly reflect the documentation reorganization: same-directory references use simple filenames, while the system guide uses the new ../guides/ path.

docs-site/architecture/dojo.md (2)

6-7: LGTM — companion links updated to new structure.

System guide moved to ../guides/ and meta-learning doc renamed (dropped -architecture suffix).


297-297: LGTM — closing reference updated consistently.

Matches the companion link update at line 6.

docs-site/architecture/meta-learning.md (2)

6-8: LGTM — companion links updated to new documentation structure.

All paths correctly reflect the reorganization: guides/, product-design/, and same-directory references.


490-490: LGTM — closing reference updated consistently.

Matches the companion link update at line 6.

docs-site/product-design/product-design.md (2)

6-9: LGTM — companion links updated consistently.

Same-directory references simplified to filenames; system guide correctly uses ../guides/ path.


80-80: LGTM — lexicon reference link updated with correct anchor.

The link correctly points to the relocated guide with the section anchor preserved.

docs-site/methodology/reference/app-flow-standard.md (1)

355-357: The referenced files do not exist in the repository. The current state of plain backticked filenames is appropriate. Adding hyperlinks as suggested would create broken references since FRONTEND_GUIDELINES.md, PLAYGROUND_AUDIT_PROTOCOL.md, and WORKFLOW_STAGES.md do not exist in this codebase. If these are intended to be reference documents, they should either be created in the repository or removed from the documentation.

			> Likely an incorrect or invalid review comment.
docs-site/agents/kata-sensei.md (1)

194-194: Good centralization update.

This clarifies the delegator model and removes ambiguity about nested worker spawning.

docs-site/getting-started/project-setup.md (1)

6-8: Link path updates look correct.

The companion/reference links are consistent and remain within public docs boundaries.

Also applies to: 139-139

docs-site/architecture/kataka.md (1)

7-10: Companion and lexicon references are aligned.

These path/anchor changes are coherent with the docs-site structure and read cleanly.

Also applies to: 31-31, 58-58

docs-site/guides/skill-overview.md (1)

108-131: Delegated-worker rewrite is clear and consistent.

The responsibility split between sensei and workers is now explicit and operationally actionable.

Also applies to: 143-143

docs-site/product-design/interaction-design.md (1)

6-9: Nice terminology and link alignment pass.

The orchestration narrative now consistently reflects the sensei/delegated-worker execution model.

Also applies to: 42-42, 85-85, 109-109, 165-167, 175-186, 416-416

docs-site/agents/orchestration.md (1)

11-21: Strong consistency update across the orchestration contract.

The revised hierarchy/rules clearly keep kata step next and gate control at sensei level while constraining worker scope.

Also applies to: 27-39, 203-204, 240-240, 438-443

docs-site/agents/context-flow.md (1)

11-13: Context-tier split is well defined.

This cleanly documents minimal worker context and keeps orchestration authority with sensei.

Also applies to: 15-16, 41-63, 68-69, 94-95, 98-141

src/acceptance/setup.ts (1)

3-3: Good acceptance wiring for new step definitions.

Line 3 correctly registers the new cycle activation resolver steps in the shared setup entrypoint.

As per coding guidelines: "Register step files for .feature files through src/acceptance/setup.ts."

src/domain/types/cycle.ts (1)

52-53: Clarifying comment matches current domain model behavior.

The added note is accurate and keeps CycleSchema semantics explicit without changing validation behavior.

src/domain/services/cycle-manager.steps.ts (2)

55-59: State-walk helper now correctly applies names only at activation boundary.

This keeps setup behavior aligned with the “name required before/at activation” rule.


211-217: Good targeted assertion for the unnamed-cycle activation rejection path.

The new Then step cleanly captures the expected domain error condition for this scenario.

src/domain/services/cycle-manager.feature (2)

3-6: LGTM!

The scenario correctly validates that a named planning cycle can transition to active. The named "Launch Cycle" step aligns with the domain requirement that planning→active transitions require a non-empty cycle name.


8-11: LGTM!

Good addition of the negative test case. This scenario ensures the domain rejects activation of unnamed planning cycles, which is the core behavior being enforced by this PR.

src/infrastructure/execution/session-bridge.test.ts (2)

989-998: LGTM!

The test correctly validates the new rejection behavior when preparing a planning cycle without a name. The setup properly mutates the cycle JSON to remove the name field, and the assertion matches the error message from prepareCycle().


1116-1116: LGTM!

Good addition of whitespace in the name parameter to validate that normalizeCycleName() trims correctly. The assertion on line 1121 confirms the trimmed result.

src/cli/integration.test.ts (1)

136-157: LGTM!

The test correctly validates the new behavior where cycle new --skip-prompts without a -n flag creates an unnamed draft cycle in planning state. The assertions properly verify:

  • CLI output contains "Cycle created"
  • Exactly one cycle file exists
  • Cycle JSON has name: undefined and state: 'planning'

This aligns with the PR objective of keeping planning cycles unnamed until activation.

src/infrastructure/execution/session-bridge.ts (1)

188-201: LGTM!

The validation logic correctly:

  1. Normalizes both the provided name and existing cycle name
  2. Throws a clear, actionable error when no name is resolved
  3. Passes the resolved name to transitionState for domain-level enforcement

This aligns with the domain-level requirement in cycle-manager.ts that planning→active transitions require a non-empty cycle name.

CLAUDE.md (1)

41-42: LGTM!

The new guidance for scoped rules maintenance and compaction instructions is clear, actionable, and aligns with the newly added .claude/rules/ files. The separation of concerns between preserving durable conventions and discarding ephemeral details is well-articulated.

Also applies to: 112-128

.claude/rules/docs-and-agent-context.md (1)

1-15: LGTM!

The scoped rule file follows the correct frontmatter format for Claude's rules and provides clear, actionable guidance. The rules align with the retrieved learnings about keeping public/private boundaries intact. The MD041 warning about first-line heading is a false positive—YAML frontmatter is expected for these scoped rule files.

src/cli/cycle-name-prompt.ts (1)

3-5: LGTM!

The guard correctly prevents prompting in JSON mode or non-interactive environments by checking both stdin and stdout TTY status.

src/features/cycle-management/cycle-activation-name-resolver.feature (1)

1-23: LGTM!

The feature file provides comprehensive acceptance coverage for the activation name resolution logic:

  • Scenario 1 validates explicit name takes precedence
  • Scenario 2 validates LLM suggestion fallback when no prompt available
  • Scenario 3 validates user-prompted override flow

The scenarios correctly test the source field tracking, which is valuable for understanding how the name was resolved. The file is properly co-located with its implementation.

src/infrastructure/execution/session-bridge.unit.test.ts (2)

438-464: LGTM — Well-structured warning verification.

The test properly spies on logger.warn, verifies the warning is emitted exactly once with the expected message content, and correctly restores the spy in a finally block. The assertion aligns with the implementation in completePendingCycleRuns (context snippet 1) which logs one warning per missing completion result.


600-617: LGTM — Correct null-filtering test setup.

The spy correctly returns null for a specific run ID while delegating to the original implementation for others. This validates the null-filtering behavior in collectCycleCompletionTotals (context snippet 2). The try/finally ensures proper cleanup.

src/domain/services/cycle-manager.test.ts (3)

61-74: LGTM — Comprehensive name normalization tests.

These tests correctly verify that the cycle manager trims whitespace from provided names and normalizes blank/whitespace-only names to undefined. This aligns with the normalizeCycleName helper in the implementation.


371-376: LGTM — Critical activation name enforcement test.

This test validates the guard that prevents transitioning from planning to active without a usable cycle name, matching the requireCycleNameForActivation implementation.


646-653: LGTM — Validates activation rejection for unnamed immediate starts.

This test ensures that startCycle without a name throws when the cycle would immediately transition to active (all bets have kata assignments), enforcing the domain invariant.

src/features/cycle-management/cycle-activation-name-resolver.test.ts (1)

1-72: LGTM — Comprehensive resolver test coverage.

This new test file properly covers all control-flow branches of resolveCycleActivationName:

  • Explicit providedName override with trimming
  • Reusing existing cycle.name
  • Fallback to suggester when unnamed
  • Prompt callback editing the suggested name
  • Rejection of whitespace-only explicit names

The makeCycle helper creates valid Cycle fixtures with appropriate defaults.

src/cli/commands/cycle.test.ts (3)

112-137: LGTM — Tests unnamed draft and whitespace normalization.

These tests correctly verify:

  • --skip-prompts without --name creates an unnamed draft cycle
  • Whitespace-only --name normalizes to undefined at creation time

This matches the normalization behavior in cycle.ts line 69.


352-376: LGTM — Auto-suggest integration test with stubbed Claude.

The test properly uses withStubbedClaudeOutput to mock the Claude CLI response, then verifies both the JSON output and persisted cycle name match the suggested value.


908-918: LGTM — Validates whitespace-only name rejection at launch.

This test ensures the CLI properly rejects whitespace-only --name values during staged launch, setting process.exitCode = 1 and emitting the expected error message.

src/features/cycle-management/cycle-name-suggester.test.ts (1)

1-179: LGTM — Thorough test coverage for cycle name suggestion utilities.

This new test file provides excellent coverage of:

  • CycleNameSuggester class: LLM success, empty response fallback, error fallback
  • buildCycleNameSuggestionPrompt: proper prompt structure with bet descriptions
  • parseSuggestedCycleName: sanitization of various LLM output formats
  • buildHeuristicCycleName: single/multiple bets, truncation, issue ref stripping

The makeCycle helper creates appropriate test fixtures with overridable fields.

src/features/cycle-management/cycle-activation-name-resolver.steps.ts (2)

30-103: LGTM — Well-structured BDD step definitions.

The Given/When/Then steps properly exercise resolveCycleActivationName across all control-flow variants:

  • providedName override → source provided
  • No prompt available → suggester fallback with source llm
  • Prompt override → source prompted with preserved suggestedName

The world state management correctly stores cycle, suggestion, and resolved result.


3-3: 🧹 Nitpick | 🔵 Trivial

Remove unnecessary vitest import per coding guidelines.

The expect function is available globally when Vitest globals are enabled. As per coding guidelines: "Vitest globals are enabled, so do not import describe, it, or expect — use them directly."

🔧 Proposed fix
-import { expect } from 'vitest';
⛔ Skipped due to learnings
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.test.ts : Vitest globals are enabled, so do not import `describe`, `it`, or `expect` — use them directly
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/acceptance/**/*.ts : Register step files for `.feature` files through `src/acceptance/setup.ts`
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run acceptance tests using `npm run test:acceptance`
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/*.command.test.ts : Keep command-level tests focused on wiring and delegation; put parsing/formatting/selection behavior into direct unit tests
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/{cli,orchestrat}*.ts : Prefer extracting pure helpers from CLI/orchestration files before adding more direct tests to large side-effect-heavy modules
src/domain/services/cycle-manager.ts (2)

13-26: LGTM — Clean centralized name normalization and activation guard.

The normalizeCycleName helper properly trims whitespace and returns undefined for empty strings. The requireCycleNameForActivation guard correctly enforces that planning → active transitions require a usable name (either provided or from the existing cycle), throwing a descriptive KataError when neither is available.


233-262: LGTM — Well-factored private helpers for transition logic.

The refactoring into renameCycleIfNeeded, assertTransitionAllowed, applyTransitionName, and requiresActivationName improves readability and testability. The applyTransitionName method correctly routes to requireCycleNameForActivation for activation scenarios while allowing optional naming for other transitions.

src/cli/commands/cycle.ts (3)

397-404: LGTM — Proper activation name resolution for cycle start.

The integration correctly:

  1. Calls resolveCycleActivationName with the draft cycle and optional --name
  2. Conditionally provides promptForCycleActivationName based on shouldPromptForCycleName(Boolean(ctx.globalOpts.json))
  3. Passes the resolved activationName.name to bridge.prepareCycle

This ensures the cycle is named before activation per the new domain invariant.


749-778: LGTM — Consistent activation naming for staged launch.

The staged launch implementation mirrors the cycle start pattern:

  • Resolves activation name with optional --name override
  • Conditionally enables prompting based on JSON mode
  • Passes resolved name to bridge.prepareCycle

The flow correctly validates agent ID before launching and provides clear error messages.


432-435: LGTM — Enhanced output includes cycle name.

Both JSON and text output now include the resolved/persisted cycle name, improving observability and UX consistency.

src/infrastructure/execution/session-bridge.steps.ts (6)

28-28: LGTM!

Adding an optional error property to capture exceptions during step execution is a clean pattern for negative test scenarios.


98-119: LGTM!

The createUnnamedPlanningCycle helper correctly creates a cycle without a name property and sets state: 'planning', aligning with the domain requirement that planning cycles remain unnamed until activation.


200-210: LGTM!

The step definition correctly initializes the test world with an unnamed planning cycle using the new helper.


284-306: LGTM!

The new step definitions correctly exercise the prepareCycle method with the new name parameter. Passing undefined as the second argument (agentId) is safe per the method signature prepareCycle(cycleId: string, agentId?: string, name?: string).


420-428: LGTM!

The assertion step correctly validates that the persisted cycle name matches the expected value after preparation.


469-472: LGTM!

The error assertion correctly validates that the cycle preparation was rejected due to a missing name, using the expected error message substring.

src/cli/commands/execute.test.ts (6)

139-153: LGTM!

The withStubbedClaudeOutput helper is well-designed with proper PATH restoration in a finally block. The platform-aware path separator handling ensures cross-platform compatibility.


329-349: LGTM!

Good coverage for the auto-suggestion flow when preparing an unnamed cycle without --name. The test correctly verifies both the console output and the persisted cycle name.


351-371: LGTM!

The test correctly validates that --name accepts and trims whitespace from the provided name, and persists the trimmed value.


373-393: LGTM!

Good negative test case ensuring whitespace-only --name values are properly rejected with an informative error message.


395-418: LGTM!

This edge case correctly tests that a whitespace-only stored cycle name is treated as unnamed and auto-recovered via the suggester.


420-431: LGTM!

Good test for the error path when the cycle reference cannot be resolved.

src/cli/commands/execute.ts (7)

22-24: LGTM!

The new imports for cycle activation name resolution and prompting are correctly structured with proper path aliases and .js extensions.

Also applies to: 100-100, 109-109


133-142: LGTM!

The integration with resolveCycleActivationName correctly passes the cycle, provided name from --name, and conditionally supplies the prompt callback based on whether JSON output is requested. This ensures non-interactive behavior when --json is set.


540-550: LGTM!

The refactored runCategories function is cleaner with clear early returns and delegation to helper functions.


552-585: LGTM!

The ExecutionSetup type and prepareExecutionRun function cleanly encapsulate the setup logic with proper early returns for failure cases.


587-615: LGTM!

The runExecutionMode function cleanly delegates to single-category or pipeline mode based on the number of categories.


617-665: LGTM!

The extracted helper functions (parseExecutionCategories, resolveExecutionBet, markExecutionProjectState, validateExecutionAgent) improve modularity and testability while maintaining the same error handling behavior.


667-680: LGTM!

The finalizeSavedKata function cleanly encapsulates the kata saving logic with proper conditional output based on JSON mode.

src/features/cycle-management/cycle-name-suggester.ts (5)

1-35: LGTM!

The CycleNameSuggester class is well-designed with dependency injection for testability. The fallback from LLM to heuristic naming on any error is appropriate for this use case.


37-66: LGTM!

The prompt construction is clear and well-constrained, providing the LLM with explicit formatting requirements that should yield consistent, parseable output.


68-84: LGTM!

The parsing logic robustly handles various LLM output quirks (bullets, numbering, quotes, common prefixes) before normalizing the result.


86-102: LGTM!

The heuristic naming strategy is sensible: use up to two bet descriptions, truncated and title-cased, with a "+ More" suffix when additional bets exist.


104-140: LGTM!

The text normalization helpers are well-implemented. The summarizeBetDescription function properly handles issue references, tokenization, truncation, and casing. The toTitleCase function correctly preserves short uppercase acronyms.

src/features/cycle-management/cycle-activation-name-resolver.ts (2)

1-19: LGTM!

The interface definitions are well-structured with clear separation between input, dependencies, and output types. The source discriminator provides good traceability for debugging and testing.


20-54: LGTM!

The resolution logic correctly implements the priority chain (provided → existing → suggested/prompted) with proper error handling for empty names and accurate source tracking.

Comment on lines +46 to +49
function normalizeCycleName(name: string | undefined): string | undefined {
const trimmed = name?.trim();
return trimmed ? trimmed : undefined;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find all definitions of normalizeCycleName across the codebase

rg -n 'function normalizeCycleName' --type=ts

Repository: cmbays/kata

Length of output: 439


🏁 Script executed:

rg -A 3 'function normalizeCycleName' --type=ts -B 1

Repository: cmbays/kata

Length of output: 1253


Extract normalizeCycleName to a shared domain service module.

This function is defined identically in three locations:

  • src/domain/services/cycle-manager.ts (line 13)
  • src/infrastructure/execution/session-bridge.ts (line 46)
  • src/features/cycle-management/cycle-activation-name-resolver.ts (line 56)

Extract it to @domain/services/cycle-helpers.ts (or similar) to eliminate duplication and ensure consistent normalization behavior across all layers.

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

In `@src/infrastructure/execution/session-bridge.ts` around lines 46 - 49, The
normalizeCycleName function is duplicated; extract it into a single shared
domain service module (e.g., domain cycle-helpers) as an exported function
normalizeCycleName(name: string | undefined): string | undefined, then replace
the local implementations by importing and using that exported function in the
files that currently define it (the cycle-manager, session-bridge, and
cycle-activation-name-resolver modules) to remove duplication and ensure a
single normalization implementation.

Copy link

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@docs-site/architecture/sensei-orchestration.md`:
- Around line 91-95: The consecutive bullets in the "sensei-orchestration"
section repetitively start with "It …", so update the four bullets (starting
with "It can manage the overall flow across multiple bets in the same cycle.",
"It can decide which bet or which stage should run next.", "It can dispatch work
for different bets as separate agent tasks when that is the right orchestration
strategy.", and "It can also serialize bets when coordination cost or dependency
risk is too high.") to remove the repeated "It can" opening—rewrite them to
start with concise verbs or noun phrases (e.g., "Manage the overall flow across
multiple bets in the same cycle.", "Decide which bet or stage should run next.",
"Dispatch work for different bets as separate agent tasks when appropriate.",
"Serialize bets when coordination cost or dependency risk is too high.") to
improve readability and consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bd4306b3-4c5b-4e88-9338-b446e9f622a4

📥 Commits

Reviewing files that changed from the base of the PR and between eaee511 and a25f4f4.

📒 Files selected for processing (19)
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/docs-and-agent-context.md
  • .claude/rules/execution-bridge-and-cycles.md
  • .claude/rules/testing-and-quality.md
  • .claude/settings.local.json
  • .gitignore
  • CLAUDE.md
  • docs-site/architecture/sensei-orchestration.md
  • src/cli/cycle-name-prompt.ts
  • src/cli/integration.test.ts
  • src/domain/services/cycle-manager.ts
  • src/domain/services/cycle-name.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-name-suggester.ts
  • src/infrastructure/execution/session-bridge.feature
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/infrastructure/execution/session-bridge.ts
💤 Files with no reviewable changes (1)
  • .claude/settings.local.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lint, Tests, Quality Loop & Build
🧰 Additional context used
📓 Path-based instructions (8)
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: All types must be defined as Zod schemas (using zod/v4 import path), not as separate interface definitions. This is a non-negotiable schema-first approach.
Use path aliases for internal imports: @domain/*src/domain/*, @infra/*src/infrastructure/*, @features/*src/features/*, @shared/*src/shared/*, @cli/*src/cli/*
Use .js file extensions on all internal imports in ESM module context
Respect strict dependency direction: domain → infrastructure → features → shared → cli. No reverse imports allowed.

Files:

  • src/domain/services/cycle-name.ts
  • src/infrastructure/execution/session-bridge.ts
  • src/cli/cycle-name-prompt.ts
  • src/domain/services/cycle-manager.ts
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/cli/integration.test.ts
  • src/features/cycle-management/cycle-name-suggester.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Colocate test files as *.test.ts next to the corresponding *.ts source file

Files:

  • src/domain/services/cycle-name.ts
  • src/infrastructure/execution/session-bridge.ts
  • src/cli/cycle-name-prompt.ts
  • src/domain/services/cycle-manager.ts
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/cli/integration.test.ts
  • src/features/cycle-management/cycle-name-suggester.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
src/domain/services/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use domain/services/ for pipeline composition, manifest building, and cycle management

Files:

  • src/domain/services/cycle-name.ts
  • src/domain/services/cycle-manager.ts
**/*.feature

📄 CodeRabbit inference engine (AGENTS.md)

**/*.feature: Co-locate .feature files with the feature they specify
For new behavior or behavior clarification, acceptance scenarios must exist and fail before implementation

Files:

  • src/infrastructure/execution/session-bridge.feature
**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

Keep public/private boundaries intact; public repo docs should not point at private ops paths directly

Files:

  • CLAUDE.md
  • docs-site/architecture/sensei-orchestration.md
src/infrastructure/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Place persistence implementations (JsonStore), registries, adapters, and tracking logic in the infrastructure/ directory

Files:

  • src/infrastructure/execution/session-bridge.ts
  • src/infrastructure/execution/session-bridge.steps.ts
src/cli/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use cli/ directory as a thin wrapper using Commander.js, not for complex application logic

Files:

  • src/cli/cycle-name-prompt.ts
  • src/cli/integration.test.ts
**/*.test.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Vitest globals are enabled, so do not import describe, it, or expect — use them directly

Files:

  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/cli/integration.test.ts
🧠 Learnings (22)
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/domain/services/**/*.ts : Use `domain/services/` for pipeline composition, manifest building, and cycle management

Applied to files:

  • src/domain/services/cycle-name.ts
  • src/infrastructure/execution/session-bridge.ts
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/execution-bridge-and-cycles.md
  • src/domain/services/cycle-manager.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to **/*.feature : For new behavior or behavior clarification, acceptance scenarios must exist and fail before implementation

Applied to files:

  • src/infrastructure/execution/session-bridge.feature
  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to **/*.md : Keep public/private boundaries intact; public repo docs should not point at private `ops` paths directly

Applied to files:

  • .claude/rules/docs-and-agent-context.md
  • CLAUDE.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Read `MEMORY.md` before any cross-repo or governance-heavy task

Applied to files:

  • .claude/rules/docs-and-agent-context.md
  • CLAUDE.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.ts : Respect strict dependency direction: domain → infrastructure → features → shared → cli. No reverse imports allowed.

Applied to files:

  • CLAUDE.md
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/execution-bridge-and-cycles.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Follow org testing standards referenced from `MEMORY.md`

Applied to files:

  • CLAUDE.md
  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/{cli,orchestrat}*.ts : Prefer extracting pure helpers from CLI/orchestration files before adding more direct tests to large side-effect-heavy modules

Applied to files:

  • src/infrastructure/execution/session-bridge.ts
  • .claude/rules/testing-and-quality.md
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/execution-bridge-and-cycles.md
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.test.ts
  • src/cli/integration.test.ts
  • src/features/cycle-management/cycle-activation-name-resolver.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/*.command.test.ts : Keep command-level tests focused on wiring and delegation; put parsing/formatting/selection behavior into direct unit tests

Applied to files:

  • .claude/rules/testing-and-quality.md
  • .claude/rules/cli-and-cycle-commands.md
  • .claude/rules/execution-bridge-and-cycles.md
  • src/features/cycle-management/cycle-name-suggester.test.ts
  • src/cli/integration.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Drive implementation with unit/integration tests until acceptance scenarios pass as part of the quality loop

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run `npm run test:coverage:unit && npm run test:crap` after driving implementation with tests

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run focused mutation testing on changed behavior-heavy modules

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Focused mutation testing must be run for changed business logic or orchestration seams with meaningful survivors explicitly called out

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/acceptance/**/*.ts : Register step files for `.feature` files through `src/acceptance/setup.ts`

Applied to files:

  • .claude/rules/testing-and-quality.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.test.ts : Vitest globals are enabled, so do not import `describe`, `it`, or `expect` — use them directly

Applied to files:

  • .claude/rules/testing-and-quality.md
  • src/cli/integration.test.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/cli/**/*.ts : Use `cli/` directory as a thin wrapper using Commander.js, not for complex application logic

Applied to files:

  • .claude/rules/cli-and-cycle-commands.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/shared/constants/**/*.ts : Define KATA_DIRS path constants in the `shared/constants/` directory

Applied to files:

  • .claude/rules/cli-and-cycle-commands.md
  • src/infrastructure/execution/session-bridge.steps.ts
  • src/cli/integration.test.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/infrastructure/**/*.ts : Place persistence implementations (JsonStore), registries, adapters, and tracking logic in the `infrastructure/` directory

Applied to files:

  • .claude/rules/execution-bridge-and-cycles.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/domain/ports/**/*.ts : Define interfaces (IPersistence, IStageRegistry, IRefResolver) in the `domain/ports/` directory

Applied to files:

  • .claude/rules/execution-bridge-and-cycles.md
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.ts : Use path aliases for internal imports: `domain/*` → `src/domain/*`, `infra/*` → `src/infrastructure/*`, `features/*` → `src/features/*`, `shared/*` → `src/shared/*`, `cli/*` → `src/cli/*`

Applied to files:

  • .claude/rules/execution-bridge-and-cycles.md
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run integration tests using `npm run test:integration`

Applied to files:

  • src/cli/integration.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Changed unit and integration tests must pass locally before submitting

Applied to files:

  • src/cli/integration.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run unit tests using `npm run test:unit`

Applied to files:

  • src/cli/integration.test.ts
🪛 LanguageTool
docs-site/architecture/sensei-orchestration.md

[style] ~93-~93: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...h bet or which stage should run next. - It can dispatch work for different bets as...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~94-~94: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... is the right orchestration strategy. - It can also serialize bets when coordinati...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~125-~125: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...cursive agent-management assumptions. - It allows parallelism where Claude Code su...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~126-~126: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...lelism where Claude Code supports it. - It keeps orchestration decisions visible i...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~127-~127: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...of burying them inside a worker agent. It also keeps failure handling simpler: wh...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (31)
docs-site/architecture/sensei-orchestration.md (1)

5-7: Good boundary-safe links and terminology alignment.

Line 6–7 keep links within public docs paths, and Line 48 uses the standardized “delegated worker agents” wording consistently with the centralized model.

As per coding guidelines, "Keep public/private boundaries intact; public repo docs should not point at private ops paths directly."

Also applies to: 48-48

src/cli/integration.test.ts (2)

1-2: LGTM!

The imports are now correctly structured: only vi is imported from Vitest (using globals for describe, it, expect, etc.), and readdirSync is properly added to support the new test case.


136-157: LGTM!

This integration test correctly validates the PR objective of allowing unnamed cycles during the planning phase. The test:

  1. Creates a cycle without the --name flag
  2. Verifies the cycle file is persisted
  3. Confirms name is undefined and state is 'planning'

The assertions align with the domain behavior where normalizeCycleName(undefined) returns undefined and the default cycle state is 'planning'.

The non-null assertion at line 154 (cycleFiles[0]!) is safe given the preceding length check at line 152.

.gitignore (1)

32-40: Good .claude ignore hardening.

This correctly keeps scoped shared config/rules trackable while ensuring settings.local.json stays ignored.

src/domain/services/cycle-name.ts (1)

1-4: Normalization helper is clean and correct.

Trim + empty-to-undefined behavior is precise and reusable for activation-name enforcement paths.

src/infrastructure/execution/session-bridge.feature (1)

28-39: Acceptance coverage for activation-time naming is solid.

These scenarios clearly lock in both the rejection path (unnamed cycle) and successful activation with an explicit name.

src/infrastructure/execution/session-bridge.ts (1)

184-197: Activation guard is implemented correctly.

Requiring a resolved non-empty name before transitionState(..., 'active', ...) removes ID-fallback ambiguity and enforces the intended domain rule.

.claude/rules/docs-and-agent-context.md (1)

14-17: Docs boundary guidance is clear and aligned.

The rules keep public docs decoupled from private ops paths and clarify current-vs-target behavior expectations.

CLAUDE.md (1)

41-42: Root guidance updates are coherent and practical.

The scoped-rule lifecycle and compact-instruction sections are consistent with the repo’s current operating model.

Also applies to: 112-128

.claude/rules/cli-and-cycle-commands.md (1)

10-14: CLI rule set matches the implemented activation policy.

Especially good to see cycle new planning-name optionality and activation-time non-empty-name requirement stated explicitly.

src/cli/cycle-name-prompt.ts (1)

3-5: Prompt gating and normalization are correct.

TTY/JSON gating is appropriate, and returning value.trim() keeps prompt output aligned with validation and downstream resolver semantics.

Also applies to: 7-16

.claude/rules/testing-and-quality.md (1)

1-19: LGTM!

The rule file is well-structured with proper frontmatter scoping and a top-level heading that addresses the previous MD041 concern. The guidance aligns with the project's testing philosophy—particularly the emphasis on extracting pure helpers before adding side-effect-heavy tests and keeping mutation ignore scope narrow.

src/domain/services/cycle-manager.ts (3)

14-22: LGTM!

The requireCycleNameForActivation helper cleanly encapsulates the activation-time naming guard with correct fallback precedence (provided name → existing cycle name → error). The error message is descriptive and actionable.


170-182: Well-refactored state transition logic.

The separation into renameCycleIfNeeded, assertTransitionAllowed, and applyTransitionName follows the principle of extracting deterministic helpers from orchestration code. The same-state rename check at line 175 correctly avoids unnecessary writes when the name hasn't changed.


245-258: Clear activation-name enforcement.

The applyTransitionName and requiresActivationName helpers correctly enforce that planning → active transitions require a resolved name while allowing optional renaming for other transitions.

src/features/cycle-management/cycle-activation-name-resolver.test.ts (2)

5-18: Clean test fixture helper.

The makeCycle factory provides sensible defaults with easy overrides, supporting deterministic test setup. Using randomUUID() for cycle IDs ensures uniqueness across test runs.


20-93: Comprehensive test coverage for resolution precedence.

The test suite thoroughly validates:

  • Priority order (provided → existing → suggested)
  • Source attribution for each path
  • Prompt editing and source preservation when accepting suggestions unchanged
  • Validation errors for whitespace-only inputs

This aligns with the learning to put parsing/formatting/selection behavior into direct unit tests rather than command-level tests.

.claude/rules/execution-bridge-and-cycles.md (1)

1-16: LGTM!

The rule file establishes clear architectural guardrails for the execution bridge layer. The H1 heading addresses the previous MD041 concern, and the content effectively codifies the dependency direction and helper extraction principles from the project learnings.

src/infrastructure/execution/session-bridge.steps.ts (3)

98-119: LGTM!

The createUnnamedPlanningCycle helper correctly creates a cycle without a name property, allowing Zod's schema parsing to handle the optional field. This supports testing the activation-name enforcement path.


296-306: Good error-capture pattern for negative testing.

The try/catch with world.error storage enables clean assertion of error scenarios without failing the step prematurely.


469-472: Clear error assertion for unnamed cycle rejection.

The assertion verifies both that an error occurred and that the message contains the expected constraint text, providing good test observability.

src/features/cycle-management/cycle-name-suggester.test.ts (3)

25-63: Thorough suggester control-flow coverage.

Tests validate the three key paths: successful LLM parsing, empty LLM output fallback, and LLM exception fallback. This ensures robust behavior regardless of Claude availability.


109-133: Good parser normalization coverage.

Tests cover the key parsing edge cases: labels/bullets/quotes, internal whitespace, preamble lines, and code fences. The undefined return for empty input ensures clean fallback handling.


135-186: Comprehensive heuristic name generation tests.

Coverage includes single/multiple bets, the + More suffix logic, empty-bets fallback, issue-ref stripping, and truncation. This aligns with the learning to put formatting/selection behavior into direct unit tests.

src/features/cycle-management/cycle-activation-name-resolver.ts (3)

1-3: Good centralization of normalization logic.

Using normalizeCycleName from @domain/services/cycle-name.js addresses the previous duplication concern and ensures consistent name handling across the codebase.


21-39: Clear resolution precedence with clean helper delegation.

The main function's structure makes the priority order immediately apparent: provided → existing → suggested (with optional prompt). Extracting each path into named helpers improves readability.


63-77: Smart source attribution for prompted names.

The logic at lines 72-74 correctly preserves the suggester's source ('llm' or 'heuristic') when the user accepts the suggestion unchanged, providing accurate attribution for analytics or logging.

src/features/cycle-management/cycle-name-suggester.ts (4)

13-35: Well-structured suggester with graceful fallback.

The try/catch pattern in suggest() ensures the function always returns a valid suggestion, falling back to heuristic naming when Claude is unavailable or returns unusable output. The comment at line 30 documents this intentional behavior.


68-77: Robust multi-line parsing strategy.

Iterating through lines and checking each with isLikelySuggestedCycleName handles various LLM output formats (preamble, code fences, etc.) gracefully.


97-114: Thorough bet description sanitization.

The summarizeBetDescription function correctly:

  • Strips common issue-linking patterns (closes #123, `fixes `#123)
  • Removes quotes that might wrap descriptions
  • Limits token count and applies truncation with ellipsis
  • Falls back to 'Planned Cycle' if normalization yields nothing

159-166: Timeout addresses previous blocking concern.

The 30-second timeout on execFileSync prevents indefinite hangs when the claude CLI is unresponsive, and the existing try/catch in suggest() handles the resulting error gracefully.

Comment on lines +91 to 95
- It can manage the overall flow across multiple bets in the same cycle.
- It can decide which bet or which stage should run next.
- It can dispatch work for different bets as separate agent tasks when that is the right orchestration strategy.
- It can also serialize bets when coordination cost or dependency risk is too high.

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Reduce repeated bullet openings to improve readability.

Several consecutive bullets start with “It …”, which makes this section feel repetitive. A small wording pass would read cleaner.

✍️ Suggested wording tweak
- - It can manage the overall flow across multiple bets in the same cycle.
- - It can decide which bet or which stage should run next.
- - It can dispatch work for different bets as separate agent tasks when that is the right orchestration strategy.
- - It can also serialize bets when coordination cost or dependency risk is too high.
+ - Sensei can manage the overall flow across multiple bets in the same cycle.
+ - It decides which bet or stage should run next.
+ - Work for different bets can be dispatched as separate agent tasks when that is the right orchestration strategy.
+ - Bets can also be serialized when coordination cost or dependency risk is too high.

Also applies to: 123-127

🧰 Tools
🪛 LanguageTool

[style] ~93-~93: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...h bet or which stage should run next. - It can dispatch work for different bets as...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~94-~94: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... is the right orchestration strategy. - It can also serialize bets when coordinati...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

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

In `@docs-site/architecture/sensei-orchestration.md` around lines 91 - 95, The
consecutive bullets in the "sensei-orchestration" section repetitively start
with "It …", so update the four bullets (starting with "It can manage the
overall flow across multiple bets in the same cycle.", "It can decide which bet
or which stage should run next.", "It can dispatch work for different bets as
separate agent tasks when that is the right orchestration strategy.", and "It
can also serialize bets when coordination cost or dependency risk is too high.")
to remove the repeated "It can" opening—rewrite them to start with concise verbs
or noun phrases (e.g., "Manage the overall flow across multiple bets in the same
cycle.", "Decide which bet or stage should run next.", "Dispatch work for
different bets as separate agent tasks when appropriate.", "Serialize bets when
coordination cost or dependency risk is too high.") to improve readability and
consistency.

coderabbitai[bot]
coderabbitai bot previously requested changes Mar 21, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/domain/services/cycle-manager.test.ts`:
- Around line 598-608: Add a test to guard against activating an empty, unnamed
cycle: when using CycleManager methods (create, startCycle) attempt to start a
newly created cycle without bets and without providing a name and assert it
fails (state is not 'active' and startCycle returns an error or contains
betsWithoutKata indicating rejection). Specifically, add a new it() similar to
the existing "transitions cycle to active..." test but call
manager.create(makeBudget()) then immediately call manager.startCycle(cycle.id,
'') or undefined and assert the cycle remains non-active and that the API
reports the empty-cycle rejection; apply the same additional test pattern
mirrored for the other case noted around the 640-652 region to cover both
branches.

In `@src/infrastructure/execution/session-bridge.unit.test.ts`:
- Around line 438-464: The test is making two separate toHaveBeenCalledWith
assertions on the same spy (warnSpy) for messages about run completion;
consolidate them into a single assertion that matches both substrings using a
regex so the expectation is atomic and clearer. Update the assertions around
warnSpy (used in the try/finally) to one
expect(warnSpy).toHaveBeenCalledWith(expect.stringMatching(/No completion result
provided for run ".*"[\s\S]*defaulting to success/)) or similar regex that
includes both "No completion result provided for run" and "defaulting to
success", leaving the rest of the assertions for bridge.completeCycle,
firstRun/secondRun, and CycleSchema unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3b51588e-8b0b-4957-b1cd-1b41e0d02eed

📥 Commits

Reviewing files that changed from the base of the PR and between a25f4f4 and e186028.

📒 Files selected for processing (2)
  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lint, Tests, Quality Loop & Build
🧰 Additional context used
📓 Path-based instructions (5)
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: All types must be defined as Zod schemas (using zod/v4 import path), not as separate interface definitions. This is a non-negotiable schema-first approach.
Use path aliases for internal imports: @domain/*src/domain/*, @infra/*src/infrastructure/*, @features/*src/features/*, @shared/*src/shared/*, @cli/*src/cli/*
Use .js file extensions on all internal imports in ESM module context
Respect strict dependency direction: domain → infrastructure → features → shared → cli. No reverse imports allowed.

Files:

  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Colocate test files as *.test.ts next to the corresponding *.ts source file

Files:

  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
src/domain/services/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use domain/services/ for pipeline composition, manifest building, and cycle management

Files:

  • src/domain/services/cycle-manager.test.ts
**/*.test.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Vitest globals are enabled, so do not import describe, it, or expect — use them directly

Files:

  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
src/infrastructure/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Place persistence implementations (JsonStore), registries, adapters, and tracking logic in the infrastructure/ directory

Files:

  • src/infrastructure/execution/session-bridge.unit.test.ts
🧠 Learnings (6)
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/*.command.test.ts : Keep command-level tests focused on wiring and delegation; put parsing/formatting/selection behavior into direct unit tests

Applied to files:

  • src/domain/services/cycle-manager.test.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to src/domain/services/**/*.ts : Use `domain/services/` for pipeline composition, manifest building, and cycle management

Applied to files:

  • src/domain/services/cycle-manager.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Applies to src/**/{cli,orchestrat}*.ts : Prefer extracting pure helpers from CLI/orchestration files before adding more direct tests to large side-effect-heavy modules

Applied to files:

  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
📚 Learning: 2026-03-20T03:28:00.814Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-20T03:28:00.814Z
Learning: Applies to **/*.test.ts : Vitest globals are enabled, so do not import `describe`, `it`, or `expect` — use them directly

Applied to files:

  • src/domain/services/cycle-manager.test.ts
  • src/infrastructure/execution/session-bridge.unit.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Changed unit and integration tests must pass locally before submitting

Applied to files:

  • src/infrastructure/execution/session-bridge.unit.test.ts
📚 Learning: 2026-03-15T01:51:21.342Z
Learnt from: CR
Repo: cmbays/kata PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T01:51:21.342Z
Learning: Run unit tests using `npm run test:unit`

Applied to files:

  • src/infrastructure/execution/session-bridge.unit.test.ts
🔇 Additional comments (5)
src/domain/services/cycle-manager.test.ts (2)

60-63: Good normalization coverage for create-time naming.

These cases cleanly lock in trim + blank-to-undefined behavior and reduce regressions around draft-cycle naming.

Also applies to: 70-73


327-332: Activation gate tests are solid and aligned with the new rule.

This set validates all key paths: existing name carry-forward, supplied-name normalization, and hard failure when activation has no valid name.

Also applies to: 365-375

src/infrastructure/execution/session-bridge.unit.test.ts (3)

5-5: LGTM!

The import correctly excludes describe, it, expect, and vi since Vitest globals are enabled. Explicitly importing beforeEach and afterEach is valid and works alongside the globals configuration.


191-206: LGTM!

Good test coverage for cycle name normalization. The input ' Renamed Cycle ' with leading/trailing whitespace properly validates that the domain/infrastructure layer trims and normalizes names before persisting.


600-617: LGTM!

The spy implementation correctly delegates to the original function for most runs while returning null for the specific test case. The try/finally pattern ensures proper cleanup. The assertion completedBets === 1 is correct: one run is completed and readable, while the other returns null and is filtered out per the implementation in collectCycleCompletionTotals.

@cmbays cmbays dismissed stale reviews from coderabbitai[bot] and coderabbitai[bot] March 21, 2026 22:25

Superseded by later commits; all actionable feedback has been addressed.

@cmbays cmbays merged commit c3489c4 into main Mar 21, 2026
2 of 3 checks passed
@cmbays cmbays deleted the codex-quick-wins-20260321 branch March 21, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant