Skip to content

feat(governance): Policy v2 Tier A — set-membership + cross-arg conditions (v0.284.0) - #498

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/tier-a-policy-ops
Jul 31, 2026
Merged

feat(governance): Policy v2 Tier A — set-membership + cross-arg conditions (v0.284.0)#498
vikasprogrammer merged 1 commit into
mainfrom
feat/tier-a-policy-ops

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

First concrete step of the Policy v2 wedge in docs/agent-os-plan.md §4.3. Small, pure, self-contained — no new plane.

What

Extends the JSON rule engine (src/governance/policy.ts) with two new when shapes, still stateless and still first-match:

  • in / nin — set membership against an array value → the invalid-enum guard (status ∉ {paid,shipped,refunded}never).
  • argRef — compare one arg to another arg instead of a constant → the wrong-recipient guard (payee ≠ buyerask owner).

Why the sweep work is the real change (not evalWhen)

applyProposal is tighten-only, proven by an exhaustive monotonicity sweep (firstLooseningsampleArgDomains). New ops the sampler doesn't enumerate would silently make that proof unsound. So:

  • sampleArgDomains now emits every enum member for in/nin, and seeds both sides of a cross-arg pair with one shared domain so the cartesian sweep hits arg == argRef and arg ≠ argRef.
  • firstLoosening's rare huge-product fallback gains explicit joint coverage of each argRef pair — independent per-arg variation can't observe arg == argRef.

Touch-points

All in policy.ts: Op, OPS, new When interface, evalWhen, describeMatch, OP_PHRASE, validatePolicyDocument, sampleArgDomains, argRefPairs, firstLoosening.

Tests

  • New scripts/tier-a-policy-test.cjs18/18: runtime semantics (in/nin + argRef eq/ne/gt, incl. fail-closed on missing args), validation of both new shapes, and that the monotonicity sweep reaches the new-op boundaries (a real new-op tightening is seen by describeProposal and accepted by applyProposal, never falsely flagged as loosening). Wired into npm run test:governance.
  • Existing conformance: 130/130 unchanged — backward-compatible, the bundled default policy uses no new ops.
  • npm run build clean.

🤖 Generated with Claude Code

@vikasprogrammer
vikasprogrammer force-pushed the feat/tier-a-policy-ops branch from 399aa5b to 0508487 Compare July 31, 2026 10:17
@vikasprogrammer vikasprogrammer changed the title feat(governance): Policy v2 Tier A — set-membership + cross-arg conditions (v0.282.0) feat(governance): Policy v2 Tier A — set-membership + cross-arg conditions (v0.283.0) Jul 31, 2026
…tions (v0.282.0)

Extends the pure JSON rule engine (src/governance/policy.ts) with two new
`when` shapes, still stateless and still first-match:

- `in` / `nin` — set membership against an array value (invalid-enum guard).
- `argRef` — compare one arg to another arg instead of a constant
  (wrong-recipient / cross-arg guard).

The applyProposal tighten-only monotonicity proof stays sound: sampleArgDomains
emits every enum member and seeds both sides of a cross-arg pair with one shared
domain, and firstLoosening's rare fallback path gains explicit joint coverage of
each argRef pair (independent variation can't observe arg == argRef).

Touch-points (all in policy.ts): Op, OPS, the new When interface, evalWhen,
describeMatch, OP_PHRASE, validatePolicyDocument, sampleArgDomains, argRefPairs,
firstLoosening.

Tests: new scripts/tier-a-policy-test.cjs (18 cases: runtime semantics,
validation, and that the monotonicity sweep reaches the new-op boundaries),
wired into `npm run test:governance`. The 130-case conformance suite is
unchanged — backward-compatible, since the bundled default policy uses no new ops.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vikasprogrammer
vikasprogrammer force-pushed the feat/tier-a-policy-ops branch from 0508487 to a8b85bc Compare July 31, 2026 10:18
@vikasprogrammer vikasprogrammer changed the title feat(governance): Policy v2 Tier A — set-membership + cross-arg conditions (v0.283.0) feat(governance): Policy v2 Tier A — set-membership + cross-arg conditions (v0.284.0) Jul 31, 2026
@vikasprogrammer
vikasprogrammer merged commit ec3bfa0 into main Jul 31, 2026
1 check passed
@vikasprogrammer
vikasprogrammer deleted the feat/tier-a-policy-ops branch July 31, 2026 10:18
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