Skip to content

test: cover recoverable session-load errors and run-id branding#275

Merged
tobyhede merged 2 commits intomainfrom
worktree-rdpath-recoverable-tests
May 8, 2026
Merged

test: cover recoverable session-load errors and run-id branding#275
tobyhede merged 2 commits intomainfrom
worktree-rdpath-recoverable-tests

Conversation

@tobyhede
Copy link
Copy Markdown
Owner

@tobyhede tobyhede commented May 7, 2026

Summary

  • Adds three integration cases to packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts that exercise the isRecoverableActiveStateLookupError branches added to packages/claude-code-plugin/src/rdpath.ts in Artifact uri phase 3 cli runtime variable contract exec #267: legacy ownedRunbooks session, legacy stacks session, and SessionDataSchema validation failure.
  • Adds packages/core/__tests__/runbook/run-id.test.ts covering isRunId, assertRunId, RUN_ID_PATTERN, and RUN_ID_PREFIX. assertRunId is the canonical run-id validator that brand-helpers.ts and a growing set of fixtures rely on; it had no direct tests in core.
  • Replaces CodeRabbit Generated Unit Tests: Add generated unit tests for PR changes #268. CodeRabbit's auto-generated PR deleted ~440 lines of existing integration tests while appending three new ones; this PR adds only the three new cases on top of the current main, plus the core run-id tests.

Test plan

  • `packages/core` — `npm test -- --testPathPatterns=run-id` (23/23)
  • `packages/claude-code-plugin` — `npm test -- --testPathPatterns=rdpath-find-integration` (26/26)
  • `npm run check:format`, `check:spell`, `check:lint:fast`, `check:lint:typed` clean
  • Full unit suite green across all packages

Summary by CodeRabbit

  • Tests
    • Added integration tests ensuring path-resolution gracefully handles legacy/invalid session data and still exits cleanly with expected output path.
    • Added unit tests validating run ID format and assertion behavior, covering valid cases, multiple invalid formats, edge cases, and exported pattern/constant expectations.

Adds three integration cases to rdpath-find-integration.test.ts that
exercise the new isRecoverableActiveStateLookupError branches in
packages/claude-code-plugin/src/rdpath.ts: legacy ownedRunbooks format,
legacy stacks format, and SessionDataSchema validation failure.

Adds packages/core/__tests__/runbook/run-id.test.ts covering isRunId,
assertRunId, RUN_ID_PATTERN, and RUN_ID_PREFIX. assertRunId is the
canonical run-id validator that brand-helpers and a growing set of
fixtures rely on; it had no direct tests in core.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2b8fbe53-59b7-416b-89ed-2e6ea28b165f

📥 Commits

Reviewing files that changed from the base of the PR and between 5199728 and d9c469f.

📒 Files selected for processing (1)
  • packages/core/__tests__/runbook/run-id.test.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: perf
  • GitHub Check: playwright
  • GitHub Check: scenarios
  • GitHub Check: lint-typed (24)
  • GitHub Check: test (24)
  • GitHub Check: analyze
  • GitHub Check: smoke-test-linux
  • GitHub Check: Cloudflare Pages
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use clear, descriptive variable and function names that convey intent
Add comments for complex logic and non-obvious code sections
Use async/await over callbacks and promise chains
Use const by default, let for variables that need reassignment, avoid var
Use template literals instead of string concatenation

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript for type safety; define explicit types instead of relying on inference

**/*.{ts,tsx}: Prefer interface for defining object shapes in TypeScript
Use isError(), isNodeError(), or getErrorMessage() from @rundown-org/core (or packages/claude-code-plugin/src/shared/errors.ts inside the plugin) — never call Error.isError() directly
All exported TypeScript symbols must have TSDoc documentation including description, @param for all parameters, @returns if non-void, and @throws if exceptions are possible
Use discriminated unions and type narrowing to make invalid states unrepresentable. Guards should express domain conditions through typed return values, never raw action-type string checks.
Use XState's native event system and state graph structure instead of creating artificial state identifiers (like ~channel prefixes) for synthetic IDs.

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
**/*.test.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests with clear arrange-act-assert structure

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
**/*.{ts,tsx,js,mjs,cjs}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,mjs,cjs}: Use camelCase for variable names in TypeScript/JavaScript
Always use async/await for promises in TypeScript/JavaScript
Variable names must match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/ (alphanumeric and underscore, starting with letter or underscore)

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Mock injected core services structurally in non-core tests using object-shaped service doubles instead of constructing real core services from mocked modules

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
**/__tests__/**/*.ts

⚙️ CodeRabbit configuration file

**/__tests__/**/*.ts: Test files. Focus on:

  • Use Error.isError() instead of instanceof Error except for same-realm custom error classes.
  • Mock passthrough pattern: pass through real functions that do not need mocking.
  • Test isolation, meaningful assertions, edge cases, and regression coverage for changed behavior.
  • Prefer targeted verification commands that match the package touched by the PR.

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
🧠 Learnings (5)
📚 Learning: 2026-03-13T07:37:13.038Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 102
File: packages/cli/__tests__/commands/fail.test.ts:134-141
Timestamp: 2026-03-13T07:37:13.038Z
Learning: In the tobyhede/rundown repository, ensure that ErrorResponseSchema in packages/core/src/output/zod-schemas.ts uses command: z.string().optional() (renamed from action) to reflect NoActiveRunbookOutput.action → command across the codebase. Update and verify all references to this field, including related code paths such as OutputEmitter.noActiveRunbook() and json-renderer.ts. During reviews, check that tests (e.g., packages/cli/__tests__/commands/fail.test.ts) align with the new field name and that any expectations or mocks reference command rather than action.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
📚 Learning: 2026-04-06T04:20:01.297Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 177
File: packages/claude-code-plugin/runbooks/planning/write-plan.runbook.md:24-24
Timestamp: 2026-04-06T04:20:01.297Z
Learning: In this repository (tobyhede/rundown), `CLAUDE_PLUGIN_ROOT` is part of a published contract and is guaranteed to already include a trailing `/` (enforced since PR `#174`). Therefore, when reviewing code, do not flag path concatenations that join the variable directly to the next path segment (e.g., `{{ CLAUDE_PLUGIN_ROOT }}schemas/plan.schema.json`) as missing a separator—this resolves correctly because the trailing slash is included in the variable value.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
📚 Learning: 2026-04-24T01:48:48.712Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 227
File: packages/core/__tests__/runbook/compiler.test.ts:9985-10000
Timestamp: 2026-04-24T01:48:48.712Z
Learning: In `packages/core/__tests__/runbook/**/*.test.ts`, avoid using `as any` when preparing hydrated/persisted snapshots for `createActor(machine, { snapshot })`. Instead, construct the persisted snapshot in a typed way (e.g., start from `baseSnap` and build the final snapshot via object spread so TypeScript can infer `typeof baseSnap`). This keeps the persisted snapshot/context shape checked at compile time and prevents schema drift from bypassing the type system.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
📚 Learning: 2026-05-08T00:05:42.310Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 274
File: packages/core/__tests__/runbook/compiler.test.ts:8754-8772
Timestamp: 2026-05-08T00:05:42.310Z
Learning: In the tobyhede/rundown runbook compiler tests that cover naked step/substep OUTPUTS (executor file-backed), when verifying that a specific context variable is not produced, assert absence per key with `expect(snapshot.context.variables).not.toHaveProperty('<Key>')` instead of asserting `expect(snapshot.context.variables).toEqual({})`. This avoids over-constraining unrelated context variables while still checking that the expected keys are truly missing.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
📚 Learning: 2026-05-03T01:45:03.732Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 255
File: packages/cli/__tests__/commands/status.test.ts:239-249
Timestamp: 2026-05-03T01:45:03.732Z
Learning: In tobyhede/rundown’s status output logic (notably `buildStashedStatus` in `packages/cli`/`packages/core`), when a stashed runbook has `parentLinkage.kind === 'delegation'`, the generated status must omit the `vars` key for delegation-claimed children. Specifically, `rd status` (without `--claim-id`) must not expose inherited variable contents for these delegation-claimed descendants (e.g., ensure output does not contain sensitive values). Only callers using `rd status --claim-id <claimId>` (the capability-holder) are allowed to see the `vars` field for stashed delegated children. This guards against production data leaks; preserve/test this isolation behavior (as fixed in PR `#255`, commit dfba8464).

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
🔇 Additional comments (4)
packages/core/__tests__/runbook/run-id.test.ts (4)

109-119: Parameterized negative parity checks keep RUN_ID_PATTERN and isRunId in sync.

The it.each approach systematically verifies that both the regex and the predicate reject the same invalid inputs. This directly addresses the prior review concern and ensures the pattern and function remain consistent as the validation logic evolves.


4-63: Excellent systematic coverage of isRunId validation rules.

The test suite methodically covers both valid canonical formats (including edge-case hex bodies) and a comprehensive range of rejection scenarios—uppercase variants, length boundaries, non-hex characters, legacy formats, and type guards. This provides strong regression protection for the run-id validation contract.


65-91: Strong coverage of assertRunId semantics.

The tests confirm the brand-helper contract: valid inputs pass through unchanged, invalid inputs throw, and the function is safely idempotent. The error-message check at line 72 ensures the thrown error provides actionable feedback to callers.


1-120: Well-structured test suite with comprehensive run-id validation coverage.

The file systematically exercises all exported run-id helpers with clear positive and negative cases. The organization into three focused describe blocks and the use of parameterized tests for negative-parity checks makes the suite maintainable and easy to extend. No issues identified.


📝 Walkthrough

Walkthrough

Adds three integration tests checking rdpath soft-fail behavior with legacy/malformed .rundown/session.json when RD_WORK_PATH is set, and adds unit tests validating isRunId/assertRunId and exported RUN_ID constants/pattern.

Changes

rdpath Legacy Session Data Fallback Tests

Layer / File(s) Summary
Soft-fail scenarios for legacy/invalid session formats
packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
Adds three integration tests asserting that rdpath --file plan.json soft-fails gracefully (exit 0, no stderr, dated path output without context segment) when RD_WORK_PATH is set and .rundown/session.json contains legacy ownedRunbooks ownership format, legacy stacks structure, or schema-validation-failing content.

Run ID Validation and Canonicalization Tests

Layer / File(s) Summary
isRunId validation rules
packages/core/__tests__/runbook/run-id.test.ts
Tests that isRunId accepts only canonical rd_ + 32 lowercase hex and rejects uppercase prefix/body, wrong lengths (31/33 chars), non-hex characters, UUID-style hyphenation, empty strings, bare rd_, legacy wf-YYYY-MM-DD-... format, and non-string inputs.
assertRunId behavior and idempotency
packages/core/__tests__/runbook/run-id.test.ts
Tests that assertRunId returns valid IDs unchanged, throws on invalid inputs, and is idempotent for canonical IDs.
Run ID constants and pattern exports
packages/core/__tests__/runbook/run-id.test.ts
Tests that RUN_ID_PREFIX exports 'rd_', RUN_ID_PATTERN is fully anchored, and the pattern matches all IDs that isRunId validates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • tobyhede/rundown#131: Prior modifications to rdpath integration tests in the same file.
  • tobyhede/rundown#249: Added tests handling legacy/invalid .rundown/session.json formats (including stacks and ownership shapes).
  • tobyhede/rundown#247: Introduced active-state fallback and soft-fail logic that these integration tests exercise.
🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding tests for recoverable session-load errors and run-id validation coverage.
Description check ✅ Passed The description comprehensively covers objectives, test coverage, and test plan execution with specific file paths and test counts, but omits the description template's Review Notes checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Persisted State No-Migration ✅ Passed PR adds tests for rejecting legacy session state. No migration logic, compatibility shims, or state rewriting. Legacy state is rejected; rdpath gracefully proceeds without context rather than failing.
Cli Schema Coverage ✅ Passed PR adds test-only changes. No CLI output behavior, command definitions, schemas, or OutputEmitter usage were modified. All CLI/schema source files remain unchanged.
Sha-Pinned Workflow Actions ✅ Passed All 6 GitHub Actions workflows are properly SHA-pinned with version comments. Every action uses commit SHAs with version tags; no unpinned tags like @v4 detected. Security best practices met.
Security Policy Review ✅ Passed Test-only PR. No code changes to production. No modifications to security policy or sensitive areas. Per check: passes if PR doesn't touch these areas.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-rdpath-recoverable-tests

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

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 8, 2026

Deploying rundown with  Cloudflare Pages  Cloudflare Pages

Latest commit: d9c469f
Status: ✅  Deploy successful!
Preview URL: https://1c5cc1a2.rundown-7hl.pages.dev
Branch Preview URL: https://worktree-rdpath-recoverable.rundown-7hl.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/__tests__/runbook/run-id.test.ts`:
- Around line 103-107: Add negative parity checks so RUN_ID_PATTERN and isRunId
remain consistent: update the test in run-id.test.ts (the case using
RUN_ID_PATTERN and isRunId) to include several rejected cases (e.g., missing
"rd_" prefix, uppercase hex, wrong length, non-hex chars) and assert both
RUN_ID_PATTERN.test(value) and isRunId(value) are false for those inputs;
alternatively factor allowed and disallowed examples into a shared fixture array
and iterate asserting true for allowed examples and false for disallowed ones to
ensure regex and isRunId stay in sync.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: adfd1251-be58-4ea3-ba3f-3ee726960f99

📥 Commits

Reviewing files that changed from the base of the PR and between 17cc2b9 and 5199728.

📒 Files selected for processing (2)
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
  • packages/core/__tests__/runbook/run-id.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: setup-build (24)
  • GitHub Check: smoke-test-macos
  • GitHub Check: smoke-test-linux
  • GitHub Check: analyze
  • GitHub Check: smoke-test-macos
  • GitHub Check: smoke-test-linux
  • GitHub Check: Cloudflare Pages
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use clear, descriptive variable and function names that convey intent
Add comments for complex logic and non-obvious code sections
Use async/await over callbacks and promise chains
Use const by default, let for variables that need reassignment, avoid var
Use template literals instead of string concatenation

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript for type safety; define explicit types instead of relying on inference

**/*.{ts,tsx}: Prefer interface for defining object shapes in TypeScript
Use isError(), isNodeError(), or getErrorMessage() from @rundown-org/core (or packages/claude-code-plugin/src/shared/errors.ts inside the plugin) — never call Error.isError() directly
All exported TypeScript symbols must have TSDoc documentation including description, @param for all parameters, @returns if non-void, and @throws if exceptions are possible
Use discriminated unions and type narrowing to make invalid states unrepresentable. Guards should express domain conditions through typed return values, never raw action-type string checks.
Use XState's native event system and state graph structure instead of creating artificial state identifiers (like ~channel prefixes) for synthetic IDs.

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
**/*.test.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests with clear arrange-act-assert structure

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
**/*.{ts,tsx,js,mjs,cjs}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,mjs,cjs}: Use camelCase for variable names in TypeScript/JavaScript
Always use async/await for promises in TypeScript/JavaScript
Variable names must match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/ (alphanumeric and underscore, starting with letter or underscore)

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Mock injected core services structurally in non-core tests using object-shaped service doubles instead of constructing real core services from mocked modules

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
**/__tests__/**/*.ts

⚙️ CodeRabbit configuration file

**/__tests__/**/*.ts: Test files. Focus on:

  • Use Error.isError() instead of instanceof Error except for same-realm custom error classes.
  • Mock passthrough pattern: pass through real functions that do not need mocking.
  • Test isolation, meaningful assertions, edge cases, and regression coverage for changed behavior.
  • Prefer targeted verification commands that match the package touched by the PR.

Files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
packages/claude-code-plugin/**/*.ts

⚙️ CodeRabbit configuration file

packages/claude-code-plugin/**/*.ts: Claude Code plugin for runbook orchestration. Focus on:

  • MCP integration correctness, runbook discovery, namespace resolution, state lifecycle, and hook behavior.
  • Safe path handling for plugin root/data paths and generated files.
  • Changes to Zod schemas must stay consistent with checked-in JSON schemas.

Files:

  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
🧠 Learnings (6)
📚 Learning: 2026-03-13T07:37:13.038Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 102
File: packages/cli/__tests__/commands/fail.test.ts:134-141
Timestamp: 2026-03-13T07:37:13.038Z
Learning: In the tobyhede/rundown repository, ensure that ErrorResponseSchema in packages/core/src/output/zod-schemas.ts uses command: z.string().optional() (renamed from action) to reflect NoActiveRunbookOutput.action → command across the codebase. Update and verify all references to this field, including related code paths such as OutputEmitter.noActiveRunbook() and json-renderer.ts. During reviews, check that tests (e.g., packages/cli/__tests__/commands/fail.test.ts) align with the new field name and that any expectations or mocks reference command rather than action.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
📚 Learning: 2026-04-06T04:20:01.297Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 177
File: packages/claude-code-plugin/runbooks/planning/write-plan.runbook.md:24-24
Timestamp: 2026-04-06T04:20:01.297Z
Learning: In this repository (tobyhede/rundown), `CLAUDE_PLUGIN_ROOT` is part of a published contract and is guaranteed to already include a trailing `/` (enforced since PR `#174`). Therefore, when reviewing code, do not flag path concatenations that join the variable directly to the next path segment (e.g., `{{ CLAUDE_PLUGIN_ROOT }}schemas/plan.schema.json`) as missing a separator—this resolves correctly because the trailing slash is included in the variable value.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
📚 Learning: 2026-04-24T01:48:48.712Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 227
File: packages/core/__tests__/runbook/compiler.test.ts:9985-10000
Timestamp: 2026-04-24T01:48:48.712Z
Learning: In `packages/core/__tests__/runbook/**/*.test.ts`, avoid using `as any` when preparing hydrated/persisted snapshots for `createActor(machine, { snapshot })`. Instead, construct the persisted snapshot in a typed way (e.g., start from `baseSnap` and build the final snapshot via object spread so TypeScript can infer `typeof baseSnap`). This keeps the persisted snapshot/context shape checked at compile time and prevents schema drift from bypassing the type system.

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
📚 Learning: 2026-05-03T01:45:03.732Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 255
File: packages/cli/__tests__/commands/status.test.ts:239-249
Timestamp: 2026-05-03T01:45:03.732Z
Learning: In tobyhede/rundown’s status output logic (notably `buildStashedStatus` in `packages/cli`/`packages/core`), when a stashed runbook has `parentLinkage.kind === 'delegation'`, the generated status must omit the `vars` key for delegation-claimed children. Specifically, `rd status` (without `--claim-id`) must not expose inherited variable contents for these delegation-claimed descendants (e.g., ensure output does not contain sensitive values). Only callers using `rd status --claim-id <claimId>` (the capability-holder) are allowed to see the `vars` field for stashed delegated children. This guards against production data leaks; preserve/test this isolation behavior (as fixed in PR `#255`, commit dfba8464).

Applied to files:

  • packages/core/__tests__/runbook/run-id.test.ts
📚 Learning: 2026-03-12T12:08:17.780Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 100
File: packages/claude-code-plugin/src/rdpath-core.ts:9-9
Timestamp: 2026-03-12T12:08:17.780Z
Learning: For imports from 'node:path' in the packages/claude-code-plugin package, prefer namespace imports: import * as path from 'node:path'. This is the dominant pattern across 8+ files (e.g., shared/logger.ts, shared/utils.ts, context.ts, gate-loader.ts, gates/plugin-path.ts, shared/config.ts). Do not suggest switching to named imports; preserve the namespace import convention in this package.

Applied to files:

  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
📚 Learning: 2026-04-08T00:08:09.549Z
Learnt from: tobyhede
Repo: tobyhede/rundown PR: 187
File: packages/claude-code-plugin/__tests__/review-schema.test.ts:98-99
Timestamp: 2026-04-08T00:08:09.549Z
Learning: In tobyhede/rundown, enforce the CLAUDE.md `isZodError()` convention for Zod-related errors. Instead of `instanceof ZodError` in both test and production code (and instead of `toThrow(ZodError)` / `expect(...).toBeInstanceOf(ZodError)` in Jest tests), write Jest assertions as: use `expect(fn).toThrow()` (no `ZodError` class argument), then capture the thrown error (or use the matcher’s error value) and assert `expect(isZodError(err)).toBe(true)` using `isZodError` from `packages/claude-code-plugin/src/shared/errors.ts`. Do not accept the `ZodError` class checks even if they might work due to module loading nuances; treat them as violations. Existing occurrences may be considered acknowledged tech debt until cleaned up (e.g., in plan-schema*.test.ts files).

Applied to files:

  • packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts
🔇 Additional comments (2)
packages/claude-code-plugin/__tests__/rdpath-find-integration.test.ts (1)

471-540: Nice regression coverage for recoverable session-load failures.

These cases pin the intended CLI contract well: exit 0, no stderr, and no ctx segment when session.json is legacy or schema-invalid.

packages/core/__tests__/runbook/run-id.test.ts (1)

4-91: Good coverage of the canonical run-id validator contract.

The accepted/rejected cases plus assertRunId idempotence make the branded run-id rules very explicit.

Comment thread packages/core/__tests__/runbook/run-id.test.ts
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

Existing parity test only verified the positive direction. Add an it.each
block covering common invalid inputs (missing prefix, uppercase hex,
wrong length, non-hex chars, UUID body) and assert both
RUN_ID_PATTERN.test() and isRunId() return false, so the regex and the
predicate stay in sync if either changes.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

✅ Created PR with unit tests: #276

@tobyhede tobyhede merged commit 76f8882 into main May 8, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant