Skip to content

Slice/m2.9#354

Open
failerko wants to merge 14 commits into
mainfrom
slice/M2.9
Open

Slice/m2.9#354
failerko wants to merge 14 commits into
mainfrom
slice/M2.9

Conversation

@failerko

@failerko failerko commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added pre-flight validation that catches configuration resolver failures before pipeline execution begins.
    • Introduced system entries for diagnostic artifacts that are excluded from undo/rollback operations.
  • Documentation

    • Updated data model documentation to clarify system entry behavior and lifecycle.
    • Enhanced pre-flight implementation guidance with resolver input specifications.
  • Tests

    • Added comprehensive test coverage for system entry operations and pre-flight orchestration validation.

failerko and others added 14 commits June 16, 2026 22:05
…r error

PhaseNode now declares resolves?: ResolverInput[] on both serial and parallel variants to enumerate which configuration inputs each phase validates. PreflightSnapshot and ResolverInput types define the shape of preflight validation contracts. config-resolver PipelineError variant captures resolution failures during the pre-flight walk (Slice 2.9 task 1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The structured fields (failure/target/phaseName) are the contract; detail stays optional so the pre-flight walk can omit it and only the orchestrator's existing log fallback consumes it.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…phase 0

Wires runPreflight into the inner for(;;) loop as the first statement, so any declared resolver failures abort the run before phase 0 executes. Routes through the existing abortRun path (preflight-failure → outcome=failed, reverse-replay is a no-op at zero deltas). Widens AbortCause and abortRun's cause param with 'preflight-failure'; the user-cancel/otherwise ternary maps it to 'failed' without further change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gged)

Direct insert/delete bypasses the delta log — system entries are diagnostic
artifacts, not narrative state. writeSystemEntry clears any existing system
entry before inserting so the MAX(position)+1 subquery resolves to the true
content tail; at most one per branch, always the last entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A throwing ResolverInput.when predicate rejected runPipeline outside the abort path, orphaning the registered run + its unresolved terminal (blocked edits, deadlocked awaitRunTerminal waiters). Catch and fail through abortRun like phase throws.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Implements Slice 2.9 config pre-flight validation: extends pipeline types with PreflightSnapshot, ResolverInput, and a config-resolver PipelineError variant; adds runPreflight that validates per-PhaseNode resolver inputs before phase 0; wires it into the orchestrator with a preflight-failure abort path. Also introduces non-delta-logged writeSystemEntry/clearSystemEntry DB helpers for per-branch singleton system story entries, with supporting tests and data model documentation.

Changes

Config Pre-flight Validation and System Entry Helpers

Layer / File(s) Summary
Pipeline type contracts
lib/pipeline/types.ts, lib/pipeline/index.ts
Extends PipelineError with a config-resolver variant (failure, target, phaseName, optional detail); adds PreflightSnapshot and ResolverInput types; extends PhaseNode serial and parallel forms with optional resolves?: readonly ResolverInput[]; re-exports both new types from the module index.
runPreflight implementation and unit tests
lib/pipeline/runtime/preflight.ts, lib/pipeline/runtime/preflight.test.ts
Implements runPreflight iterating phases and parallel branches, filtering by when predicates, calling resolveModel, and returning the first config-resolver failure or null. Unit tests cover success, all failure kinds, phase/parallel traversal order, selectivity, predicate skipping/forwarding, and network-call purity.
Orchestrator preflight integration and tests
lib/pipeline/runtime/orchestrator.ts, lib/pipeline/__tests__/preflight-orchestration.test.ts
Imports appSettingsStore and runPreflight; extends AbortCause.reason with 'preflight-failure'; inserts a preflight gate before runPhases that calls abortRun on failure. Orchestration tests verify broken resolver halts before phase 0 with no deltas emitted, valid config reaches phase 0, and predicate throws produce a clean abort with no stranded runs.
System entry DB helpers, tests, and data model doc
lib/actions/story-entries/system-entry.ts, lib/actions/story-entries/system-entry.test.ts, lib/actions/index.ts, docs/data-model.md
Adds clearSystemEntry (transactional delete of kind='system' rows) and writeSystemEntry (clear-then-insert singleton at MAX(position)+1, metadata: null); re-exports both from lib/actions/index.ts. Tests cover tail insertion, singleton replacement, empty-branch initial insert, and no-op clear. Data model doc section codifies the non-delta-logged, rollback-invisible, per-branch-tail-singleton rule.
Preflight slice specification updates
docs/implementation/milestones/02-first-user-loop/slices/09-preflight.md
Records the resolved per-PhaseNode resolves? declaration syntax, when predicate shape using PreflightSnapshot, resolveModel delegation, abort-before-phase-0 control flow, system-entry direct-insert semantics, and a developer follow-up note on doc wording reconciliation.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant runPipeline
  participant runPreflight
  participant resolveModel
  participant abortRun

  Caller->>runPipeline: runPipeline(pipeline, ctx)
  runPipeline->>runPreflight: runPreflight(pipeline, { appSettings })
  loop Each phase → branch → resolves input
    runPreflight->>resolveModel: resolveModel(target, config)
    resolveModel-->>runPreflight: ok | failure
  end
  alt any input fails
    runPreflight-->>runPipeline: ConfigResolverError { kind, target, phaseName }
    runPipeline->>abortRun: abortRun('preflight-failure', error)
    abortRun-->>runPipeline: failed pipeline_runs record + run_complete event
    runPipeline-->>Caller: failed result (no deltas, no phase 0)
  else all inputs pass
    runPreflight-->>runPipeline: null
    runPipeline->>runPipeline: runPhases(...)
    runPipeline-->>Caller: completed result
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐇 Hoppity-hop, before phase zero we go,
The resolver checks targets all in a row.
A system entry slips in, no delta to log,
CTRL-Z won't find it — it hides in the fog.
Pre-flight is pure, no fetch calls allowed,
This bunny declares the pipeline is proud! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Slice/m2.9' is vague and generic, providing no meaningful information about the actual changes made in this comprehensive pull request. Use a more descriptive title that captures the main change, such as 'Implement preflight config resolution and system entry management' or 'Add M2.9 preflight orchestration with system entry helpers'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements a configuration pre-flight validation step before running pipeline phases, ensuring that declared resolver inputs are valid against the current settings. It introduces runPreflight to perform this check in phase order, aborting the pipeline run cleanly with a config-resolver error if validation fails. Additionally, it introduces direct, non-delta-logged "system entries" (kind='system') to represent diagnostic artifacts (such as configuration failures) at the branch tail, along with actions to write and clear them, complete with comprehensive unit and integration tests. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@docs/implementation/milestones/02-first-user-loop/slices/09-preflight.md`:
- Around line 148-159: The document contains conflicting guidance about system
entry write behavior. While the Preflight section correctly states that system
entries use direct non-delta-logged inserts, the Background and Scope sections
earlier in the 09-preflight.md file still reference composing the delta-logged
entry-create arm. Update the wording in the Background and Scope sections to
consistently state that system entries use direct non-delta inserts instead of
the delta-logged entry-create approach, ensuring the entire document describes a
single canonical behavior for system entry handling.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9e2d302-2b2c-4fbe-b0b4-154a132b7292

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3b7f6 and 64ac73d.

📒 Files selected for processing (11)
  • docs/data-model.md
  • docs/implementation/milestones/02-first-user-loop/slices/09-preflight.md
  • lib/actions/index.ts
  • lib/actions/story-entries/system-entry.test.ts
  • lib/actions/story-entries/system-entry.ts
  • lib/pipeline/__tests__/preflight-orchestration.test.ts
  • lib/pipeline/index.ts
  • lib/pipeline/runtime/orchestrator.ts
  • lib/pipeline/runtime/preflight.test.ts
  • lib/pipeline/runtime/preflight.ts
  • lib/pipeline/types.ts

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.

Slice 2.9 — Resolver-input declaration + config pre-flight validation

1 participant