Skip to content

[codex] Add Micro ECF policy pack#17

Open
rhein1 wants to merge 5 commits into
syrin-labs:mainfrom
rhein1:codex/agoragentic-micro-ecf-policy
Open

[codex] Add Micro ECF policy pack#17
rhein1 wants to merge 5 commits into
syrin-labs:mainfrom
rhein1:codex/agoragentic-micro-ecf-policy

Conversation

@rhein1

@rhein1 rhein1 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a Micro ECF policy-pack guide for Syrin agents using Agoragentic
  • add a preview-first Micro ECF example with intent contracts, execution boundaries, review gates, consequence axes, policy fingerprints, and Agoragentic execute payloads
  • document the workflow schema and add tests for allowed preview actions, denied live spend, secret access blocking, fingerprint stability, and execute payload evidence

Validation

  • python -m compileall -q agoragentic tests
  • python -m unittest tests.test_agoragentic_autonomous_lifecycle -v
  • python -m unittest discover -s tests -v
  • python -m ruff check agoragentic/examples/micro_ecf_policy_pack.py tests/test_agoragentic_autonomous_lifecycle.py
  • python agoragentic/examples/micro_ecf_policy_pack.py --action "execute live spend" --max-cost 0.10

Notes

This is independent of PR #15 and PR #16. It gives Syrin users a small, mountable governance contract rather than a full enterprise ECF dependency.

Summary by CodeRabbit

  • New Features

    • Added Micro ECF policy pack support: portable, preview-first governance for agent actions with fail-closed behavior.
  • Documentation

    • New guide and workflow schema describing policy pack structure, review gates, execution constraints, and mounting guidance.
    • README and examples index updated to reference Micro ECF guidance.
  • Examples

    • Added a CLI example that builds policy packs, runs pre-action classification (allow/review/deny), and emits preview execute payloads.
  • Tests

    • Added regression tests for classification outcomes, constraint enforcement, and deterministic fingerprinting.

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd8b396b-ea4a-4d52-a808-2fd0fddf9737

📥 Commits

Reviewing files that changed from the base of the PR and between 071ad22 and e74942f.

📒 Files selected for processing (2)
  • agoragentic/examples/micro_ecf_policy_pack.py
  • tests/test_agoragentic_autonomous_lifecycle.py
📝 Walkthrough

Walkthrough

Adds Micro ECF portable governance: new documentation and workflow schema, a CLI example that builds/fingerprints/classifies policy packs and emits execute payloads and mount instructions, README and examples updates, and tests validating classification, payload constraints, and deterministic fingerprinting.

Changes

Micro ECF policy pack (single coherent change DAG)

Layer / File(s) Summary
Data Shape
agoragentic/examples/micro_ecf_policy_pack.py
Introduces dataclasses IntentContract, ExecutionBoundary, MicroECFPolicyPack with JSON-serializable representations for the policy pack schema.
Core Logic
agoragentic/examples/micro_ecf_policy_pack.py
Adds fingerprint_policy (deterministic SHA‑256 fingerprint), helper _contains_any, required_evidence_for_terms, and classify_action implementing keyword-based allow/review/deny decisions and evidence mapping.
Execute Payload Construction
agoragentic/examples/micro_ecf_policy_pack.py
Adds build_execute_payload to embed policy + pre-action review into an execute payload and build_syrin_mount_instructions describing read-only mount and reconciliation steps.
CLI / Example Entrypoint
agoragentic/examples/micro_ecf_policy_pack.py
Adds main() CLI parsing (--goal, --task, --action, --max-cost, --run-live) that builds policy pack, classifies action, and outputs JSON artifacts and mount instructions.
Documentation & Schemas
agoragentic/MICRO_ECF_POLICY_PACK.md, agoragentic/WORKFLOW_SCHEMAS.md, agoragentic/README.md, agoragentic/examples/README.md
New MICRO_ECF_POLICY_PACK.md and WORKFLOW_SCHEMAS.md describing pack structure, preview-first fail-closed posture, schema outputs; README and examples README updated to reference the new example and docs and to replace prior example references.
Tests
tests/test_agoragentic_autonomous_lifecycle.py
Loads micro_ecf_policy_pack example and adds seven tests covering classification outcomes (allow/deny), preview-only behavior when live disabled, secret-like blocking, execute payload propagation of constraints and fingerprint, denied payload disabling live preference, and deterministic fingerprinting.

Sequence Diagram

sequenceDiagram
    participant CLI as User/CLI
    participant Builder as PolicyBuilder
    participant Classifier as ActionClassifier
    participant Payload as PayloadBuilder
    participant Output as JSONEmitter

    CLI->>Builder: provide goal, task, action, max_cost, run_live
    Builder->>Builder: create IntentContract & ExecutionBoundary
    Builder->>Builder: compute deterministic SHA-256 fingerprint
    Builder->>Output: emit policy pack JSON

    CLI->>Classifier: request action classification
    Classifier->>Classifier: keyword scan (sensitive / prohibited / secret)
    Classifier->>Classifier: decide allow / review / deny + evidence
    Classifier->>Output: emit action review result

    CLI->>Payload: request execute payload
    Payload->>Payload: embed policy pack & review decision
    Payload->>Payload: set preview_only or live flags per policy
    Payload->>Output: emit execute payload + Syrin mount instructions
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
I nibble rules and stamp them tight,
SHA‑256 keeps fingerprints right,
Preview hops before live leaps,
Secrets fenced where caution keeps,
I twitch my whiskers — policy bright.

🚥 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 '[codex] Add Micro ECF policy pack' directly and clearly summarizes the main change: introduction of a Micro ECF policy pack feature with supporting documentation, example code, and tests.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@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)
tests/test_agoragentic_autonomous_lifecycle.py (1)

226-276: ⚡ Quick win

Add regression tests for word-boundary matching and deny payload execution lockout.

Please add cases that verify:

  • "display ..." does not trigger "pay" detection, and
  • build_execute_payload(..., action=<denied>) sets execution intent to blocked (e.g., prefer_execute == False).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_agoragentic_autonomous_lifecycle.py` around lines 226 - 276, Add
two tests: one that calls micro_ecf.classify_action("display paywall", policy)
(or similar phrase containing "display") to assert the decision does NOT mark
"pay" or "live_spend" (verifying word-boundary matching), and another that
builds a policy where the action is denied then calls
micro_ecf.build_execute_payload(..., action=<denied>) and asserts the resulting
payload's execution intent flag (e.g., payload["constraints"]["prefer_execute"]
or equivalent field used by build_execute_payload) is False to ensure denied
actions block execution; use the existing helpers micro_ecf.classify_action and
micro_ecf.build_execute_payload and add tests alongside the other test_*
methods.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@agoragentic/examples/micro_ecf_policy_pack.py`:
- Around line 228-231: The _contains_any function uses raw substring checks
causing false positives (e.g., "display" matches "pay"); replace the substring
test with boundary-aware matching by checking each term with a word-boundary
regular expression (use re.search with r'\b' + re.escape(term) + r'\b' and
re.IGNORECASE) so matches only occur on whole words; keep the function name
_contains_any and return the same list[str] of matched terms.
- Around line 302-307: The current constraints set "prefer_execute": True
regardless of a deny decision, which can let callers attempt execution even when
decision == "deny"; update the prefer_execute value in the constraints dict (the
line constructing "prefer_execute") so it only becomes True when the decision is
"allow" (and optionally when live spend is allowed) — e.g., set prefer_execute
to something like (decision["decision"] == "allow" and
policy.boundary.live_spend_allowed) so deny/preview decisions do not produce
executable routing intent.

---

Nitpick comments:
In `@tests/test_agoragentic_autonomous_lifecycle.py`:
- Around line 226-276: Add two tests: one that calls
micro_ecf.classify_action("display paywall", policy) (or similar phrase
containing "display") to assert the decision does NOT mark "pay" or "live_spend"
(verifying word-boundary matching), and another that builds a policy where the
action is denied then calls micro_ecf.build_execute_payload(...,
action=<denied>) and asserts the resulting payload's execution intent flag
(e.g., payload["constraints"]["prefer_execute"] or equivalent field used by
build_execute_payload) is False to ensure denied actions block execution; use
the existing helpers micro_ecf.classify_action and
micro_ecf.build_execute_payload and add tests alongside the other test_*
methods.
🪄 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

Run ID: 82f6c796-f203-43fc-a1da-19dacf693b14

📥 Commits

Reviewing files that changed from the base of the PR and between ded42d2 and 3f466c2.

📒 Files selected for processing (6)
  • agoragentic/MICRO_ECF_POLICY_PACK.md
  • agoragentic/README.md
  • agoragentic/WORKFLOW_SCHEMAS.md
  • agoragentic/examples/README.md
  • agoragentic/examples/micro_ecf_policy_pack.py
  • tests/test_agoragentic_autonomous_lifecycle.py

Comment thread agoragentic/examples/micro_ecf_policy_pack.py Outdated
Comment thread agoragentic/examples/micro_ecf_policy_pack.py

@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.

🧹 Nitpick comments (2)
agoragentic/examples/micro_ecf_policy_pack.py (2)

107-118: 💤 Low value

as_dict shares mutable internal state.

MicroECFPolicyPack.as_dict() returns self.review_gates by reference, and the inner list[str] values are also shared. Callers that mutate the returned mapping (e.g., payload["input"]["micro_ecf"]["review_gates"]["live_spend"].append(...)) will silently mutate the frozen policy and break determinism of fingerprint_policy. Returning a deep copy keeps the dataclass effectively immutable as advertised.

♻️ Proposed change
-            "review_gates": self.review_gates,
+            "review_gates": {key: list(values) for key, values in self.review_gates.items()},
🤖 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 `@agoragentic/examples/micro_ecf_policy_pack.py` around lines 107 - 118,
MicroECFPolicyPack.as_dict currently returns references to mutable internals
(notably review_gates and nested lists, plus consequence_axes and
reconciliation_required), which allows callers to mutate the dataclass and
invalidate fingerprint_policy; update MicroECFPolicyPack.as_dict to return a
deep copy (or construct a new dict with copied lists/structures) so that
review_gates, consequence_axes, reconciliation_required and any nested list
values are new objects rather than references to self's internals, preserving
immutability and ensuring fingerprint_policy remains deterministic.

26-47: 💤 Low value

Consider broader synonym coverage for spend/transact verbs.

With word-boundary matching, "pay" no longer matches "payment", "paywall", etc. Concretely, an action like "approve payment of $100" or "buy provider credits" currently classifies as allow because none of execute live, spend, pay, settle match. If the intent of this term list is to fail-closed on common live-spend phrasings, consider also covering "payment", "purchase", "buy", "charge", "transact", or document that the matcher is intentionally narrow and callers must canonicalize action phrasing before review.

♻️ Example expansion
 SENSITIVE_ACTION_TERMS = (
     "execute live",
     "spend",
     "pay",
+    "payment",
+    "purchase",
+    "buy",
+    "charge",
     "settle",
     "deploy",
     "write memory",
     "store secret",
     "retrieve secret",
     "send email",
     "post outreach",
     "change budget",
 )

If the matchers are extended, the live-spend grouping at Line 254 and the evidence mapping at Line 279 should be updated to include the new terms.

🤖 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 `@agoragentic/examples/micro_ecf_policy_pack.py` around lines 26 - 47, Expand
the verb coverage in SENSITIVE_ACTION_TERMS (and optionally
PROHIBITED_ACTION_TERMS) to include common synonyms and noun forms like
"payment", "payments", "purchase", "purchases", "buy", "buying", "charge",
"charges", "transact", "transaction", "transactions" (or decide and document
that callers must canonicalize action phrasing); then update the live-spend
grouping and evidence mapping references that depend on these tuples (the
live-spend grouping and the evidence mapping) so they include the new terms or
accept canonicalized inputs accordingly.
🤖 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.

Nitpick comments:
In `@agoragentic/examples/micro_ecf_policy_pack.py`:
- Around line 107-118: MicroECFPolicyPack.as_dict currently returns references
to mutable internals (notably review_gates and nested lists, plus
consequence_axes and reconciliation_required), which allows callers to mutate
the dataclass and invalidate fingerprint_policy; update
MicroECFPolicyPack.as_dict to return a deep copy (or construct a new dict with
copied lists/structures) so that review_gates, consequence_axes,
reconciliation_required and any nested list values are new objects rather than
references to self's internals, preserving immutability and ensuring
fingerprint_policy remains deterministic.
- Around line 26-47: Expand the verb coverage in SENSITIVE_ACTION_TERMS (and
optionally PROHIBITED_ACTION_TERMS) to include common synonyms and noun forms
like "payment", "payments", "purchase", "purchases", "buy", "buying", "charge",
"charges", "transact", "transaction", "transactions" (or decide and document
that callers must canonicalize action phrasing); then update the live-spend
grouping and evidence mapping references that depend on these tuples (the
live-spend grouping and the evidence mapping) so they include the new terms or
accept canonicalized inputs accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ee1ef16-b1ed-43fe-8ec9-82522fd7c9bb

📥 Commits

Reviewing files that changed from the base of the PR and between 3f466c2 and bea33fd.

📒 Files selected for processing (4)
  • agoragentic/README.md
  • agoragentic/examples/README.md
  • agoragentic/examples/micro_ecf_policy_pack.py
  • tests/test_agoragentic_autonomous_lifecycle.py

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.

2 participants