Skip to content

refactor: renew transient run-state and storage view contracts - #236

Merged
Sinity merged 2 commits into
masterfrom
feature/refactor/transient-run-state-renewal
Apr 20, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/refactor/transient-run-state-renewal

Conversation

@Sinity

@Sinity Sinity commented Apr 20, 2026 •

Copy link
Copy Markdown
Owner

Ref #235
Ref #222

Summary

  • renew transient run-state and plan-state contracts around PlanResult, RunResult, cursor payloads, and run drift/count snapshots
  • propagate those typed contracts through planning, acquisition, render/watch helpers, and the affected test surfaces
  • keep persisted RunRecord JSON boundaries broad while making the transient pipeline/runtime layer explicit and typed

Problem

The run-state seam was still path-dependent and loosely modeled. Planning counts/details, cursor snapshots, run counts, drift, and render failures moved through broad dicts, which made the pipeline runtime ambiguous and forced repeated coercion at the CLI/test boundaries.

Solution

  • introduced explicit transient state models and payload aliases in polylogue/storage/state_views.py for plan counts/details, run counts, drift buckets, cursor state, and render failures
  • rewired planning and execution state in polylogue/pipeline/services/planning_runtime.py, polylogue/pipeline/run_state.py, and polylogue/pipeline/run_finalization.py to use those models directly
  • propagated the tighter cursor and render-failure contracts through source acquisition/decoding helpers plus watch.py, run_stages.py, and pipeline/services/rendering.py
  • updated the affected CLI, pipeline, source, and integration tests to construct typed run/plan fixtures explicitly instead of raw dict payloads

Verification

  • pytest -q tests/unit/cli/test_run.py tests/unit/cli/test_run_laws.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/pipeline/test_run_sources.py tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_observers.py tests/unit/pipeline/test_watch.py
  • mypy polylogue/pipeline/watch.py polylogue/pipeline/run_stages.py polylogue/pipeline/services/rendering.py tests/unit/cli/test_run.py tests/unit/cli/test_run_int.py tests/unit/cli/test_run_laws.py tests/unit/sources/test_drive_ops.py tests/unit/sources/test_decoders.py tests/unit/sources/test_acquisition_encoding.py tests/unit/sources/test_source_laws.py tests/integration/test_security.py tests/unit/pipeline/test_run_sources.py tests/integration/test_workflows.py
  • devtools verify

@coderabbitai

coderabbitai Bot commented Apr 20, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A large typing refactor introduces strongly-typed Pydantic models (RunCounts, PlanCounts, RunDrift, DriftBucket, CursorStatePayload, etc.) in state_views.py and updates 20+ dependent modules to accept both legacy Mapping[str, object] and new typed inputs. Tests are refactored to construct results using typed models instead of raw dicts.

Changes

Cohort / File(s) Summary
Storage Type Definitions
polylogue/storage/state_views.py
Added 16 new TypedDict payload types and Pydantic models (CursorStatePayload, PlanCounts, RunCounts, RunDrift, DriftBucket, RenderFailurePayload, etc.). Refactored PlanResult/RunResult fields from raw dict[str, int] to typed sparse/dense int-map models. Added field validators for coercion and normalization.
CLI Type Updates
polylogue/cli/formatting.py, polylogue/cli/run_display_workflow.py, polylogue/cli/run_workflow.py
Strengthened parameter types in formatting functions and workflow display functions to accept typed models (RunCounts, PlanCounts, RunDrift, CursorStatePayload) alongside legacy Mapping[str, object] inputs.
Pipeline State & Run Finalization
polylogue/pipeline/run_state.py, polylogue/pipeline/run_finalization.py
Refactored RunExecutionState to use RunCounts, RunDrift, DriftBucket, and RenderFailurePayload models; updated record methods to assign typed fields via attribute access rather than dict indexing. Added model construction and serialization via model_copy() and to_dict().
Pipeline Services
polylogue/pipeline/services/acquisition.py, polylogue/pipeline/services/acquisition_records.py, polylogue/pipeline/services/acquisition_streams.py, polylogue/pipeline/services/planning_runtime.py, polylogue/pipeline/services/rendering.py
Updated cursor tracking and result types to use CursorStatePayload and RenderFailurePayload; refactored plan-building logic to use PlanCounts/PlanDetails with attribute-based field assignment instead of dict indexing.
Run Stage & Watch Utilities
polylogue/pipeline/run_stages.py, polylogue/pipeline/watch.py
Retyped RenderStageOutcome.failures to list[RenderFailurePayload]; added _conversation_count() helper to safely extract conversation counts from both legacy and typed counts objects.
Source Acquisition & Cursor
polylogue/sources/cursor.py, polylogue/sources/decoder_zip.py, polylogue/sources/drive.py, polylogue/sources/source_acquisition.py, polylogue/sources/source_parsing.py, polylogue/sources/source_walk.py
Updated cursor-state parameter types across source handlers from `dict[str, Any]
Library Utilities
polylogue/lib/run_activity.py
Widened conversation_activity_counts() to accept RunCounts and RunDrift alongside legacy mapping types; updated internal helpers to handle both forms.
Test Updates
tests/unit/cli/test_run.py, tests/unit/cli/test_run_int.py, tests/unit/cli/test_run_laws.py, tests/unit/pipeline/test_run_sources.py, tests/unit/sources/test_acquisition_encoding.py, tests/unit/sources/test_decoders.py, tests/unit/sources/test_drive_ops.py, tests/unit/sources/test_source_laws.py, tests/integration/test_security.py, tests/integration/test_workflows.py
Updated test fixtures and result construction to use strongly-typed models (RunCounts, RunDrift, PlanCounts, CursorStatePayload, RenderFailurePayload) instead of raw dicts; added helper functions (_empty_cursor_state(), _observer_result()) for typed result initialization; updated assertions to use .int_value(...) accessors.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related issues

  • refactor: renew transient run-state and storage view contracts #235: This PR directly implements the same refactoring effort — introducing RunCounts/PlanCounts/CursorStatePayload models and updating polylogue/storage/state_views, run_state, run_finalization, planning_runtime, and all downstream CLI/pipeline usages to align with typed state contracts.

Possibly related PRs

Suggested labels

area:cli, area:pipeline, area:storage

Poem

🐰 Types take shape with models grand,
Cursors, counts, and drift so planned,
Dict chaos tamed to structure pure,
State flows typed, of that we're sure!
Onward hops the refactored way,
Strong types brighten coding day. 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% 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
Title check ✅ Passed The title 'refactor: renew transient run-state and storage view contracts' accurately and specifically summarizes the main change: introducing explicit typed contracts for run-state and storage views throughout the codebase.
Description check ✅ Passed The description includes all required template sections: Summary (what changed and why), Problem (what was needed), Solution (what was done with key modules), and Verification (commands run and validation). It is comprehensive and well-structured.

✏️ 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 feature/refactor/transient-run-state-renewal

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.

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

Caution

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

⚠️ Outside diff range comments (1)
polylogue/lib/run_activity.py (1)

7-26: ⚠️ Potential issue | 🟠 Major

Handle RunDrift buckets instead of dropping them.

RunDrift.get() returns a DriftBucket, not a Mapping, so Line 23 makes typed drift always read as zero. This breaks conversation_activity_counts(..., drift=RunDrift(...)).

🐛 Proposed fix
-from polylogue.storage.state_views import RunCounts, RunDrift
+from polylogue.storage.state_views import DriftBucket, RunCounts, RunDrift
@@
     if drift is None:
         return 0
     bucket_mapping = drift.get(bucket)
-    if not isinstance(bucket_mapping, Mapping):
+    if not isinstance(bucket_mapping, (Mapping, DriftBucket)):
         return 0
     value = bucket_mapping.get(key)
     return value if isinstance(value, int) else 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/lib/run_activity.py` around lines 7 - 26, The _drift_value helper
currently treats drift.get(bucket) as a generic Mapping and returns 0 when it's
a RunDrift/DriftBucket, so typed drift values are always zero; update
_drift_value to handle both Mapping and RunDrift types by checking if drift is a
RunDrift (or if bucket_mapping is a DriftBucket) and then retrieving the int
value from that bucket (e.g., call drift.get(bucket) and accept either a Mapping
or a DriftBucket, then use .get(key) and isinstance(..., int) to return the int
or 0). Ensure you reference the existing function _drift_value and the
RunDrift/DriftBucket return type when making the conditional branch so
RunDrift-backed buckets are not dropped.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@polylogue/pipeline/watch.py`:
- Around line 58-67: Change the _conversation_count signature to accept a
RunResult (not object) and remove the unreachable Mapping and getattr fallbacks:
inside _conversation_count(result: RunResult) call
result.counts.int_value("conversations") directly (using RunCounts.int_value)
and return the integer if isinstance(..., int) else 0; update any callers (e.g.,
WatchRunner._sync_fn) if necessary to keep types consistent. This eliminates
defensive type checks and relies on RunResult.counts being a RunCounts instance.

In `@tests/unit/sources/test_decoders.py`:
- Around line 298-310: The test uses cursor_state.get("failed_files", []) which
can produce an untyped default literal; change the access to use the shared
helper _failed_files(cursor_state) (the same helper used in
tests/integration/test_security.py) so the result is correctly typed as
list[CursorFailurePayload]; update the assertion variables in
test_cursor_state_records_failures to call _failed_files(cursor_state) instead
of cursor_state.get(...) and keep the rest of the assertions the same (the test
still seeds cursor_state via _seeded_cursor_state and exercises
_ZipEntryValidator).

---

Outside diff comments:
In `@polylogue/lib/run_activity.py`:
- Around line 7-26: The _drift_value helper currently treats drift.get(bucket)
as a generic Mapping and returns 0 when it's a RunDrift/DriftBucket, so typed
drift values are always zero; update _drift_value to handle both Mapping and
RunDrift types by checking if drift is a RunDrift (or if bucket_mapping is a
DriftBucket) and then retrieving the int value from that bucket (e.g., call
drift.get(bucket) and accept either a Mapping or a DriftBucket, then use
.get(key) and isinstance(..., int) to return the int or 0). Ensure you reference
the existing function _drift_value and the RunDrift/DriftBucket return type when
making the conditional branch so RunDrift-backed buckets are not dropped.
🪄 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: 5891ef69-8431-4333-99d3-895a61e4c632

📥 Commits

Reviewing files that changed from the base of the PR and between 014f01a and 6c328b9.

📒 Files selected for processing (30)
  • polylogue/cli/formatting.py
  • polylogue/cli/run_display_workflow.py
  • polylogue/cli/run_workflow.py
  • polylogue/lib/run_activity.py
  • polylogue/pipeline/run_finalization.py
  • polylogue/pipeline/run_stages.py
  • polylogue/pipeline/run_state.py
  • polylogue/pipeline/services/acquisition.py
  • polylogue/pipeline/services/acquisition_records.py
  • polylogue/pipeline/services/acquisition_streams.py
  • polylogue/pipeline/services/planning_runtime.py
  • polylogue/pipeline/services/rendering.py
  • polylogue/pipeline/watch.py
  • polylogue/sources/cursor.py
  • polylogue/sources/decoder_zip.py
  • polylogue/sources/drive.py
  • polylogue/sources/source_acquisition.py
  • polylogue/sources/source_parsing.py
  • polylogue/sources/source_walk.py
  • polylogue/storage/state_views.py
  • tests/integration/test_security.py
  • tests/integration/test_workflows.py
  • tests/unit/cli/test_run.py
  • tests/unit/cli/test_run_int.py
  • tests/unit/cli/test_run_laws.py
  • tests/unit/pipeline/test_run_sources.py
  • tests/unit/sources/test_acquisition_encoding.py
  • tests/unit/sources/test_decoders.py
  • tests/unit/sources/test_drive_ops.py
  • tests/unit/sources/test_source_laws.py

Comment on lines +58 to +67
def _conversation_count(result: object) -> int:
counts = getattr(result, "counts", None)
int_value = getattr(counts, "int_value", None)
if callable(int_value):
value = int_value("conversations")
return value if isinstance(value, int) else 0
if isinstance(counts, Mapping):
value = counts.get("conversations", 0)
return value if isinstance(value, int) else 0
return 0

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 | 🔵 Trivial

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP -C3 'counts\s*=' --type=py -g '!tests/**' | rg -n 'RunResult|counts='
rg -nP -C2 '\bRunResult\s*\(' --type=py

Repository: Sinity/polylogue

Length of output: 10982


🏁 Script executed:

# Get the full RunResult and RunCounts definitions
rg -A 10 'class RunResult' polylogue/storage/state_views.py
rg -A 15 'class RunCounts' --type=py

Repository: Sinity/polylogue

Length of output: 2541


🏁 Script executed:

# Check the watch.py file to see the full context of _conversation_count
cat -n polylogue/pipeline/watch.py | head -100

Repository: Sinity/polylogue

Length of output: 2566


🏁 Script executed:

# Find all usages of _conversation_count
rg '_conversation_count' --type=py -B 2 -A 2

Repository: Sinity/polylogue

Length of output: 29489


🏁 Script executed:

# Get the full _SparseIntMap definition
rg -B 5 -A 20 'class _SparseIntMap' polylogue/storage/state_views.py

Repository: Sinity/polylogue

Length of output: 888


🏁 Script executed:

# Check if there are any other places where counts is assigned a plain dict/Mapping to RunResult
rg 'RunResult\s*\(' --type=py -A 3 | grep -A 3 'counts\s*='

Repository: Sinity/polylogue

Length of output: 2804


Type _conversation_count parameter to RunResult instead of object to eliminate unnecessary defensive code.

WatchRunner._sync_fn() returns RunResult, which always has counts: RunCounts. Since RunCounts provides a callable int_value(field_name: str) method, narrowing the parameter type from object to RunResult allows direct access without getattr fallbacks. The Mapping branch is unreachable—every instantiation of RunResult in the codebase uses RunCounts, never a plain dict.

♻️ Proposed simplification
-from collections.abc import Callable, Mapping
+from collections.abc import Callable
@@
-def _conversation_count(result: object) -> int:
-    counts = getattr(result, "counts", None)
-    int_value = getattr(counts, "int_value", None)
-    if callable(int_value):
-        value = int_value("conversations")
-        return value if isinstance(value, int) else 0
-    if isinstance(counts, Mapping):
-        value = counts.get("conversations", 0)
-        return value if isinstance(value, int) else 0
-    return 0
+def _conversation_count(result: RunResult) -> int:
+    return result.counts.int_value("conversations")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/pipeline/watch.py` around lines 58 - 67, Change the
_conversation_count signature to accept a RunResult (not object) and remove the
unreachable Mapping and getattr fallbacks: inside _conversation_count(result:
RunResult) call result.counts.int_value("conversations") directly (using
RunCounts.int_value) and return the integer if isinstance(..., int) else 0;
update any callers (e.g., WatchRunner._sync_fn) if necessary to keep types
consistent. This eliminates defensive type checks and relies on RunResult.counts
being a RunCounts instance.

Comment on lines 298 to +310
def test_cursor_state_records_failures(self) -> None:
"""Rejected entries record failures in cursor_state."""
cursor_state: dict[str, Any] = {"failed_files": [], "failed_count": 0}
cursor_state = _seeded_cursor_state()
validator = _ZipEntryValidator(
"chatgpt",
cursor_state=cursor_state,
zip_path=Path("archive.zip"),
)
bomb_entry = self._make_zip_info("bomb.json", file_size=500000, compress_size=1)
list(validator.filter_entries([bomb_entry]))
assert int(cursor_state["failed_count"]) >= 1
assert len(cast(list[object], cursor_state["failed_files"])) >= 1
failed_files: list[CursorFailurePayload] = cursor_state.get("failed_files", [])
assert cursor_state["failed_count"] >= 1
assert len(failed_files) >= 1

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 | 🔵 Trivial

Minor: explicit typing of .get default.

cursor_state.get("failed_files", []) returns list[CursorFailurePayload] | list[Never] under strict TypedDict semantics. The inline annotation is fine at runtime, but mypy may complain about the default literal. Consider routing through the same helper used in tests/integration/test_security.py (_failed_files) to keep the access pattern uniform across tests.

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

In `@tests/unit/sources/test_decoders.py` around lines 298 - 310, The test uses
cursor_state.get("failed_files", []) which can produce an untyped default
literal; change the access to use the shared helper _failed_files(cursor_state)
(the same helper used in tests/integration/test_security.py) so the result is
correctly typed as list[CursorFailurePayload]; update the assertion variables in
test_cursor_state_records_failures to call _failed_files(cursor_state) instead
of cursor_state.get(...) and keep the rest of the assertions the same (the test
still seeds cursor_state via _seeded_cursor_state and exercises
_ZipEntryValidator).

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c328b96b6

ℹ️ 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 thread polylogue/lib/run_activity.py Resolved
@Sinity
Sinity merged commit 5ed4243 into master Apr 20, 2026
13 of 14 checks passed
@Sinity
Sinity deleted the feature/refactor/transient-run-state-renewal branch April 20, 2026 01:58
Sinity added a commit that referenced this pull request Apr 22, 2026
Ref #235
Ref #222

## Summary
- renew transient run-state and plan-state contracts around `PlanResult`, `RunResult`, cursor payloads, and run drift/count snapshots
- propagate those typed contracts through planning, acquisition, render/watch helpers, and the affected test surfaces
- keep persisted `RunRecord` JSON boundaries broad while making the transient pipeline/runtime layer explicit and typed

## Problem
The run-state seam was still path-dependent and loosely modeled. Planning counts/details, cursor snapshots, run counts, drift, and render failures moved through broad dicts, which made the pipeline runtime ambiguous and forced repeated coercion at the CLI/test boundaries.

## Solution
- introduced explicit transient state models and payload aliases in `polylogue/storage/state_views.py` for plan counts/details, run counts, drift buckets, cursor state, and render failures
- rewired planning and execution state in `polylogue/pipeline/services/planning_runtime.py`, `polylogue/pipeline/run_state.py`, and `polylogue/pipeline/run_finalization.py` to use those models directly
- propagated the tighter cursor and render-failure contracts through source acquisition/decoding helpers plus `watch.py`, `run_stages.py`, and `pipeline/services/rendering.py`
- updated the affected CLI, pipeline, source, and integration tests to construct typed run/plan fixtures explicitly instead of raw dict payloads

## Verification
- `pytest -q tests/unit/cli/test_run.py tests/unit/cli/test_run_laws.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/pipeline/test_run_sources.py tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_observers.py tests/unit/pipeline/test_watch.py`
- `mypy polylogue/pipeline/watch.py polylogue/pipeline/run_stages.py polylogue/pipeline/services/rendering.py tests/unit/cli/test_run.py tests/unit/cli/test_run_int.py tests/unit/cli/test_run_laws.py tests/unit/sources/test_drive_ops.py tests/unit/sources/test_decoders.py tests/unit/sources/test_acquisition_encoding.py tests/unit/sources/test_source_laws.py tests/integration/test_security.py tests/unit/pipeline/test_run_sources.py tests/integration/test_workflows.py`
- `devtools verify`
@Sinity Sinity added area:pipeline Pipeline area:storage Storage tool:claude Claude type:refactor Code restructuring labels Apr 22, 2026
Sinity added a commit that referenced this pull request Apr 22, 2026
The run-state seam was still path-dependent and loosely modeled.
Planning counts/details, cursor snapshots, run counts, drift, and
render failures moved through broad dicts, making the pipeline
runtime ambiguous and forcing repeated coercion at the CLI/test
boundaries. Persisted `RunRecord` JSON boundaries stay broad by
design; the transient pipeline/runtime layer is what tightens here.

Introduces explicit transient state models and payload aliases in
`storage/state_views.py` for plan counts/details, run counts, drift
buckets, cursor state, and render failures. Rewires planning and
execution state in `pipeline/services/planning_runtime.py`,
`pipeline/run_state.py`, and `pipeline/run_finalization.py` to use
those models directly. Propagates the tighter cursor and render-
failure contracts through source acquisition/decoding helpers plus
`watch.py`, `run_stages.py`, and `pipeline/services/rendering.py`.
Affected CLI, pipeline, source, and integration tests construct
typed run/plan fixtures explicitly instead of raw dict payloads.

Verification: focused pytest and mypy over the touched run/pipeline/
source tests; devtools verify green.

Ref #235
Ref #222
Sinity added a commit that referenced this pull request Apr 22, 2026
The run-state seam was still path-dependent and loosely modeled.
Planning counts/details, cursor snapshots, run counts, drift, and
render failures moved through broad dicts, making the pipeline
runtime ambiguous and forcing repeated coercion at the CLI/test
boundaries. Persisted `RunRecord` JSON boundaries stay broad by
design; the transient pipeline/runtime layer is what tightens here.

Introduces explicit transient state models and payload aliases in
`storage/state_views.py` for plan counts/details, run counts, drift
buckets, cursor state, and render failures. Rewires planning and
execution state in `pipeline/services/planning_runtime.py`,
`pipeline/run_state.py`, and `pipeline/run_finalization.py` to use
those models directly. Propagates the tighter cursor and render-
failure contracts through source acquisition/decoding helpers plus
`watch.py`, `run_stages.py`, and `pipeline/services/rendering.py`.
Affected CLI, pipeline, source, and integration tests construct
typed run/plan fixtures explicitly instead of raw dict payloads.

Verification: focused pytest and mypy over the touched run/pipeline/
source tests; devtools verify green.

Ref #235
Ref #222
Sinity added a commit that referenced this pull request Apr 22, 2026
The run-state seam was still path-dependent and loosely modeled.
Planning counts/details, cursor snapshots, run counts, drift, and
render failures moved through broad dicts, making the pipeline
runtime ambiguous and forcing repeated coercion at the CLI/test
boundaries. Persisted `RunRecord` JSON boundaries stay broad by
design; the transient pipeline/runtime layer is what tightens here.

Introduces explicit transient state models and payload aliases in
`storage/state_views.py` for plan counts/details, run counts, drift
buckets, cursor state, and render failures. Rewires planning and
execution state in `pipeline/services/planning_runtime.py`,
`pipeline/run_state.py`, and `pipeline/run_finalization.py` to use
those models directly. Propagates the tighter cursor and render-
failure contracts through source acquisition/decoding helpers plus
`watch.py`, `run_stages.py`, and `pipeline/services/rendering.py`.
Affected CLI, pipeline, source, and integration tests construct
typed run/plan fixtures explicitly instead of raw dict payloads.

Verification: focused pytest and mypy over the touched run/pipeline/
source tests; devtools verify green.

Ref #235
Ref #222
@Sinity

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 1 finding(s) confirmed still present → tracked in #550.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:pipeline Pipeline area:storage Storage tool:claude Claude type:refactor Code restructuring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants