Skip to content

feat: export canonical authorization records v0.1 - #205

Merged
safal207 merged 13 commits into
mainfrom
feat/canonical-authorization-export-v0.1
Jun 29, 2026
Merged

safal207 merged 13 commits into
mainfrom
feat/canonical-authorization-export-v0.1

Conversation

@safal207

@safal207 safal207 commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Implements PythiaLabs #204 as the pre-execution authority side of the three-record trustworthy-transition profile from safal207/Liminal#108.

This PR exports deterministic PythiaLabs gate decisions as provider-neutral authorization_record artifacts while preserving PythiaLabs' existing product boundary.

Added

  • docs/interop/PYTHIALABS_AUTHORIZATION_EXPORT_V0_1.md
  • schemas/interop/pythialabs-authorization-record-v0.1.schema.json
  • conformance/pythialabs-authorization-export-v0.1.json
  • scripts/check_pythialabs_authorization_export.py

Showcase adapters

The same portable record shape is demonstrated across:

  • infrastructure actions;
  • banking-risk actions;
  • Web3 treasury actions.

Elixir module names and internal atoms are not normative interoperability fields.

Fixture coverage

  1. accepted reversible infrastructure action;
  2. blocked destructive action without approval;
  3. expired temporal authorization;
  4. target-state drift after decision;
  5. evidence snapshot updated before execution;
  6. accepted action with a matching observation handoff;
  7. accepted action with a contradicted external response-integrity record.

Exported bindings

The record keeps separate digests for:

  • action identity;
  • canonical arguments;
  • decision-time evidence snapshot;
  • environment;
  • target state;
  • source evidence artifact.

This makes temporal expiry, target-state drift, and evidence drift explicit instead of hiding all context behind one generic digest.

Boundary

  • PythiaLabs issues deterministic pre-execution authority.
  • A downstream runtime owns execution observations.
  • A separate verifier owns response-integrity verdicts.
  • Imported observation and integrity records remain independently attributed.
  • A downstream integrity failure does not rewrite the original PythiaLabs decision.

Validation

python3 scripts/check_pythialabs_authorization_export.py

The checker deterministically rebuilds canonical records and handoffs, verifies pinned SHA-256 references, enforces zero additional side effects for blocked/expired/drifted authority, and preserves the independent integrity verdict.

Relates to #204 and safal207/Liminal#108.

Summary by CodeRabbit

  • New Features
    • Added validation for deterministic PythiaLabs authorization export records using RFC8785 canonical digests and a published JSON schema.
    • Introduced interoperability documentation and a conformance fixture covering multiple allowance/blocking, expiration/drift, and join/integrity scenarios.
  • Bug Fixes
    • Strengthened checks for timestamp/digest consistency, join outcomes, and effective authority derivation to better detect stale, mismatched, or integrity-failing decisions.
  • Tests
    • Added adversarial negative tests to ensure tampering and mismatches are rejected as expected.
    • Added a CI workflow to run authorization export verification and the adversarial test suite on relevant changes.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b45351f-5544-4fe1-946d-6e783ca37754

📥 Commits

Reviewing files that changed from the base of the PR and between 08f1fcc and c96e882.

📒 Files selected for processing (1)
  • scripts/test_pythialabs_authorization_export.py

📝 Walkthrough

Walkthrough

Adds a PythiaLabs authorization export v0.1 profile with a JSON Schema, conformance fixture cases, a Python checker and adversarial tests, dependency pins, a GitHub Actions workflow, and interoperability documentation.

Changes

Authorization Export v0.1 Profile

Layer / File(s) Summary
Schema and record contract
schemas/interop/pythialabs-authorization-record-v0.1.schema.json, docs/interop/PYTHIALABS_AUTHORIZATION_EXPORT_V0_1.md
JSON Schema enforces required fields, digest patterns, and closed objects; docs define the portable record shape, canonicalization, digest bindings, authority derivation, drift/expiry semantics, handoff behavior, claim boundary, and invariant.
Conformance fixture cases
conformance/pythialabs-authorization-export-v0.1.json
Fixture metadata plus seven cases covering accepted, blocked, expired, drifted, stale-evidence, and handoff-integrity scenarios, along with invariant assertions.
Checker canonicalization, export derivation, and authority state
scripts/check_pythialabs_authorization_export.py
Implements RFC 8785 canonicalization, digest helpers, strict validation, schema loading, authorization export derivation, and authority-state mapping from timing, drift, approval, and verification fields.
Handoff derivation, end-to-end verify, tests, and workflow
scripts/check_pythialabs_authorization_export.py, scripts/test_pythialabs_authorization_export.py, scripts/requirements-pythialabs-authorization-export.txt, .github/workflows/authorization-export.yml
Builds observation and integrity records, verifies joins and execution timing, adds adversarial rejection checks and export-isolation checks, pins new dependencies, and wires CI to run the checker and tests on path-filtered events.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Poem

🐇 I hopped through bytes, both crisp and neat,
Canonical hashes kept the beat.
The gate said ALLOW, or BLOCK, or WAIT,
And every join found its true state.
Hoppity‑hash! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding canonical authorization record export support for v0.1.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/canonical-authorization-export-v0.1

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.

🔧 OpenGrep (1.23.0)
scripts/test_pythialabs_authorization_export.py

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.11][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist


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

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 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.

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

🤖 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 `@scripts/check_pythialabs_authorization_export.py`:
- Around line 172-179: The verify() logic is trusting
expected["authority_state"] instead of deriving the effective state from the
gate data, so stale or expired cases can pass incorrectly. Update verify() in
the authorization export checker to compute the authority state from the actual
authorization fields (including temporal/drift inputs like evaluation_clock,
expires_at, and revalidation_requirements) and use that derived state when
evaluating allowed/execution_allowed and side-effect expectations. Keep the
existing VALID_STATES guard, but make the state used in the allowed calculation
come from the gate data rather than expected authority_state.
- Around line 31-33: The canonical(value) helper currently uses json.dumps with
sort_keys/separators, which is only a Python-stable encoding and not RFC
8785/JCS-compliant. Replace it with a real JCS canonicalizer so the bytes used
for record_ref hashing match the fixture contract for all legal JSON values.
Keep the change localized to canonical() in the authorization export script and
ensure the hash input is produced from true RFC8785-JCS output.
- Around line 200-211: The verifier in check_pythialabs_authorization_export.py
currently accepts derived records without validating them against the published
schema. Update the main verification flow around verify(case) to validate each
derived record against
schemas/interop/pythialabs-authorization-record-v0.1.schema.json after
derivation, using the record’s actual structure rather than only ad hoc string
checks. Keep the existing case_id/duplicate handling, but fail fast with a clear
FixtureError when the schema check fails so malformed fields like
source_showcase, digests, or timestamps cannot pass.
- Around line 181-190: The join validation in verify() currently checks record
refs and authorization linkage but never asserts the expected join outcome from
handoff.expected_join. Update the verification around handoff(case,
authorization) to compare the observed join semantics against
expected["expected_join"], using the existing joined, observation, and
response_integrity_record checks to distinguish MATCH from
MATCH_WITH_INTEGRITY_FAILURE. Keep the change localized to verify() and the
fixture-driven assertions so the advertised downstream behavior is actually
enforced.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 632835f3-cf84-4dcd-9587-c7f42cd0457c

📥 Commits

Reviewing files that changed from the base of the PR and between d17b765 and dbe5668.

📒 Files selected for processing (4)
  • conformance/pythialabs-authorization-export-v0.1.json
  • docs/interop/PYTHIALABS_AUTHORIZATION_EXPORT_V0_1.md
  • schemas/interop/pythialabs-authorization-record-v0.1.schema.json
  • scripts/check_pythialabs_authorization_export.py

Comment thread scripts/check_pythialabs_authorization_export.py Outdated
Comment thread scripts/check_pythialabs_authorization_export.py Outdated
Comment thread scripts/check_pythialabs_authorization_export.py Outdated
Comment thread scripts/check_pythialabs_authorization_export.py Outdated
@safal207
safal207 marked this pull request as ready for review June 29, 2026 03:10

@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

🤖 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 @.github/workflows/authorization-export.yml:
- Around line 5-22: The authorization-export workflow is only watching and
installing from scripts/requirements-pythialabs-authorization-export.txt, so
changes to the alias file can bypass CI or never be exercised. Update the
workflow trigger paths in authorization-export.yml and the dependency install
step to include and consume
scripts/pythialabs_authorization_export_requirements.txt as well, ensuring both
the alias and the canonical requirements file are covered. Keep the changes
aligned with the existing authorization export job so either file update runs
the verifier and installs the changed requirements.

In `@scripts/check_pythialabs_authorization_export.py`:
- Around line 68-83: The strings() helper currently returns the original list
object, which lets later mutations leak into the exported record. Update
strings() in check_pythialabs_authorization_export.py to return a new list copy
after validation, and keep export() relying on that helper so
authorization["record"] and canonical_bytes_utf8 stay immutable once built.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 95261914-a63b-49f1-af03-7fe5b80e4b97

📥 Commits

Reviewing files that changed from the base of the PR and between dbe5668 and 759ae58.

📒 Files selected for processing (6)
  • .github/workflows/authorization-export.yml
  • docs/interop/PYTHIALABS_AUTHORIZATION_EXPORT_V0_1.md
  • scripts/check_pythialabs_authorization_export.py
  • scripts/pythialabs_authorization_export_requirements.txt
  • scripts/requirements-pythialabs-authorization-export.txt
  • scripts/test_pythialabs_authorization_export.py
✅ Files skipped from review due to trivial changes (2)
  • scripts/pythialabs_authorization_export_requirements.txt
  • docs/interop/PYTHIALABS_AUTHORIZATION_EXPORT_V0_1.md

Comment thread .github/workflows/authorization-export.yml
Comment thread scripts/check_pythialabs_authorization_export.py Outdated
@safal207
safal207 merged commit 9231876 into main Jun 29, 2026
4 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