Skip to content

Mine and match reusable authority by kernel-resolved scope #128

Description

@George-RD

What to build

Deepen action mediation per the architecture review: mine and match reusable authority by kernel-resolved scope. This is T17-T18 work building on the Effect Truth settlement (T3).

Acceptance criteria

  1. Implement scoped authority matching logic. 2. Add tests covering scope overlap, drift, and resolution. 3. Document the matching algorithm and failure modes.

Blocked by

T3 (Effect Truth settlement, epic #198); Bell fit review

Fence: Do not start before the Bell fit review lands on build-on. Route through delivery vehicle in DIRECTION.md.

Original report

Why

The current standing-rule and reflection-miner path identifies reusable authority too coarsely:

  • live standing-rule lookup matches only ActionId;
  • the scheduled miner groups approvals by (artifact_id, action_id);
  • repeated approvals across different mailboxes, recipients, conversations, connector instances, or counterparties can therefore look like one pattern;
  • the proposal carries one source event rather than a complete evidence-set binding;
  • generic action mediation currently constructs requests with no trusted target reference or target digest and derives string parameters from the shell payload;
  • scope mismatch is therefore impossible to evaluate before budget reservation or dark-window scheduling;
  • the store currently keeps effectively one active rule per action and activation revokes other active rules for that action, which cannot represent separate reviewed responsibilities for different accounts/relationships.

OpenSpine must learn the smallest safe repeatable context class, not merely that the same verb was approved twice.

Scope

1. Build the resolved context at the kernel boundary

For every delegatable action, the kernel must construct the ResolvedActionContext defined in #126 before reusable-authority consultation. The shell may provide an intent/reference token, but it cannot select trusted connector, account, target, counterparty, or bound parameter values.

For the Gmail draft proof, context must include at least:

  • canonical action email.create_draft;
  • stable Gmail connector-instance identity;
  • owner-mailbox account identity/role;
  • selected conversation/thread target;
  • kernel-resolved recipient/counterparty identity;
  • workflow/task-shape identity;
  • immutable target and payload digests.

The exact reviewed scope may intentionally be broader than one thread (for example one mailbox + one bound relationship), but that widening must be explicit in the proposal and owner decision. It cannot be inferred from two unrelated approvals.

2. Evidence-class mining

Replace (artifact_id, action_id) counting with deterministic context-class grouping. Repeated approval evidence must prove:

  • the same executable action descriptor/version;
  • the same required scope dimensions;
  • compatible workflow/task shape;
  • at least the configured number of distinct owner approvals;
  • an evidence-set digest and bounded list of encrypted source references.

If approvals differ on a required dimension, the miner must either produce separate narrow candidates or no authority proposal. It must never silently compute a wider least-common scope.

The candidate artifact identity must be scope-safe. Reusing the workflow/artifact ID for every candidate cannot represent multiple relationships/accounts and causes duplicate/version collisions. Define a stable logical responsibility/rule identity derived from reviewed semantics while keeping owner-readable names separate from digests.

3. Reviewed scope in standing-rule artifacts

Extend the standing-rule schema/store with the reviewed scope or a digest-bound reference to it. The serialized artifact must remain versioned, diffable, exportable, and re-confirmable.

The runtime row must index the dimensions needed for deterministic lookup without making the standing rule a second live authority object.

4. Multiple scoped rules and conflict resolution

Replace the current one-active-rule-per-action assumption.

  • Multiple active rules for the same canonical action MUST be allowed when their reviewed scopes are disjoint or deterministically distinguishable.
  • Activating a rule for relationship/account A MUST NOT revoke the independent rule for relationship/account B.
  • Version replacement applies to the same logical scoped rule, not every rule sharing the action ID.
  • If more than one active rule matches a live context, the kernel must use a settled deterministic rule: preferably exact/single match; any specificity ordering must be formally defined and proven non-widening.
  • Ambiguous overlapping matches MUST fail closed to ordinary approval/needs_review rather than picking by insertion order/version alone.
  • Budgets from multiple rules MUST NOT be summed, pooled, or opportunistically selected to extend authority.
  • Scope amendment/widening creates a new reviewed version and conflict evaluation; it never silently merges active rules.

5. Match before reserve

On every live request:

  1. run the normal grant/policy gate;
  2. resolve trusted action context;
  3. find exactly one compatible rule whose action descriptor and reviewed scope match;
  4. only then reserve quota/rate or schedule a dark-window decision;
  5. execute through Unify approved and delegated effect execution; fail closed on missing executors #127's shared effect executor.

A missing, changed, unresolved, stale, incompatible, or ambiguous scope must leave ApprovalRequired unchanged. It must consume no standing-rule budget and create no dark-window pending row.

6. Drift and invalidation

Move a rule to needs_review when any bound semantic dependency changes, including:

  • action descriptor or executor version changes incompatibly;
  • connector instance/account is removed or reconfigured;
  • target/counterparty identity becomes unresolved, erased, or re-bound;
  • workflow/task-shape authority changes;
  • active policy newly denies the action;
  • another activation creates an ambiguous overlap;
  • repeated saturation or existing expiry triggers fire.

The normal gate must still deny immediately even before the lifecycle row is reconciled.

7. Dark-window restraint

Until #126 settles AD-012 for communication effects, scope mismatch, ambiguous overlap, and unresolved context must never schedule an Allow default. The first Gmail proof should ship with no dark-window Allow unless separately justified and tested.

TDD matrix

  • Same action, same connector instance, same mailbox, same bound relationship: candidate may be proposed and matched.
  • Same action, different mailbox: separate/no candidate; live reuse falls back before reserve.
  • Gmail vs a second email connector implementing email.create_draft: no cross-connector reuse.
  • Same mailbox, different recipient identity: separate scoped rules may coexist; neither revokes or consumes the other's budget.
  • Two disjoint rules for the same action match their own contexts independently.
  • Overlapping rules that both match one context fail closed and create no usage/timer row.
  • Version bump replaces only the same logical scoped rule.
  • Changed thread within an owner-approved relationship scope: matches only when that is the declared scope.
  • Missing/expired/foreign selection token: no context and no consultation.
  • Counterparty erasure/rebinding: dependent rule becomes unusable and enters review without affecting other scoped rules.
  • Policy change between proposal and activation: activation fails or moves to review.
  • Policy change after activation: gate denies immediately and reconciliation marks review.
  • Scope mismatch with exhausted budget/dark-window configuration: no usage and no timer row.
  • Concurrent final budget unit remains atomic after scope filtering.

Invariants

  • No fuzzy model judgment in scope comparison or rule selection.
  • Identity remains separate from authority; a bound identity is only one reviewed scope dimension.
  • Context fields are kernel-derived and content-addressed where appropriate.
  • Existing digest-bound per-instance approval remains valid and does not become broader automatically.
  • The task grant remains the live authority object.
  • Multiple responsibilities cannot pool authority merely because they share an action ID.

Done when

  • The miner cannot call two different targets/accounts one repeated approval pattern.
  • Every active communication standing rule carries reviewed non-action scope.
  • Multiple disjoint scoped rules for one action coexist safely.
  • Ambiguous overlaps fail closed without budget use.
  • Live scope matching occurs before budget reservation and dark-window scheduling.
  • Changed context reliably falls back to ordinary approval without leakage or budget use.
  • Scope/evidence/conflict behavior is covered by protocol-neutral tests plus the Gmail matrix.

Relationship

Parent: #123.

Requires: #126 and #127.

Provides the context/evidence inputs required by #133.

Blocks the first complete Gmail delegation proof.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fence:post-fit-reviewDo not start before the Bell fit review lands on build-on

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions