Skip to content

Complete pinned policy deployment and audited enforcement - #10

Merged
Deathcharge merged 2 commits into
mainfrom
codex/release-candidate-contracts
Aug 31, 2026
Merged

Deathcharge merged 2 commits into
mainfrom
codex/release-candidate-contracts

Conversation

@Deathcharge

@Deathcharge Deathcharge commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

User-facing outcome

Complete a local policy promotion and enforcement workflow for Python agents and automation:
test a policy, build an unsigned revisioned artifact, verify trusted digest/application pins,
and enforce an operation with opt-in minimized audit delivery.

Safety and compatibility

  • Preserved deny-overrides-allow, default deny, existing decision digests and exit codes.
  • Bounded new artifacts and evidence; validates direct Request construction before freezing.
  • No automatic telemetry, network calls, signing keys, or policy-supplied code execution.
  • Documented additive public API/CLI/schema changes and rejection of unpaired Unicode surrogates and >4096-bit integers.
  • Artifact hashes are explicitly NOT signatures; deployment loading requires separate trusted pins.
  • Audit sink is caller-owned and synchronous; a failed sink prevents operation execution.
  • No license changes, PyPI publication, production deployment, other-repository edits, or rewritten history.

Verification

Runtime implementation is ca0f5ea; 28ce9db adds only cross-platform setup-documentation fixes.

  • python -m ruff format --check .: passed, 42 files.
  • python -m ruff check .: passed.
  • python -m mypy policy_engine: passed, 13 source files.
  • python -m pytest --cov=policy_engine --cov-report=term-missing -q: 150 passed, 93.15% branch-aware coverage.
  • python -m pip_audit --local --progress-spinner off --cache-dir .venv/audit-cache: no known vulnerabilities; unpublished local package skipped. Fixed pip's reported PYSEC-2026-3721 by requiring >=26.2,<27 in dev dependencies.
  • Exact final committed-tree python -m build --outdir dist/candidate-20260831-28ce9db, python -m twine check dist/candidate-20260831-28ce9db/*, and python scripts/verify_distribution.py --dist dist/candidate-20260831-28ce9db: all passed, including inventories and isolated installed check/test/batch/pack/verify-artifact/audit journeys.
  • python examples/pinned_gateway.py: actual temporary document read, denied callback never invoked, two minimized audit records.
  • Golden manifest digest and tamper/pin/application/no-overwrite/audit-failure regression tests included.
  • CI now repeats installed-distribution journeys on Linux and Windows, instead of import-only smoke checks.
  • All seven CI jobs passed at 28ce9db, including Linux Python 3.11–3.14 and Windows Python 3.11/3.14.
  • The non-publishing release workflow passed on 28ce9db and retained candidate archives for 14 days. No release tag or PyPI publication was created; the tag-only check was intentionally inapplicable to this manual candidate run.

Review disposition

CodeRabbit completed its review through ca0f5ea with no actionable comments and a low merge-risk
assessment. Its general follow-ups concern separating parsed content from trusted deployment state
and failure-atomic artifact publication. The current API deliberately requires separate trusted
pins in load_artifact; parse_artifact promises only internal consistency. Exclusive-create
packing can leave an incomplete file after interruption; loading fails closed and documentation
requires retry at a new path. Neither behavior silently authorizes different policy content.

The service also reported a docstring-coverage warning across touched functions (including tests
and helpers). Public APIs have docstrings and the end-to-end contract is documented; the repository's
own quality gates pass. No blanket test-docstring expansion or relaxed quality gate was added.
The final two documentation edits at 28ce9db were directly checked and tested; the requested
incremental service review was rate-limited, not an approval. Independent production review remains
an external gate.

Release disposition

Engineering release candidate. License parameter confirmation, PyPI ownership/trusted-publisher setup,
and independent/representative production-consumer review remain named external gates in
docs/PRODUCTIZATION.md and docs/RELEASING.md. Signing, hot reload, benchmarks and framework-specific
adapters remain demand-driven follow-ups, not claimed capabilities.

Rollback: revert this PR's merge commit; prior baseline is 8ddaa1f. No persistent runtime data or
deployment state is changed. Artifact rollback requires explicitly restoring a prior approved pin.

Local candidate artifact SHA-256 (28ce9db, Windows Python 3.11)

  • samsarix_policy_engine-0.1.0-py3-none-any.whl: 954029dac776b18e6e3e161af0032d5ab679e4f2e08570bae157fcb2e488fc15
  • samsarix_policy_engine-0.1.0.tar.gz: 52f81f8579155a31b7080c17749bea1fdcb3e474f0e4a54db6ad79b8cb1f5da2

These identify the locally verified candidate files, not a public release or a promise that
timestamp-bearing distribution archives are reproducible byte-for-byte across builds.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f73dc57a-7b9a-449f-91e5-8e3bbdf281be

📥 Commits

Reviewing files that changed from the base of the PR and between 8ddaa1f and ca0f5ea.

📒 Files selected for processing (31)
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • CHANGELOG.md
  • MANIFEST.in
  • README.md
  • ROADMAP.md
  • docs/BATCH_EVALUATION.md
  • docs/COMPETITIVE_LANDSCAPE.md
  • docs/POLICY_ARTIFACTS.md
  • docs/PRODUCTIZATION.md
  • docs/RELEASING.md
  • examples/file-policy-tests.json
  • examples/pinned_gateway.py
  • policy_engine/__init__.py
  • policy_engine/artifacts.py
  • policy_engine/batching.py
  • policy_engine/cli.py
  • policy_engine/enforcement.py
  • policy_engine/engine.py
  • policy_engine/errors.py
  • policy_engine/models.py
  • policy_engine/schemas/__init__.py
  • policy_engine/schemas/artifact.schema.json
  • policy_engine/validation.py
  • pyproject.toml
  • scripts/smoke_installed.py
  • scripts/verify_distribution.py
  • tests/test_artifacts.py
  • tests/test_cli.py
  • tests/test_enforcement.py
  • tests/test_example_consumer.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • New Features
    • Added deterministic, SHA-256-pinned policy artifacts with pack, verify-artifact, and artifact-based check commands.
    • Added guarded action execution with optional minimized audit events and fail-closed denial handling.
    • Added self-contained offline schema access and expanded distribution validation.
  • Bug Fixes
    • Strengthened request and batch validation, including limits for oversized integers, invalid Unicode, and malformed inputs.
  • Documentation
    • Added guidance for policy artifacts, enforcement, release verification, and batch evaluation.

Walkthrough

The change adds deterministic pinned policy artifacts, offline schema bundling, guarded action enforcement, stricter request validation, artifact-based CLI commands, a file gateway example, and automated wheel/sdist verification in CI and release workflows.

Changes

Policy release candidate

Layer / File(s) Summary
Validation and hashing hardening
policy_engine/validation.py, policy_engine/models.py, policy_engine/batching.py, policy_engine/engine.py, policy_engine/errors.py, tests/test_enforcement.py, tests/test_cli.py, docs/BATCH_EVALUATION.md, CHANGELOG.md
Request values now undergo centralized validation and freezing. JSON inputs reject unpaired surrogates and integers above 4,096 bits. Batch diagnostics remain bounded and structured. Policy hashing is incremental and deterministic.
Pinned artifact and offline schema contract
policy_engine/artifacts.py, policy_engine/schemas/*, policy_engine/__init__.py, tests/test_artifacts.py, docs/POLICY_ARTIFACTS.md
The package adds canonical policy artifacts with SHA-256 pins, application binding, optional suite evidence, parsing limits, and offline schema resolution.
Guarded action enforcement
policy_engine/enforcement.py, examples/*, tests/test_enforcement.py, tests/test_example_consumer.py, README.md
guarded_call evaluates decisions, sends optional minimized audit events, blocks on audit failure, and invokes allowed operations once. The pinned file gateway example demonstrates allow and deny paths.
Artifact CLI workflow
policy_engine/cli.py, tests/test_cli.py, README.md
The CLI adds pack and verify-artifact. check accepts either a raw policy or an artifact with required digest and application pins.
Distribution verification and release documentation
scripts/*, .github/workflows/*, MANIFEST.in, pyproject.toml, docs/RELEASING.md, docs/PRODUCTIZATION.md, ROADMAP.md, docs/COMPETITIVE_LANDSCAPE.md, README.md
Distribution verification checks archive contents and runs installed API and CLI journeys. CI and release workflows use the verifier, and release documentation describes the six bundled schemas and verification steps.

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

Merge Risk: 🔵 Low · up to ca0f5

The PR adds revisioned policy artifacts and pinned enforcement, but an unpinned parsing path could be mistaken for trusted deployment input, while an interrupted artifact write can leave a partial file that blocks retry. It is mergeable with explicit owner follow-up to separate verified trust state and make artifact publication failure-atomic.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant PolicyArtifact
  participant PolicyEngine
  participant guarded_call
  participant AuditSink
  participant Operation
  Caller->>PolicyArtifact: load artifact with trusted sha256 and application
  PolicyArtifact-->>Caller: validated policy
  Caller->>guarded_call: submit request and operation
  guarded_call->>PolicyEngine: evaluate request
  PolicyEngine-->>guarded_call: decision
  guarded_call->>AuditSink: deliver optional AuditEvent
  AuditSink-->>guarded_call: delivery result
  guarded_call->>Operation: invoke allowed operation once
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 17 files. (14 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main changes: pinned policy deployment and audited enforcement.
Description check ✅ Passed The description follows the required template, explains the user-facing outcome and safety controls, documents public changes, and reports required verification results plus additional artifact and bo…
Full details: Docstring Coverage

Explanation

Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 17 files. (14 skipped: 14 unsupported.)

Full details: Description check

Explanation

The description follows the required template, explains the user-facing outcome and safety controls, documents public changes, and reports required verification results plus additional artifact and boundary checks.

  • Fix all pre-merge checks with AI
✨ 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 codex/release-candidate-contracts

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 31, 2026 17:08
@Deathcharge

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Deathcharge

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Deathcharge
Deathcharge merged commit 638ee3f into main Aug 31, 2026
8 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.

1 participant