Skip to content

refactor: renew run and acquisition boundary contracts - #254

Merged
Sinity merged 2 commits into
masterfrom
feature/refactor/run-acquisition-boundaries
Apr 20, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/refactor/run-acquisition-boundaries

Conversation

@Sinity

@Sinity Sinity commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • tighten run/acquisition telemetry and stage payloads around explicit JSON and TypedDict contracts
  • carry those contracts through source assembly sidecars and the affected pipeline/source tests
  • keep the slice stacked on the schema/lib payload-boundary renewal

Problem

The run and acquisition flow still relied on loosely shaped dictionaries and ad hoc payload coercion at key boundaries. Stage observations, run-state payload emission, sidecar enrichment, and a chunk of the downstream tests were all depending on inferred dict[str, object] shapes rather than stable typed contracts, which left the code path-dependent and brittle at both runtime and verification time.

Solution

  • add polylogue/pipeline/payload_types.py and thread its typed payload contracts through run execution, finalization, acquisition, parsing, ingest batching, source acquisition, and the run CLI
  • tighten run_state, metrics, and stage outcome models so emitted run payloads and observation summaries are explicit JSON-shaped values instead of generic dict/cast plumbing
  • replace loose source sidecar maps with typed Claude Code and Codex sidecar contracts, then align the pipeline/source tests with the new observation and run-json helpers

Verification

  • ruff check polylogue/pipeline/payload_types.py polylogue/pipeline/stage_models.py polylogue/pipeline/services/parsing_models.py polylogue/lib/metrics.py polylogue/pipeline/run_support.py polylogue/pipeline/run_finalization.py polylogue/pipeline/run_stages.py polylogue/pipeline/run_execution.py polylogue/pipeline/services/acquisition.py polylogue/pipeline/services/acquisition_streams.py polylogue/pipeline/services/parsing_workflow.py polylogue/pipeline/services/ingest_batch.py polylogue/sources/source_acquisition.py polylogue/cli/run_workflow.py polylogue/cli/commands/run.py
  • mypy polylogue/pipeline/payload_types.py polylogue/pipeline/stage_models.py polylogue/pipeline/services/parsing_models.py polylogue/lib/metrics.py polylogue/pipeline/run_support.py polylogue/pipeline/run_finalization.py polylogue/pipeline/run_stages.py polylogue/pipeline/run_execution.py polylogue/pipeline/services/acquisition.py polylogue/pipeline/services/acquisition_streams.py polylogue/pipeline/services/parsing_workflow.py polylogue/pipeline/services/ingest_batch.py polylogue/sources/source_acquisition.py polylogue/cli/run_workflow.py polylogue/cli/commands/run.py
  • ruff check polylogue/pipeline/services/__init__.py polylogue/pipeline/services/acquisition_records.py polylogue/sources/assembly.py polylogue/sources/assembly_claude_code.py polylogue/sources/assembly_codex.py polylogue/sources/cursor.py polylogue/sources/source_walk.py tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_assembly.py tests/unit/sources/test_source_laws.py
  • mypy polylogue/pipeline/services/__init__.py polylogue/pipeline/services/acquisition_records.py polylogue/sources/assembly.py polylogue/sources/assembly_claude_code.py polylogue/sources/assembly_codex.py polylogue/sources/cursor.py polylogue/sources/source_walk.py tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_assembly.py tests/unit/sources/test_source_laws.py
  • pytest -q tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_assembly.py tests/unit/sources/test_source_laws.py tests/unit/devtools/test_pipeline_probe.py
  • devtools verify

Ref #252

@coderabbitai

coderabbitai Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 24 seconds.

⌛ 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7e260213-dd47-40c5-a4e8-dc9a7c4a1abe

📥 Commits

Reviewing files that changed from the base of the PR and between c2817b2 and fe0fcc8.

📒 Files selected for processing (27)
  • polylogue/cli/commands/run.py
  • polylogue/cli/run_workflow.py
  • polylogue/lib/metrics.py
  • polylogue/pipeline/payload_types.py
  • polylogue/pipeline/run_execution.py
  • polylogue/pipeline/run_finalization.py
  • polylogue/pipeline/run_stages.py
  • polylogue/pipeline/run_support.py
  • polylogue/pipeline/services/__init__.py
  • polylogue/pipeline/services/acquisition.py
  • polylogue/pipeline/services/acquisition_records.py
  • polylogue/pipeline/services/acquisition_streams.py
  • polylogue/pipeline/services/ingest_batch.py
  • polylogue/pipeline/services/parsing_models.py
  • polylogue/pipeline/services/parsing_workflow.py
  • polylogue/pipeline/stage_models.py
  • polylogue/sources/assembly.py
  • polylogue/sources/assembly_claude_code.py
  • polylogue/sources/assembly_codex.py
  • polylogue/sources/cursor.py
  • polylogue/sources/source_acquisition.py
  • polylogue/sources/source_walk.py
  • polylogue/storage/run_state.py
  • tests/unit/pipeline/test_parsing_service.py
  • tests/unit/pipeline/test_run_sources.py
  • tests/unit/sources/test_assembly.py
  • tests/unit/sources/test_source_laws.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/run-acquisition-boundaries

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.

@Sinity
Sinity marked this pull request as ready for review April 20, 2026 07:11
Base automatically changed from feature/refactor/schema-lib-semantic-precision to master April 20, 2026 07:11
@Sinity
Sinity force-pushed the feature/refactor/run-acquisition-boundaries branch from c7085ef to fe0fcc8 Compare April 20, 2026 07:20
@Sinity
Sinity merged commit 335963e into master Apr 20, 2026
12 checks passed
@Sinity
Sinity deleted the feature/refactor/run-acquisition-boundaries branch April 20, 2026 07:20
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- tighten run/acquisition telemetry and stage payloads around explicit JSON and TypedDict contracts
- carry those contracts through source assembly sidecars and the affected pipeline/source tests
- keep the slice stacked on the schema/lib payload-boundary renewal

## Problem
The run and acquisition flow still relied on loosely shaped dictionaries and ad hoc payload coercion at key boundaries. Stage observations, run-state payload emission, sidecar enrichment, and a chunk of the downstream tests were all depending on inferred `dict[str, object]` shapes rather than stable typed contracts, which left the code path-dependent and brittle at both runtime and verification time.

## Solution
- add `polylogue/pipeline/payload_types.py` and thread its typed payload contracts through run execution, finalization, acquisition, parsing, ingest batching, source acquisition, and the run CLI
- tighten `run_state`, `metrics`, and stage outcome models so emitted run payloads and observation summaries are explicit JSON-shaped values instead of generic dict/cast plumbing
- replace loose source sidecar maps with typed Claude Code and Codex sidecar contracts, then align the pipeline/source tests with the new observation and run-json helpers

## Verification
- `ruff check polylogue/pipeline/payload_types.py polylogue/pipeline/stage_models.py polylogue/pipeline/services/parsing_models.py polylogue/lib/metrics.py polylogue/pipeline/run_support.py polylogue/pipeline/run_finalization.py polylogue/pipeline/run_stages.py polylogue/pipeline/run_execution.py polylogue/pipeline/services/acquisition.py polylogue/pipeline/services/acquisition_streams.py polylogue/pipeline/services/parsing_workflow.py polylogue/pipeline/services/ingest_batch.py polylogue/sources/source_acquisition.py polylogue/cli/run_workflow.py polylogue/cli/commands/run.py`
- `mypy polylogue/pipeline/payload_types.py polylogue/pipeline/stage_models.py polylogue/pipeline/services/parsing_models.py polylogue/lib/metrics.py polylogue/pipeline/run_support.py polylogue/pipeline/run_finalization.py polylogue/pipeline/run_stages.py polylogue/pipeline/run_execution.py polylogue/pipeline/services/acquisition.py polylogue/pipeline/services/acquisition_streams.py polylogue/pipeline/services/parsing_workflow.py polylogue/pipeline/services/ingest_batch.py polylogue/sources/source_acquisition.py polylogue/cli/run_workflow.py polylogue/cli/commands/run.py`
- `ruff check polylogue/pipeline/services/__init__.py polylogue/pipeline/services/acquisition_records.py polylogue/sources/assembly.py polylogue/sources/assembly_claude_code.py polylogue/sources/assembly_codex.py polylogue/sources/cursor.py polylogue/sources/source_walk.py tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_assembly.py tests/unit/sources/test_source_laws.py`
- `mypy polylogue/pipeline/services/__init__.py polylogue/pipeline/services/acquisition_records.py polylogue/sources/assembly.py polylogue/sources/assembly_claude_code.py polylogue/sources/assembly_codex.py polylogue/sources/cursor.py polylogue/sources/source_walk.py tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_assembly.py tests/unit/sources/test_source_laws.py`
- `pytest -q tests/unit/pipeline/test_parsing_service.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_assembly.py tests/unit/sources/test_source_laws.py tests/unit/devtools/test_pipeline_probe.py`
- `devtools verify`

Ref #252
@Sinity Sinity added area:pipeline Pipeline area:schema Schema 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 and acquisition flow still relied on loosely shaped
dictionaries and ad hoc payload coercion at key boundaries. Stage
observations, run-state payload emission, sidecar enrichment, and
a chunk of the downstream tests were all depending on inferred
`dict[str, object]` shapes rather than stable typed contracts,
leaving the code path-dependent and brittle at runtime and
verification time.

Adds `pipeline/payload_types.py` and threads typed payload contracts
through run execution, finalization, acquisition, parsing, ingest
batching, source acquisition, and the run CLI. Tightens `run_state`,
`metrics`, and stage outcome models so emitted run payloads and
observation summaries are explicit JSON-shaped values instead of
generic dict/cast plumbing. Replaces loose source sidecar maps with
typed Claude Code and Codex sidecar contracts, then aligns the
pipeline/source tests with the new observation and run-json helpers.

Stacked on the schema/lib payload-boundary renewal (#253).

Verification: ruff + mypy over pipeline/run/acquisition/source
modules; pytest over parsing, run-sources, assembly, source-laws,
and probe suites; devtools verify green.

Ref #252
Sinity added a commit that referenced this pull request Apr 22, 2026
The run and acquisition flow still relied on loosely shaped
dictionaries and ad hoc payload coercion at key boundaries. Stage
observations, run-state payload emission, sidecar enrichment, and
a chunk of the downstream tests were all depending on inferred
`dict[str, object]` shapes rather than stable typed contracts,
leaving the code path-dependent and brittle at runtime and
verification time.

Adds `pipeline/payload_types.py` and threads typed payload contracts
through run execution, finalization, acquisition, parsing, ingest
batching, source acquisition, and the run CLI. Tightens `run_state`,
`metrics`, and stage outcome models so emitted run payloads and
observation summaries are explicit JSON-shaped values instead of
generic dict/cast plumbing. Replaces loose source sidecar maps with
typed Claude Code and Codex sidecar contracts, then aligns the
pipeline/source tests with the new observation and run-json helpers.

Stacked on the schema/lib payload-boundary renewal (#253).

Verification: ruff + mypy over pipeline/run/acquisition/source
modules; pytest over parsing, run-sources, assembly, source-laws,
and probe suites; devtools verify green.

Ref #252
Sinity added a commit that referenced this pull request Apr 22, 2026
The run and acquisition flow still relied on loosely shaped
dictionaries and ad hoc payload coercion at key boundaries. Stage
observations, run-state payload emission, sidecar enrichment, and
a chunk of the downstream tests were all depending on inferred
`dict[str, object]` shapes rather than stable typed contracts,
leaving the code path-dependent and brittle at runtime and
verification time.

Adds `pipeline/payload_types.py` and threads typed payload contracts
through run execution, finalization, acquisition, parsing, ingest
batching, source acquisition, and the run CLI. Tightens `run_state`,
`metrics`, and stage outcome models so emitted run payloads and
observation summaries are explicit JSON-shaped values instead of
generic dict/cast plumbing. Replaces loose source sidecar maps with
typed Claude Code and Codex sidecar contracts, then aligns the
pipeline/source tests with the new observation and run-json helpers.

Stacked on the schema/lib payload-boundary renewal (#253).

Verification: ruff + mypy over pipeline/run/acquisition/source
modules; pytest over parsing, run-sources, assembly, source-laws,
and probe suites; devtools verify green.

Ref #252
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:52

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

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

Labels

area:pipeline Pipeline area:schema Schema tool:claude Claude type:refactor Code restructuring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants