Skip to content

feat: prepare exact private action tickets - #76

Merged
stone16 merged 1 commit into
mainfrom
codex/issue-67-action-prepare
Jul 24, 2026
Merged

feat: prepare exact private action tickets#76
stone16 merged 1 commit into
mainfrom
codex/issue-67-action-prepare

Conversation

@stone16

@stone16 stone16 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Closes #67

Outcome

Implements the closed ActionPlane.prepare(TrustedEffectIntent) boundary for one exact private delivery effect. The trusted TypeScript module now validates the service, Organization, destination, audience, purpose, payload digest, policy epoch, approval tier, and idempotency identity before returning an operation-specific one-shot ticket or a closed zero-effect refusal.

Security and persistence

  • Adds distinct placeholder, reply-finalization, and private-follow-up ticket types and audiences.
  • Persists digest-only delivery attempts, tickets, and restricted prepare audit rows behind Organization-owned FORCE RLS.
  • Adds the dedicated least-privilege action login and prepare definer; table privileges are limited to required SELECT/INSERT, with audit INSERT-only.
  • Keeps Sender, perform, group delivery, and all provider effects NOT_ACTIVE.
  • Records the boundary and rollback in ADR-0049 and activates only the private prepare carrier in the security catalog.

Verification

Fresh make db-reset && make check:

  • Ruff and strict mypy: pass
  • TypeScript ActionPlane typecheck/build: pass
  • ActionPlane runtime tests: 5 passed
  • Unit: 1208 passed
  • Catalog: 122 passed
  • Process smoke: 4 passed
  • Real PostgreSQL integration/security: 354 passed, 4 deselected
  • M0 security veto: 130 passed — M0 SECURITY PASS

The PostgreSQL evidence includes all three operations across the wrong-field matrix, payload/idempotency conflicts, unknown operation rejection, exact retry, stale/disabled/expired context, RLS isolation, restricted digest scans, least privilege, and zero Sender calls.

Final independent standards and specification reviews report no actionable findings.

Summary by CodeRabbit

  • New Features

    • Added a private ActionPlane preparation flow for placeholder creation, reply finalization, and private follow-ups.
    • Preparation now validates authorization, audience, source status, approvals, and idempotency before issuing action tickets.
    • Added digest-only ticket and audit handling with fail-closed outcomes for denied or conflicting requests.
    • Added isolated action database configuration and required environment settings.
  • Documentation

    • Documented the ActionPlane preparation boundary, supported operations, security guarantees, and inactive downstream delivery steps.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@stone16, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ccf4232-480e-4666-a699-199e34106901

📥 Commits

Reviewing files that changed from the base of the PR and between 5981143 and 11c02e1.

⛔ Files ignored due to path filters (1)
  • action_plane/typescript/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (51)
  • .github/workflows/ci.yml
  • .gitignore
  • CONTEXT.md
  • Makefile
  • action_plane/typescript/.node-version
  • action_plane/typescript/README.md
  • action_plane/typescript/THIRD_PARTY_NOTICES.md
  • action_plane/typescript/package.json
  • action_plane/typescript/scripts/clean.mjs
  • action_plane/typescript/src/index.ts
  • action_plane/typescript/src/internal.ts
  • action_plane/typescript/test/action-plane.test.mjs
  • action_plane/typescript/test/live-prepare.mjs
  • action_plane/typescript/tsconfig.build.json
  • action_plane/typescript/tsconfig.json
  • compose.yaml
  • docs/decisions/0049-prepare-one-exact-private-effect.md
  • docs/decisions/README.md
  • engine/persistence/__init__.py
  • engine/persistence/configuration.py
  • engine/persistence/role_guard.py
  • engine/persistence/schema_security_manifest.yaml
  • eval/catalogs/m0-security-evidence.yaml
  • eval/catalogs/security-catalog.schema.json
  • eval/catalogs/security-invariants.yaml
  • infra/postgres/init/10-security-roles.sh
  • migrations/versions/20260723_0022_action_prepare.py
  • scripts/database_harness.sh
  • scripts/provision_database_roles.py
  • scripts/security_gate/rls.py
  • scripts/security_gate/runner.py
  • scripts/validate_security_catalog.py
  • scripts/wait_for_database.py
  • tests/catalog/test_m0_security_gate.py
  • tests/catalog/test_validate_security_catalog.py
  • tests/integration/conftest.py
  • tests/integration/test_action_prepare.py
  • tests/integration/test_file_import_tracer.py
  • tests/integration/test_m0_security_gate_rls.py
  • tests/integration/test_membership_schema.py
  • tests/integration/test_migrations.py
  • tests/integration/test_postgres_harness.py
  • tests/integration/test_zz_file_content_noop.py
  • tests/unit/test_database_configuration.py
  • tests/unit/test_database_harness_behavior.py
  • tests/unit/test_database_harness_contract.py
  • tests/unit/test_learning_database_configuration.py
  • tests/unit/test_learning_database_role_provisioning.py
  • tests/unit/test_m0_delivery_carriers.py
  • tests/unit/test_m0_rls_inventory.py
  • tests/unit/test_schema_security_manifest.py
📝 Walkthrough

Walkthrough

Adds a private TypeScript ActionPlane.prepare boundary, digest-only PostgreSQL persistence with FORCE-RLS and isolated roles, exact idempotency and fail-closed validation, build integration, security-catalog activation, and unit/integration coverage.

Changes

ActionPlane prepare implementation

Layer / File(s) Summary
TypeScript contracts, ticket issuance, and tests
action_plane/typescript/..., Makefile, .github/workflows/ci.yml
Adds trusted effect intents, canonical payload and audience digests, operation-specific tickets, PostgreSQL preparation wiring, strict package configuration, and runtime tests.
PostgreSQL authority and role isolation
migrations/versions/..., engine/persistence/..., scripts/..., infra/postgres/..., compose.yaml
Adds action roles, database configuration, three protected action tables, RLS policies, and the context_action_prepare_private_effect function with validation, idempotency, audit, and retention behavior.
Security activation and decision records
eval/catalogs/..., scripts/validate_security_catalog.py, docs/decisions/..., CONTEXT.md
Registers the ActionPlane prepare activation, PostgreSQL evidence, security-manifest updates, and ADR documentation.
Integration and contract validation
tests/catalog/..., tests/integration/..., tests/unit/...
Adds live PostgreSQL prepare coverage and updates role, migration, RLS, catalog, harness, and build-contract expectations.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.82% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: preparing exact private action tickets.
Linked Issues check ✅ Passed The PR implements ActionPlane.prepare, closed refusal paths, idempotency, persistence, RLS, and tests matching issue #67.
Out of Scope Changes check ✅ Passed The remaining docs, CI, and packaging updates support the ActionPlane work and do not appear unrelated.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-67-action-prepare

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.

@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

🧹 Nitpick comments (1)
migrations/versions/20260723_0022_action_prepare.py (1)

376-418: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Optional: collapse the duplicate delivery_evidence lookup.

expected_identity_digest is computed by scanning delivery_evidence (376-413), then the same row is re-fetched into evidence_record (415-418) with an identical predicate. You can fetch evidence_record first and then derive the identity digest from evidence_record.authentication_binding_ref via a plain assignment (no FROM), removing one point lookup on the prepare hot path and keeping the existence check in one place.

🤖 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 `@migrations/versions/20260723_0022_action_prepare.py` around lines 376 - 418,
Collapse the duplicate delivery_evidence lookup in the surrounding
action-prepare logic: fetch the matching row once into evidence_record using the
existing organization_id and evidence_digest predicate, then compute
expected_identity_digest by assigning the same digest expression from
evidence_record.authentication_binding_ref without a FROM query. Preserve the
existing existence-check behavior and digest construction.
🤖 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/database_harness.sh`:
- Around line 303-305: Update migrate_legacy_action_identity to validate
CONTEXT_ENGINE_ACTION_ROLE, CONTEXT_ENGINE_ACTION_PASSWORD, and
CONTEXT_ENGINE_ACTION_URL together, requiring exactly one entry for each; when
any variable is missing or duplicated, atomically replace all three action
entries, matching the existing learning-role migration behavior.

In `@tests/integration/test_postgres_harness.py`:
- Around line 154-157: Update the finally cleanup path in the test harness to
call guarded_action_engine.dispose() alongside the other guarded engine
disposals, ensuring it runs on failures as well as the normal path. Remove or
avoid relying solely on the separate normal-path disposal while preserving
cleanup of all existing engines.

---

Nitpick comments:
In `@migrations/versions/20260723_0022_action_prepare.py`:
- Around line 376-418: Collapse the duplicate delivery_evidence lookup in the
surrounding action-prepare logic: fetch the matching row once into
evidence_record using the existing organization_id and evidence_digest
predicate, then compute expected_identity_digest by assigning the same digest
expression from evidence_record.authentication_binding_ref without a FROM query.
Preserve the existing existence-check behavior and digest construction.
🪄 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: 496c9d2b-e3eb-4ca2-8ec4-724626cfb1f0

📥 Commits

Reviewing files that changed from the base of the PR and between 33faee2 and 5981143.

⛔ Files ignored due to path filters (1)
  • action_plane/typescript/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (50)
  • .github/workflows/ci.yml
  • .gitignore
  • CONTEXT.md
  • Makefile
  • action_plane/typescript/.node-version
  • action_plane/typescript/README.md
  • action_plane/typescript/THIRD_PARTY_NOTICES.md
  • action_plane/typescript/package.json
  • action_plane/typescript/scripts/clean.mjs
  • action_plane/typescript/src/index.ts
  • action_plane/typescript/src/internal.ts
  • action_plane/typescript/test/action-plane.test.mjs
  • action_plane/typescript/test/live-prepare.mjs
  • action_plane/typescript/tsconfig.build.json
  • action_plane/typescript/tsconfig.json
  • compose.yaml
  • docs/decisions/0049-prepare-one-exact-private-effect.md
  • docs/decisions/README.md
  • engine/persistence/__init__.py
  • engine/persistence/configuration.py
  • engine/persistence/role_guard.py
  • engine/persistence/schema_security_manifest.yaml
  • eval/catalogs/m0-security-evidence.yaml
  • eval/catalogs/security-catalog.schema.json
  • eval/catalogs/security-invariants.yaml
  • infra/postgres/init/10-security-roles.sh
  • migrations/versions/20260723_0022_action_prepare.py
  • scripts/database_harness.sh
  • scripts/provision_database_roles.py
  • scripts/security_gate/rls.py
  • scripts/security_gate/runner.py
  • scripts/validate_security_catalog.py
  • scripts/wait_for_database.py
  • tests/catalog/test_m0_security_gate.py
  • tests/catalog/test_validate_security_catalog.py
  • tests/integration/conftest.py
  • tests/integration/test_action_prepare.py
  • tests/integration/test_file_import_tracer.py
  • tests/integration/test_m0_security_gate_rls.py
  • tests/integration/test_membership_schema.py
  • tests/integration/test_migrations.py
  • tests/integration/test_postgres_harness.py
  • tests/integration/test_zz_file_content_noop.py
  • tests/unit/test_database_configuration.py
  • tests/unit/test_database_harness_contract.py
  • tests/unit/test_learning_database_configuration.py
  • tests/unit/test_learning_database_role_provisioning.py
  • tests/unit/test_m0_delivery_carriers.py
  • tests/unit/test_m0_rls_inventory.py
  • tests/unit/test_schema_security_manifest.py

Comment thread scripts/database_harness.sh
Comment on lines +154 to +157
guarded_action_engine: Engine,
identity_configuration: DatabaseConfiguration,
egress_configuration: DatabaseConfiguration,
action_configuration: DatabaseConfiguration,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Dispose guarded_action_engine in the finally path.

The new engine is disposed only on the normal path at Line 195, while the finally block disposes the other guarded engines but not this one. An earlier failure can leave the action-role pool alive during role teardown and contaminate subsequent integration tests. Add guarded_action_engine.dispose() alongside the other finally disposals.

Also applies to: 187-195

🤖 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 `@tests/integration/test_postgres_harness.py` around lines 154 - 157, Update
the finally cleanup path in the test harness to call
guarded_action_engine.dispose() alongside the other guarded engine disposals,
ensuring it runs on failures as well as the normal path. Remove or avoid relying
solely on the separate normal-path disposal while preserving cleanup of all
existing engines.

@stone16
stone16 force-pushed the codex/issue-67-action-prepare branch from 5981143 to 11c02e1 Compare July 24, 2026 02:42
@stone16
stone16 merged commit 3dab415 into main Jul 24, 2026
2 checks passed
@stone16
stone16 deleted the codex/issue-67-action-prepare branch July 24, 2026 02:47
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.

action: prepare one exact private delivery effect

1 participant