Skip to content

Add workflow contract regression suites - #9

Merged
Deathcharge merged 1 commit into
masterfrom
agent/workflow-contract-suites
Aug 10, 2026
Merged

Add workflow contract regression suites#9
Deathcharge merged 1 commit into
masterfrom
agent/workflow-contract-suites

Conversation

@Deathcharge

Copy link
Copy Markdown
Owner

Summary

  • add bounded, versioned regression suites with exact-output and expected-error contracts
  • add the samsarix-spirals test CLI command with human and JSON reports
  • add a practical release-policy workflow and positive/negative fixtures
  • document the competitive position, flagship use cases, guardrails, and measurable adoption gates
  • smoke-test the new command from the built wheel in CI

Why

Samsarix Spirals needs a concrete use case that is meaningfully safer and more reviewable than an ad hoc script without competing with mature durable orchestrators. Checked-in workflow contracts provide that wedge for release gates, agent-generated structured data, and repository policy fixtures while preserving the no-network, no-code-execution runtime boundary.

Impact

Users can now keep named inputs beside expected outputs or expected execution failures and run every case locally or in CI. Reports intentionally omit fixture values to reduce accidental disclosure in logs. Existing workflow schema version 1 and existing commands remain compatible.

Verification

  • 73 tests pass with 96.09% branch coverage
  • Ruff format and lint pass
  • strict mypy and compileall pass
  • Bandit passes
  • wheel and sdist build and pass Twine checks
  • the wheel installs with no dependencies in a clean Python 3.11 environment
  • the installed CLI passes all release-policy cases and isolated API import

The local pip-audit client stalled without output; the existing hosted CI pip-audit . step is the authoritative dependency-audit gate for this PR.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Added workflow regression suites with expected outputs and execution-error checks.
    • Added a test command with human-readable or compact JSON reports and failure status.
    • Added a release-policy example covering approvals, metadata, and normalized publishing manifests.
    • Expanded the public API for suite loading and execution.
  • Documentation

    • Added workflow format, competitive positioning, roadmap, and regression-suite guidance.
    • Clarified validation guarantees, limitations, release status, and setup instructions.
  • Tests

    • Added CLI, validation, redaction, reporting, and release-policy regression coverage.

Walkthrough

The change adds validated workflow regression suites, suite execution and reporting APIs, a CLI test command, release-policy fixtures, CI coverage, and documentation for the suite format, product positioning, roadmap, and project status.

Changes

Workflow regression suites

Layer / File(s) Summary
Suite contracts and validation
src/samsarix_spirals/suite.py, src/samsarix_spirals/model.py, tests/test_suite.py
Adds validated suite and case models, JSON-value validation, bounds, duplicate detection, expected output or error contracts, unknown-key checks, and source-path errors.
Suite execution and CLI reporting
src/samsarix_spirals/suite.py, src/samsarix_spirals/cli.py, src/samsarix_spirals/__init__.py, tests/test_suite.py, tests/test_cli.py, tests/test_public_api.py
Runs every case, compares outputs or execution errors, serializes results, exposes suite APIs, and adds CLI reporting with compact JSON and failure exit status.
Release-policy contract coverage
examples/release-policy.json, examples/release-policy.suite.json, .github/workflows/ci.yml, docs/WORKFLOW_FORMAT.md
Adds a release-policy workflow and suite for approval, metadata, successful manifest output, and expected validation errors. CI runs the suite as a compact JSON smoke test.
Product and format documentation
README.md, ROADMAP.md, CHANGELOG.md, docs/COMPETITIVE_POSITIONING.md, pyproject.toml
Documents regression suites, product boundaries, positioning, roadmap milestones, adoption gates, project status, and updated package metadata.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant load_suite
  participant run_suite
  participant Workflow
  CLI->>load_suite: Load workflow and suite
  load_suite-->>CLI: Return WorkflowSuite
  CLI->>run_suite: Execute all cases
  run_suite->>Workflow: Run each case input
  Workflow-->>run_suite: Return output or execution error
  run_suite-->>CLI: Return SuiteResult
  CLI-->>CLI: Render report and exit status
Loading

Possibly related PRs

  • Deathcharge/samsarix-spirals#1: The change extends the earlier CLI, public API, model validation, CI workflow, and workflow documentation with regression-suite support.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% 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 The title clearly summarizes the main change: adding workflow contract regression suites.
Description check ✅ Passed The description directly explains the regression suites, CLI command, fixtures, documentation, CI smoke tests, and verification.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/workflow-contract-suites

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.

@Deathcharge
Deathcharge marked this pull request as ready for review August 10, 2026 18:56
@Deathcharge
Deathcharge merged commit c7d4401 into master Aug 10, 2026
4 of 5 checks passed

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

🤖 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 `@examples/release-policy.suite.json`:
- Around line 35-48: Add a regression case alongside “missing version is
rejected” in the release-policy suite using an empty or missing commit while
providing a valid version and approval; assert the error step_id is
require_commit and message_contains is “commit is required”.

In `@README.md`:
- Line 43: Update the release-policy example command in README.md to include the
Unix virtual-environment executable form `.venv/bin/samsarix-spirals`, or use an
activated-venv invocation, while preserving the documented Windows command and
existing platform-specific conventions.
- Around line 69-74: Update the README regression-suite description and
exit-status list to match the `test` command contract: status 1 covers
mismatched expected outputs or execution errors, including cases where workflow
execution succeeds, while status 2 covers suite validation errors as well as
workflow-structure errors. Replace the non-observable “contract has changed”
wording and ensure both sections consistently describe these statuses.

In `@src/samsarix_spirals/suite.py`:
- Around line 49-52: Update WorkflowSuite.from_dict to first validate and detach
the entire document through validate_json_value, enforcing the suite-wide JSON
and string limits before parsing fields. Continue using the detached validated
document for field extraction, and retain the existing suite-specific checks
such as _reject_unknown_keys and case validation.
- Around line 256-258: The output check in the case evaluation flow must use
JSON-type-aware recursive comparison instead of Python equality, distinguishing
booleans from numbers at every nesting level. Update the comparison around
CaseResult creation and add regression cases covering true versus 1 and false
versus 0.
🪄 Autofix

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: ASSERTIVE

Plan: Pro Plus

Run ID: 1d428d9b-ea42-45e6-b3f2-4c362888ae1a

📥 Commits

Reviewing files that changed from the base of the PR and between 6eceb0f and 7ab90c2.

📒 Files selected for processing (16)
  • .github/workflows/ci.yml
  • CHANGELOG.md
  • README.md
  • ROADMAP.md
  • docs/COMPETITIVE_POSITIONING.md
  • docs/WORKFLOW_FORMAT.md
  • examples/release-policy.json
  • examples/release-policy.suite.json
  • pyproject.toml
  • src/samsarix_spirals/__init__.py
  • src/samsarix_spirals/cli.py
  • src/samsarix_spirals/model.py
  • src/samsarix_spirals/suite.py
  • tests/test_cli.py
  • tests/test_public_api.py
  • tests/test_suite.py

Comment on lines +35 to +48
{
"name": "missing version is rejected",
"input": {
"version": "",
"commit": "abc123",
"approved": true
},
"expect": {
"error": {
"step_id": "require_version",
"message_contains": "version is required"
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a missing-commit regression case.

examples/release-policy.json lines 19-25 require commit. This suite does not assert that failure contract.

A change can remove or alter require_commit while this CI suite still passes. Add a case with an empty or missing commit value. Expect step_id require_commit and message_contains commit is required.

🤖 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 `@examples/release-policy.suite.json` around lines 35 - 48, Add a regression
case alongside “missing version is rejected” in the release-policy suite using
an empty or missing commit while providing a valid version and approval; assert
the error step_id is require_commit and message_contains is “commit is
required”.

Comment thread README.md
```console
.venv\Scripts\samsarix-spirals validate examples/hello.json
.venv\Scripts\samsarix-spirals run examples/hello.json --input examples/hello.input.json
.venv\Scripts\samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add the Unix form of the new suite command.

The new example uses the Windows-only .venv\Scripts\samsarix-spirals path, although this README also documents macOS and Linux installation. Add the .venv/bin/samsarix-spirals form or show an activated-venv command. Otherwise Unix users cannot run the new release-policy example by copying the documented command.

This follows the platform-specific paths already documented in README.md.

Proposed documentation fix
- .venv\Scripts\samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json
+# Windows
+.venv\Scripts\samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json
+# macOS/Linux
+.venv/bin/samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.venv\Scripts\samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json
# Windows
.venv\Scripts\samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json
# macOS/Linux
.venv/bin/samsarix-spirals test examples/release-policy.json examples/release-policy.suite.json
🤖 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 `@README.md` at line 43, Update the release-policy example command in README.md
to include the Unix virtual-environment executable form
`.venv/bin/samsarix-spirals`, or use an activated-venv invocation, while
preserving the documented Windows command and existing platform-specific
conventions.

Comment thread README.md
Comment on lines +69 to +74
## Regression suites

A suite stores named inputs beside exact expected outputs or expected execution errors.
The `test` command runs every case, reports all mismatches, and exits `1` if the contract
has changed. Reports describe the mismatch without echoing input or output values, which
reduces accidental disclosure of fixture data in CI logs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Update the failure-status documentation for test.

The test command returns 1 when a suite case does not match its expected output or error, even when workflow execution succeeds. The current sentence says 1 means the contract changed, which is not observable, and the later exit-status list describes 1 only as execution failure. Suite validation errors also return 2, but the list names only workflow structure. Align both sections with the CLI contract.

The test branch in src/samsarix_spirals/cli.py, Lines 97-143, and tests/test_cli.py, Lines 142-160, provide the behavior used here.

Proposed documentation fix
- The `test` command runs every case, reports all mismatches, and exits `1` if the contract
- has changed.
+ The `test` command runs every case, reports all mismatches, and exits `1` if a case does
+ not match its expected output or error.

- CLI exit `0`: validation or execution succeeded.
- CLI exit `1`: a valid workflow failed during execution, such as a false assertion.
- CLI exit `2`: arguments, files, JSON, or workflow structure were invalid.
+ CLI exit `0`: validation or execution succeeded, or all suite cases passed.
+ CLI exit `1`: execution failed, or a suite case did not match.
+ CLI exit `2`: arguments, files, JSON, workflow, or suite structure were invalid.
🤖 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 `@README.md` around lines 69 - 74, Update the README regression-suite
description and exit-status list to match the `test` command contract: status 1
covers mismatched expected outputs or execution errors, including cases where
workflow execution succeeds, while status 2 covers suite validation errors as
well as workflow-structure errors. Replace the non-observable “contract has
changed” wording and ensure both sections consistently describe these statuses.

Comment on lines +49 to +52
def from_dict(cls, document: Mapping[str, object]) -> WorkflowSuite:
"""Validate and detach a regression-suite mapping."""
issues: list[str] = []
_reject_unknown_keys(document, {"suite_version", "name", "cases"}, "$", issues)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply JSON limits to the complete suite document.

Line 49 validates input and expect.output values separately. It does not validate document as one JSON tree.

A suite can exceed the documented total-value limit across cases. expect.error.step_id and expect.error.message_contains also bypass the documented string-length limit.

Validate and detach the complete document with validate_json_value before field parsing. Retain the suite-specific field checks.

🤖 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 `@src/samsarix_spirals/suite.py` around lines 49 - 52, Update
WorkflowSuite.from_dict to first validate and detach the entire document through
validate_json_value, enforcing the suite-wide JSON and string limits before
parsing fields. Continue using the detached validated document for field
extraction, and retain the existing suite-specific checks such as
_reject_unknown_keys and case validation.

Comment on lines +256 to +258
if result.output != case.expected_output:
return CaseResult(case.name, False, "workflow output did not equal expected output")
return CaseResult(case.name, True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use JSON-type-aware output comparison.

Line 256 uses Python equality. Python considers True == 1 and False == 0.

An output of 1 can therefore pass an expectation of true. This violates the exact JSON equality contract. Use a recursive comparator that distinguishes JSON booleans from JSON numbers. Add regression cases for true versus 1 and false versus 0.

🤖 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 `@src/samsarix_spirals/suite.py` around lines 256 - 258, The output check in
the case evaluation flow must use JSON-type-aware recursive comparison instead
of Python equality, distinguishing booleans from numbers at every nesting level.
Update the comparison around CaseResult creation and add regression cases
covering true versus 1 and false versus 0.

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