Skip to content

Add m012 Fixed Cap Dynamic Supply mechanism spec#25

Open
CShear wants to merge 2 commits intoregen-network:mainfrom
CShear:feat/m012-dynamic-supply
Open

Add m012 Fixed Cap Dynamic Supply mechanism spec#25
CShear wants to merge 2 commits intoregen-network:mainfrom
CShear:feat/m012-dynamic-supply

Conversation

@CShear
Copy link
Contributor

@CShear CShear commented Feb 18, 2026

Summary

  • Adds full mechanism spec for m012 (Fixed Cap Dynamic Supply) — replaces inflationary PoS with algorithmic mint/burn supply management
  • Supply algorithm: S[t+1] = S[t] + M[t] - B[t], minting via M[t] = r × (C - S[t]) with dynamic regrowth rate
  • Hard cap ~221M REGEN; supply decelerates as it approaches cap
  • Phase-gated PoA transition: staking multiplier (pre-M014) → max(staking, stability) during transition → stability multiplier (post-M014)
  • Ecological multiplier disabled in v0 pending oracle resolution (OQ-M012-2)
  • BigInt arithmetic in uregen for precision on full supply computations
  • State machine: INFLATIONARY → TRANSITION → DYNAMIC → EQUILIBRIUM
  • Includes SPEC.md (13 sections), JSON schemas, reference implementation with 45 assertions, replay datasets with equilibrium convergence
  • Updates verify.mjs and MECHANISM_CONSUMERS.md

Test plan

  • node mechanisms/m012-fixed-cap-dynamic-supply/reference-impl/m012_supply.js — self-test PASS (5 periods, 45 assertions)
  • npm run verify — PASS
  • m010 regression — PASS
  • Review supply algorithm against Blockscience carrying capacity model
  • Validate BigInt precision against expected supply trajectories

🤖 Generated with Claude Code

Adds full mechanism spec for m012 following the established pattern:
- SPEC.md with 13 sections covering algorithmic mint/burn supply model,
  hard cap (221M REGEN), regrowth formula S[t+1] = S[t] + M[t] - B[t],
  and phase-gated PoA transition multiplier selection
- Supply algorithm: M[t] = r × (C - S[t]) where r = r_base × multiplier × ecological
- Phase-gated multiplier: staking (pre-M014) → max(staking, stability) → stability (post-M014)
- State machine: INFLATIONARY → TRANSITION → DYNAMIC → EQUILIBRIUM
- BigInt arithmetic in uregen for precision on supply computations
- JSON schemas for supply state, period record, and KPI metrics
- Reference implementation with self-test (5 periods, 45 assertions)
- Replay datasets including equilibrium convergence scenarios
- Updates verify.mjs and MECHANISM_CONSUMERS.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @CShear, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a foundational change to the network's monetary policy by implementing the m012 Fixed Cap Dynamic Supply mechanism. This new model moves away from continuous inflationary token minting towards a hard-capped, algorithmically managed supply that dynamically adjusts based on network activity and ecological metrics. The goal is to establish long-term monetary policy certainty and align token economics with ecological outcomes, fostering a more sustainable and predictable economic environment for the network.

Highlights

  • New Mechanism Introduction: Introduced the m012 Fixed Cap Dynamic Supply mechanism, replacing inflationary Proof-of-Stake with an algorithmic mint/burn model.
  • Supply Hard Cap: Defined a hard cap of approximately 221 million REGEN tokens, with supply decelerating as it approaches this limit.
  • Phase-Gated Multipliers: Implemented a phase-gated transition for staking and stability multipliers, ensuring a smooth shift in token economics based on M014 module state.
  • Precision Arithmetic: Utilized BigInt arithmetic for precise calculations of uregen values, preventing floating-point errors in supply computations.
  • Comprehensive Documentation & Implementation: Provided a comprehensive specification (SPEC.md), JSON schemas for data structures, and a reference implementation with 45 assertions.
  • Replay Datasets: Included replay datasets to demonstrate equilibrium convergence and validate supply trajectories under various conditions.
Changelog
  • README.md
    • Updated the main README to include m012 in the mechanism index.
  • docs/MECHANISM_CONSUMERS.md
    • Documented the m012 mechanism, detailing its canonical spec, output schemas, reference implementation, datasets, and known consumers.
  • mechanisms/m012-fixed-cap-dynamic-supply/README.md
    • Added a new README file providing an overview of the m012 mechanism, its functionality, and how to reference its components.
  • mechanisms/m012-fixed-cap-dynamic-supply/SPEC.md
    • Added the full specification document for the m012 Fixed Cap Dynamic Supply mechanism, outlining its problem statement, algorithm, state machine, and integration points.
  • mechanisms/m012-fixed-cap-dynamic-supply/datasets/README.md
    • Added a README explaining the purpose and structure of the m012 replay datasets.
  • mechanisms/m012-fixed-cap-dynamic-supply/datasets/fixtures/v0_equilibrium_sample.json
    • Added a JSON fixture dataset demonstrating periods approaching equilibrium for m012.
  • mechanisms/m012-fixed-cap-dynamic-supply/datasets/fixtures/v0_sample.json
    • Added a JSON fixture dataset for v0 reference replay of m012 supply state transitions.
  • mechanisms/m012-fixed-cap-dynamic-supply/datasets/schema.json
    • Added a JSON schema for validating m012 replay datasets.
  • mechanisms/m012-fixed-cap-dynamic-supply/reference-impl/README.md
    • Added a README for the m012 reference implementation, detailing inputs, outputs, and self-test instructions.
  • mechanisms/m012-fixed-cap-dynamic-supply/reference-impl/m012_kpi.js
    • Added a JavaScript module for computing Key Performance Indicators (KPIs) for the m012 mechanism.
  • mechanisms/m012-fixed-cap-dynamic-supply/reference-impl/m012_supply.js
    • Added the core JavaScript module implementing the m012 supply period computation logic.
  • mechanisms/m012-fixed-cap-dynamic-supply/reference-impl/test_vectors/vector_v0_sample.expected.json
    • Added a JSON file containing expected outputs for m012 supply computation test vectors.
  • mechanisms/m012-fixed-cap-dynamic-supply/reference-impl/test_vectors/vector_v0_sample.input.json
    • Added a JSON file containing input test vectors for m012 supply computation.
  • mechanisms/m012-fixed-cap-dynamic-supply/schemas/README.md
    • Added a README explaining the m012 output schemas.
  • mechanisms/m012-fixed-cap-dynamic-supply/schemas/m012_kpi.schema.json
    • Added a JSON schema for the m012 KPI output block.
  • mechanisms/m012-fixed-cap-dynamic-supply/schemas/m012_period_record.schema.json
    • Added a JSON schema for m012 per-period mint/burn records.
  • mechanisms/m012-fixed-cap-dynamic-supply/schemas/m012_supply_state.schema.json
    • Added a JSON schema for the m012 supply state input.
  • package.json
    • Configured the project to use ES modules by setting "type": "module".
  • scripts/verify.mjs
    • Updated the verification script to include checks for m012 files and run its self-test.
Activity
  • The author, CShear, has implemented the full mechanism spec for m012.
  • Self-tests for m012_supply.js passed with 5 periods and 45 assertions.
  • The npm run verify command passed successfully.
  • M010 regression tests also passed.
  • Two test plan items remain unchecked: reviewing the supply algorithm against the Blockscience carrying capacity model and validating BigInt precision against expected supply trajectories.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the m012 Fixed Cap Dynamic Supply mechanism, a major addition that replaces the inflationary PoS model. The changes are comprehensive, including a detailed specification, JSON schemas for data structures, a JavaScript reference implementation with self-tests, and corresponding test data. The code quality is high, and the documentation is thorough. I've provided a few suggestions to improve clarity in the specification, aligning with established documentation rules, and enhance the robustness and readability of the reference implementation. Overall, this is an excellent contribution.

const last = ps[ps.length - 1];
const currentSupply = BigInt(last.supply_after ?? last.next_supply);
const headroom = cap - currentSupply;
const capUtil = Number(currentSupply) / Number(cap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The calculation Number(currentSupply) / Number(cap) could lead to a division by zero if hard_cap is passed as "0". This would result in capUtil being Infinity or NaN, which would violate the schema constraints for cap_utilization ([0, 1]). It's safer to handle this edge case to prevent unexpected behavior.

Suggested change
const capUtil = Number(currentSupply) / Number(cap);
const capUtil = Number(cap) > 0 ? Number(currentSupply) / Number(cap) : 0;


## Schemas
Canonical JSON schemas for m012 outputs live in `schemas/`.
- `m012_supply_state.schema.json` — supply state (supply, cap, minted, burned, rates, multipliers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for m012_supply_state.schema.json is a bit misleading. It lists fields like minted, burned, rates, and multipliers, which are actually outputs of the period computation and part of the m012_period_record.schema.json. A more accurate description would focus on the input state, as is done in mechanisms/m012-fixed-cap-dynamic-supply/schemas/README.md. This aligns with the principle of ensuring data structure definitions maintain coherence.

Suggested change
- `m012_supply_state.schema.json` — supply state (supply, cap, minted, burned, rates, multipliers)
- `m012_supply_state.schema.json` — supply state (current supply, cap, staked amounts, multiplier config)
References
  1. When defining data structures or type definitions, ensure they are aligned with the project's central data standards repository (regen-data-standards) to maintain coherence. This comment highlights an inconsistency in data structure description, which impacts coherence.


Phase-gated behavior:
- if m014.state == INACTIVE: effective_multiplier = staking_multiplier
- if m014.state == TRANSITION: effective_multiplier = max(staking, stability)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved clarity and to avoid ambiguity, it would be better to use the full variable names in the formula within the code block, consistent with the surrounding text. This aligns with the rule to explicitly define transition logic to prevent implementation ambiguity.

Suggested change
- if m014.state == TRANSITION: effective_multiplier = max(staking, stability)
- if m014.state == TRANSITION: effective_multiplier = max(staking_multiplier, stability_multiplier)
References
  1. When specifying transition logic between different mechanisms (e.g., multipliers), explicitly define the function (e.g., max()) and the state-based conditions (phase-gating) that govern the transition to prevent implementation ambiguity. This comment improves the clarity of such logic.


DYNAMIC -> EQUILIBRIUM
trigger: abs(M[t] - B[t]) < threshold for N consecutive periods
guard: N >= 12 (12 months of near-balance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There appears to be an inconsistency in the time duration for the DYNAMIC -> EQUILIBRIUM state transition. The guard is N >= 12, but the note says (12 months of near-balance). Since a period is defined as ~7 days, 12 periods would be approximately 3 months, not 12. Please clarify if N should be closer to 52 for 12 months, or if the comment should be adjusted to ~3 months. This clarification is crucial for improving the clarity of state definitions and transitions.

References
  1. To improve document clarity, co-locate all state definitions and transitions within the primary state machine documentation, including definitions for edge-case flows like escalations. This comment addresses an inconsistency that impacts the clarity of a state transition definition.

Comment on lines +64 to +70
let equilibriumStatus = "not_reached";
if (gapPct !== null && gapPct < 5) {
equilibriumStatus = "approaching";
}
if (gapPct !== null && gapPct < 1) {
equilibriumStatus = "reached";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for determining equilibriumStatus can be made more efficient and clearer by using an if/else if structure. The current implementation performs a check for gapPct < 5 even if gapPct < 1 is true, which is redundant.

Suggested change
let equilibriumStatus = "not_reached";
if (gapPct !== null && gapPct < 5) {
equilibriumStatus = "approaching";
}
if (gapPct !== null && gapPct < 1) {
equilibriumStatus = "reached";
}
let equilibriumStatus = "not_reached";
if (gapPct !== null) {
if (gapPct < 1) {
equilibriumStatus = "reached";
} else if (gapPct < 5) {
equilibriumStatus = "approaching";
}
}

…variable names

- m012_kpi.js: guard against division by zero in cap utilization
- m012_kpi.js: simplify equilibrium status with if/else if chain
- SPEC.md: use full variable names in TRANSITION multiplier selection
- SPEC.md: fix equilibrium guard comment (12 periods ≈ 3 months, not 12)
- README.md: correct supply_state schema description

Fixes Gemini review on PR regen-network#25.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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