Status: Draft Review. This report maps the Pharmacy Fiduciary Commons codebase to the principles defined in COMMONS_CONSTITUTION.md to identify gaps and design flaws.
This section analyzes the structural implementation of the smart contracts against the ten constitutional principles, identifying specific contract functions and active gaps.
- Code References:
contracts/OZTimelockControllerImport.sol,contracts/PBMRebateTreasury.sol - Status: Partial protocol-enforced alignment.
- Analysis:
- Role separation between
COUNCIL_ROLE(proposer of roots) andROOT_CONFIRMER_ROLE(verifier of roots) is contract-enforced inPBMRebateTreasury.sol. - The
GUARDIAN_ROLEholds pause capabilities but is blocked from unpausing or claiming, enforcing emergency separation.
- Role separation between
- Gaps:
- Timelocks and role splits do not ensure replaceability of the trust root.
- The annual nominations, signer elections, and removal petitions (requiring a 10% threshold) defined in
GOVERNANCE.mdare docs-only. No smart contract logic allows credentialed participants to execute a signer rotation or revoke a compromised council key.
- Code References:
contracts/PharmacyMutualCredit.sol - Status: Aspirational / Gapped.
- Analysis:
PharmacyMutualCredit.solallows peer-to-peer credit transfers and voucher redemption.- Voucher redemption now includes a 30-day issuer deauthorization grace window for vouchers created before issuer removal, with
createdAtstored on each voucher to handle reauthorization cycles.
- Gaps:
- All credit limits (
updateCreditLimit) and authorized voucher issuers (updateIssuerStatus) are managed by the globalCOUNCIL_ROLE. - There is no local autonomy: a local federation cannot set its own credit constraints, approve its own local emergency issuers, or partition its liabilities from the global registry.
- All credit limits (
- Code References:
contracts/PBMRebateTreasury.sol(reserves partitioning) - Status: Partially protocol-enforced.
- Analysis:
- The contract divides rebate inflows strictly: 99% to the distribution pool/escrow and 1% to the governance reserve.
exclusionRemediationReserveis explicitly funded viafundExclusionRemediationand is the only source of funds for approved exclusion claims, preventing old errors from depleting active pools.
- Gaps:
- The broader promise that experimental features or governance failures will not shift losses to pharmacies and patients is not contract-enforced.
- Code References:
contracts/PBMRebateTreasury.sol#L1104(recoverStaleDistributionPool) - Status: Mitigated tested design risk.
- Analysis:
- If unallocated distribution funds sit inactive for 180 days, the
Executorcan recover them to thepatientFundto prevent permanent locks. - Recovery is gated by
epochStartTimestamp, notlastDepositTimestamp, so a later 1 wei dust deposit does not restart the 180-day delay. - Recovery remains blocked while a current root is live or a pending root proposal has not expired.
- If unallocated distribution funds sit inactive for 180 days, the
- Remaining Gaps:
- Governance still needs participant-facing notice expectations before stale recovery is executed.
- Code References:
scripts/export-portability.js,scripts/verify-export.js - Status: Tool-supported prototype.
- Analysis:
- The scripts extract and verify claims, Merkle proofs, and votes locally.
- Gaps:
- Portability is entirely dependent on off-chain JSON tools. The smart contracts contain no mechanisms to recognize or interoperably migrate state to a federated fork.
- Code References:
contracts/PatientFundParticipatoryBudgeting.sol - Status: Partially protocol-enforced.
- Analysis:
- Payout matching weights use approval counts rather than token size.
- Finalized project shares are claimable for 90 days; after that grace period, council may reclaim unclaimed shares into an internal recycled matching pool that is applied by
startRoundwhen the next round opens.
- Gaps:
- Aggregated project votes are squared for payout weighting (
castVoteincrements approval count, and finalization squares it). While non-token-weighted, this approval system amplifies majorities and does not intrinsically prevent minority project exclusion. - Reclaimed funds no longer enter council custody directly, but the council still controls when the next round starts and which projects are eligible.
- Aggregated project votes are squared for payout weighting (
- Code References:
contracts/PBMRebateTreasury.sol#L1220(appealSanction) - Status: Partial protocol support + unimplemented procedure.
- Analysis:
- Any sanctioned account can submit a string reason plus non-zero evidence hash to log an appeal on-chain.
- Gaps:
- Credential revocation (managed off-chain or by the credential relayer key) has no general appeal mechanism.
- The 14-day review timeout and the requirement to lift or sustain sanctions are documented in
GOVERNANCE.mdbut are not enforced in contract code. - Future privacy-preserving credential mitigation is detailed in the IDENTITY_NULLIFIER_DESIGN.md proposal.
- Code References: Events (
ClaimResolved,SanctionUpdated, etc.) - Status: Partially protocol-enforced.
- Analysis:
- Core state modifications emit events detailing the actor and transaction parameters.
- Normal dispute flags, exclusion dispute flags, dispute resolutions, and sanction appeals now bind non-zero evidence hashes on-chain.
- Gaps:
- Events still do not store full evidence, NCPDP logs, or Council meeting rationales.
SanctionUpdatedremains reason-coded but does not require an evidence hash. The off-chain storage and availability requirements for these commitments are now defined in EVIDENCE_METADATA.md.
- Events still do not store full evidence, NCPDP logs, or Council meeting rationales.
- Code References:
contracts/PBMRebateTreasury.sol#L1141(reduceHardCap) - Status: Partially protocol-enforced.
- Analysis:
- Enforces caps on daily and absolute epoch volumes.
- Gaps:
- Caps are manual administrative parameters; they are not bound to live pharmacy transaction metrics or external sandboxes.
- The cap-reservation dispute tradeoff (where a flagged dispute locks up daily/epoch cap volume) is now documented and covered by security tests (
PBMRebateTreasury.security.test.js).
- Code References:
WELLBEING_METRICS.md - Status: Aspirational / interpretive.
- Analysis:
- Metrics define real-world benchmarks (pricing spreads, matching ratios) to evaluate institutional success.
- Gaps:
- No concrete procedure or code currently implements these checks; the wellbeing CLI auditor script is absent.
To transition COMMONS_CONSTITUTION.md from a draft proposal to a legitimate governance covenant, we outline three potential ratification pathways, which have been formalized in the proposed RATIFICATION_PROCEDURE.md:
- Credential-Gated Referendum:
- Leverage the existing
PatientFundParticipatoryBudgeting.solinfrastructure to hold a ratification vote. - Registered participant pharmacies and patient advocates vote to approve the text.
- Leverage the existing
- Multi-Sig Cooperative Signing:
- Require Council members and representatives from independent pharmacy cooperatives to execute a multi-signature transaction binding their addresses to the IPFS hash of the ratified constitution.
- Consensus Forking:
- If a subgroup disagrees with the draft, their right to fork the scripts and contracts is protected, allowing them to redeploy a separate federation with a modified constitution.
Two core governance tensions remain active and unresolved:
- Disagreement: Should the off-chain advisory layer (Dizzy the Polymath) remain strictly advisory, or should its findings be programmatically bound to the smart contracts?
- Tension:
- If strictly advisory, the Council retains execution authority and can ignore findings, risking administrative capture.
- If programmatically bound, we risk delegating authority to unappealable, opaque algorithmic models, violating the Contestable identity and No permanent sovereign principles.
- Disagreement: Should the system record stable, searchable participant credential hashes, or should it prioritize absolute privacy?
- Tension:
- However, stable hashes allow payers (PBMs) to profile and retaliate against independent pharmacies that join the commons. Resolving this requires evaluating zero-knowledge nullifiers which add implementation complexity. The proposed design direction for this is detailed in IDENTITY_NULLIFIER_DESIGN.md.