← Back to Pull requests

Step 5: the policy and pending actions #6

Closed
unknown closed this pull request without merging on Oct 20, 2026 23:46 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 23:18 UTC
Author

<!-- claude-projects-attribution: {"github_login":"b3hr4d"} -->
_Requested by Behrad · project thread_

Before: a wallet had exactly the owner who claimed it. Nobody could add a device, change a role or set a policy.

After: members change members and the policy through actions. An owner proposes, owners and approvers approve and execute, owners reject, and viewers only read. An action waits for its rule's quorum (the proposer's approval counts), then for its timelock, and then it can be executed. A signed-in non-member can ask to join with request_join, which becomes an AddMember action for a viewer. Seven new methods answer: propose, approve, reject, execute, pending, policy and request_join.

The rules, all in docs/design.md under "Approve an action":

  • An action waits seven days for its quorum (a join request one hour). At the quorum its timelock starts; it can then be executed until seven days after the timelock ends. Past either window it is expired.

  • The quorum and timelock are fixed at proposal. An approval stops counting while an action waits if its member is removed or becomes a viewer.

  • execute checks the action again against the current members and policy; one that no longer fits ends Failed with the reason, and the call returns Ok with that state.

  • No change may leave the wallet without an owner or with fewer owners and approvers than a quorum.

  • A policy has one rule per action kind, a quorum of at least one, a timelock of at most 90 days, daily limits only on transfers, and a SetPolicy rule at least as strict as every other rule, so changing the policy is never the way around a rule.
  • How: three pure modules hold the logic. policy.rs validates policies and computes the terms of an action, including the daily-limit fast path that transfers will use in step 8. actions.rs is the life of one pending action. governance.rs applies membership and policy changes to an in-memory copy of the members and the policy and refuses any change that breaks the rules above. storage.rs adds the policy (memory id 1), the actions (memory id 4, never deleted, so an id never names another action) and an index of the open ones (memory id 10, new in docs/design.md), so no call reads the whole history. Role checks are guards, like the member check from step 4.

    Upgrades: a wallet installed and claimed with step 4 has no policy, so post_upgrade now gives it the default one before it checks the state (Codex's finding). CI now builds the pull request's base, installs and claims it in PocketIC and upgrades it to the change, on every pull request from here on.

    Tests: property tests (proptest 1.11.0, a dev-dependency only) check that an action runs only with its quorum, only after its timelock and never after its expiry, under any sequence of approvals, rejections, executions and waits; that only transfers within their daily limit skip their rule; that SetPolicy is never weaker than another rule; and that any sequence of membership and policy changes leaves the wallet governable, with a refused change changing nothing. PocketIC tests advance time through a timelock (also across an upgrade), past the approval expiry and the join-request expiry, and cover rejection, a failed execution, dropped approvals, the join-request cap and the role refusals. The enumeration test from step 4 now finds seven guarded methods.

    Fault injection, each against the real Wasm: dropping the policy migration, skipping the timelock check, starting the timelock at the proposal, ignoring expiry, keeping a removed member's approvals, skipping the re-check at execution, allowing the last owner's removal, allowing a weaker SetPolicy rule, lifting the join-request cap, letting approvers propose, joining as an owner, leaving expired ids in the index, and an off-by-one daily limit each make at least one test fail.

    Choices made without you, all easy to change:

  • The default policy uses the design's recommendations: quorum 1, and 24 hours for removing a member or changing a role, 7 days for SetPolicy and Upgrade, none for the rest. Both are still listed as open decisions.

  • A join request adds a viewer. Promoting it to owner is a ChangeRole with its 24-hour timelock.

  • Join requests are kept for good, at most eight open at once and each for an hour, so strangers can add about 200 a day.

  • Transfer, InstallExtension, UninstallExtension and Upgrade proposals are refused until their steps.
  • Checks run locally: cargo fmt --all --check, clippy native and wasm32 with -D warnings, unit, property and interface tests, the release Wasm build, and the PocketIC tests against server 16.1.0, including the upgrade from step 4's Wasm.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_013Vgh2De8Zarye1iDyGSRbe

    Diff: 621 lines (+465 / -156) across 7 files Reviewer: b3hr4d Review duration: 27m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.55) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 621 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.385
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #6"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 55.3% (MEDIUM) · Higher = larger blast radius
    55.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%