Skip to content

feat: add execution-slice output format - #216

Merged
mohanagy merged 5 commits into
mainfrom
issue-164-execution-slice
May 19, 2026
Merged

mohanagy merged 5 commits into
mainfrom
issue-164-execution-slice

Conversation

@mohanagy

@mohanagy mohanagy commented May 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add a separate execution_slice field to compact runtime-generation backend packs while preserving the existing slice metadata
  • cover complete and partial execution-path behavior across retrieve, context_pack command, and stdio surfaces
  • document the new output in the changelog and proof workflows docs

Test Plan

  • npm run typecheck
  • npm run build
  • CI=1 npm run test:run

Closes #164

Summary by CodeRabbit

  • New Features

    • Added execution-slice context packs with ordered runtime steps and partial-path signaling, surfaced alongside existing slice metadata in runtime-generation backend packs.
  • Documentation

    • Updated baseline-mode documentation to reflect the expanded set of compact pack audit fields captured in reports, including execution-slice runtime-generation details.

Review Change Stack

mohanagy and others added 5 commits May 19, 2026 13:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR implements execution-slice output format for runtime-generation context packs. It adds contract types for execution steps, builds an algorithm to construct ordered runtime slices from graph data, integrates slice generation into the retrieval pipeline, propagates execution slices through pack conversion and compaction, and validates the feature across command, strategy, and stdio tests.

Changes

Execution-slice context pack feature

Layer / File(s) Summary
Execution-slice contract types
src/contracts/context-pack.ts
New exported interfaces ContextPackExecutionSliceStep and ContextPackExecutionSlice model per-step metadata (node id, label, source file/line, optional kind/framework) and overall slice status (complete/partial, steps, boundary reason). CompiledContextPack extended with optional execution_slice field.
Execution-slice building algorithm
src/runtime/retrieve.ts
buildExecutionSlice function constructs runtime slices by identifying execution-flow relations, scoring step priority from question/labels, selecting in-scope nodes, choosing start nodes under predecessor constraints, walking constrained successor links, and returning complete or partial status with optional boundary reason.
Retrieval result integration
src/runtime/retrieve.ts
RetrieveResult extended with optional execution_slice field. buildRetrieveResultFromOrderedCandidates calls buildExecutionSlice and includes result in final object.
Pack conversion and compaction
src/runtime/retrieve.ts
contextPackFromRetrieveResult includes execution_slice in compiled pack output. compactRetrieveResult and compactRetrieveResultForStdio preserve and forward execution_slice through the conversion pipeline.
Context-pack command test
tests/unit/context-pack-command.test.ts
Adds buildRuntimeGenerationGraph() helper with auth route/controller/service/session-store nodes. Test validates pack.execution_slice contains status: 'complete' and ordered step sequence for runtime-generation explain packs.
Slice-v1 retrieval strategy tests
tests/unit/retrieve-slice-v1.test.ts
Configures slice-graph with includePersistenceStep option. Introduces ExecutionSliceExpectation type and compactFor helper. New tests assert complete execution slice with specific step labels and partial slice with boundary reason when persistence excluded.
Stdio fixture and execution-slice test
tests/unit/stdio-slice-surface.test.ts
Expands test fixture to include route/controller/service/session-store graph model with enriched source files. Adds test verifying context_pack response includes "execution_slice" field for retrieval_strategy: 'slice-v1'.
Documentation
CHANGELOG.md, docs/proof-workflows.md
Documents "Execution-slice context packs" feature and updates --baseline-mode pack_only documentation to include execution_slice audit field.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • mohanagy/graphify-ts#144: Introduces the opt-in slice-v1 retrieval strategy that gates execution-slice construction in this PR.
  • mohanagy/graphify-ts#151: Updates generation-intent/target-domain signals and slice-v1 logic that execution-slice building uses to determine applicability.
  • mohanagy/graphify-ts#208: Related to compare --baseline-mode pack_only flow that persists and inspects the new execution_slice audit field in report.json.

Poem

🐰 A slice through the graph, step by step so bright,
Routes dancing with controllers, in execution's light,
Services waltz to storage, each labeled just right,
Complete paths or partial, with boundary insight,
Runtime clarity blooms—a pack-slice delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed Title 'feat: add execution-slice output format' clearly and concisely summarizes the primary change—adding a new execution-slice field to context packs.
Description check ✅ Passed Description covers the main changes, references the linked issue (#164), includes a test plan with all required checks (typecheck, build, test), and follows the repository template structure.
Linked Issues check ✅ Passed All requirements from issue #164 are met: optional execution_slice field added to context packs, ordered runtime steps captured with source labels, raw slice metadata preserved, partial-path boundaries indicated, comprehensive tests added, and files specified in the issue were modified.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the execution-slice feature per issue #164—no unrelated refactoring, dependency updates, or tangential modifications are present.

✏️ 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 issue-164-execution-slice

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

@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.

🧹 Nitpick comments (1)
tests/unit/stdio-slice-surface.test.ts (1)

158-161: ⚡ Quick win

Assert parsed pack.execution_slice shape instead of raw substring match.

The current check can pass on incidental text matches. Parse contextPackText and assert pack.execution_slice directly.

Suggested test tightening
-    const contextPackText = ((contextPackResponse as { result?: { content?: Array<{ text: string }> } }).result?.content ?? [])[0]?.text ?? ''
-
-    expect(contextPackText).toContain('"execution_slice"')
+    const contextPackText = ((contextPackResponse as { result?: { content?: Array<{ text: string }> } }).result?.content ?? [])[0]?.text ?? ''
+    const payload = JSON.parse(contextPackText) as {
+      pack?: {
+        execution_slice?: {
+          status?: string
+          steps?: Array<{ label?: string }>
+        }
+      }
+    }
+
+    expect(payload.pack?.execution_slice).toEqual(expect.objectContaining({
+      status: expect.any(String),
+      steps: expect.any(Array),
+    }))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/stdio-slice-surface.test.ts` around lines 158 - 161, Replace the
brittle substring assertion with a structured assertion: parse the string in
contextPackText as JSON (e.g., JSON.parse(contextPackText)) into a variable like
parsedPack, then assert the presence and shape of parsedPack.execution_slice
(for example that parsedPack.execution_slice is an object and contains the
expected keys/types) instead of using expect(contextPackText).toContain; use
contextPackResponse and contextPackText to locate the value and validate
parsedPack.execution_slice directly.
🤖 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.

Nitpick comments:
In `@tests/unit/stdio-slice-surface.test.ts`:
- Around line 158-161: Replace the brittle substring assertion with a structured
assertion: parse the string in contextPackText as JSON (e.g.,
JSON.parse(contextPackText)) into a variable like parsedPack, then assert the
presence and shape of parsedPack.execution_slice (for example that
parsedPack.execution_slice is an object and contains the expected keys/types)
instead of using expect(contextPackText).toContain; use contextPackResponse and
contextPackText to locate the value and validate parsedPack.execution_slice
directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f57a8815-ea26-431b-8275-209b57832e94

📥 Commits

Reviewing files that changed from the base of the PR and between 574bd02 and a1c4acc.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • docs/proof-workflows.md
  • src/contracts/context-pack.ts
  • src/runtime/retrieve.ts
  • tests/unit/context-pack-command.test.ts
  • tests/unit/retrieve-slice-v1.test.ts
  • tests/unit/stdio-slice-surface.test.ts

@mohanagy
mohanagy merged commit dbdefdf into main May 19, 2026
7 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.

[P1][Retrieval] Add execution-slice output format

1 participant