Skip to content

feat: M001-ENH mechanism spec + economic reboot mechanisms#19

Open
CShear wants to merge 2 commits intoregen-network:mainfrom
CShear:feat/economic-reboot-mechanisms
Open

feat: M001-ENH mechanism spec + economic reboot mechanisms#19
CShear wants to merge 2 commits intoregen-network:mainfrom
CShear:feat/economic-reboot-mechanisms

Conversation

@CShear
Copy link
Contributor

@CShear CShear commented Feb 18, 2026

Summary

  • Add canonical M001-ENH (Credit Class Approval Voting Enhancement) mechanism spec under mechanisms/m001-enh-credit-class-approval/, consolidating design material from phase-2/2.1, phase-2/2.3, and phase-3/3.1
  • Include JSON schemas (agent score, proposal lifecycle, KPIs), reference implementation with deterministic test vectors, and replay datasets grounded in real Regen Network credit types (C, KSH, BT, MBS, USS)
  • Add Economic Reboot mechanism specifications (M012-M015), M010 challenge/dispute workflow, PoA transition annotations, and OPAL coherence scoring
  • Update mechanism index, consumers doc, and package.json ("type": "module" for ESM support)

What's in the M001-ENH spec

  • 13-section SPEC.md: problem, scoring function (4-factor weighted composite), state machine (DRAFT → AGENT_REVIEW → VOTING → APPROVED/REJECTED/EXPIRED), deposit escrow, PoA dual-track variant, security invariants, attack model, 20 acceptance tests
  • 3 JSON schemas: m001_agent_score, m001_proposal, m001_kpi
  • Reference impl: m001_score.js (scoring) + m001_kpi.js (KPI computation) with test vectors
  • Replay datasets: v0_sample.json (full lifecycle) + v0_rejection_sample.json (edge cases)

Test plan

  • npm run verify passes
  • npm run check:index passes
  • m001_score.js self-test matches all 5 expected test vectors
  • m001_kpi.js produces correct KPI output from fixture data
  • All 17 JSON files parse correctly
  • Schema required fields and enum values validated
  • Fixture data cross-validated against schema constraints
  • m010 regression: score (0.5488) and KPI outputs unchanged

🤖 Generated with Claude Code

… spec

Consolidate design material from phase-2/2.1 (M001-ENH), phase-2/2.3 (GOV-001),
and phase-3/3.1 (protobuf + keeper) into a canonical mechanisms/ folder following
the m010 pattern. Includes 13-section SPEC, JSON schemas (agent score, proposal
lifecycle, KPIs), reference implementation with deterministic test vectors, and
replay datasets grounded in real Regen Network credit types and classes.

Also adds "type": "module" to package.json for ESM export support in reference-impl
.js files (consistent with existing m010 ESM syntax).

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 the M001-ENH mechanism, a significant enhancement to the Regen Network's credit class approval process. It establishes a robust, agent-based pre-screening system designed to elevate the quality of credit class proposals and optimize governance efficiency. The changes encompass a comprehensive specification, standardized data models via JSON schemas, and a functional reference implementation with test data, all aimed at fostering a more structured and reliable evaluation framework for new credit classes.

Highlights

  • M001-ENH Mechanism Introduction: The M001-ENH (Credit Class Approval Voting Enhancement) mechanism has been fully introduced, providing a structured pre-screening process for credit class creator applications.
  • Comprehensive Specification: A detailed specification document (SPEC.md) outlines the problem, actors, a 4-factor weighted composite scoring function, a state machine for proposal lifecycle, token flows, security invariants, an attack model, and 20 acceptance tests for M001-ENH.
  • Standardized Data Schemas: New JSON schemas have been added for agent scores, the proposal lifecycle, and Key Performance Indicators (KPIs), ensuring consistent data outputs and validation across the ecosystem.
  • Reference Implementation and Test Vectors: A JavaScript reference implementation for the M001-ENH scoring function and KPI computation is included, complete with deterministic test vectors and replay datasets for validation and consistent results.
  • Documentation and Module Support: Core documentation (README.md, MECHANISM_CONSUMERS.md) has been updated to reflect the new mechanism, and package.json was configured to enable ES Module (ESM) support.
Changelog
  • README.md
    • Added 'm001-enh' to the autogenerated mechanisms index.
  • docs/MECHANISM_CONSUMERS.md
    • Added a new section detailing the 'm001-enh' mechanism, including its canonical spec, output schemas, deterministic datasets, and known consumers.
  • mechanisms/m001-enh-credit-class-approval/README.md
    • Added an introductory overview for the 'm001-enh' mechanism, outlining its purpose, outputs, limitations of v0, and how to reference its components.
  • mechanisms/m001-enh-credit-class-approval/SPEC.md
    • Added the full specification document for 'm001-enh', detailing the problem, target actors, signal definition, evidence inputs, weighted composite scoring function, state machine, token flows, PoA variant, security invariants, attack model, integration points, acceptance tests, and rollout plan.
  • mechanisms/m001-enh-credit-class-approval/datasets/README.md
    • Added documentation explaining the purpose and usage of the deterministic replay datasets for 'm001-enh' KPI generation.
  • mechanisms/m001-enh-credit-class-approval/datasets/fixtures/v0_rejection_sample.json
    • Added a JSON fixture containing sample data for 'm001-enh' rejection and edge-case scenarios, including auto-reject, human override, low confidence, and agent timeout.
  • mechanisms/m001-enh-credit-class-approval/datasets/fixtures/v0_sample.json
    • Added a JSON fixture containing sample data for 'm001-enh' proposals covering a full lifecycle (approved, rejected, expired) with varied agent scores.
  • mechanisms/m001-enh-credit-class-approval/datasets/schema.json
    • Added a JSON schema to validate the structure and content of 'm001-enh' replay datasets.
  • mechanisms/m001-enh-credit-class-approval/reference-impl/README.md
    • Added documentation for the 'm001-enh' reference implementation, describing its inputs and outputs for scoring and KPI computation.
  • mechanisms/m001-enh-credit-class-approval/reference-impl/m001_kpi.js
    • Added a JavaScript module to compute Key Performance Indicator (KPI) metrics for 'm001-enh' credit class approval proposals.
  • mechanisms/m001-enh-credit-class-approval/reference-impl/m001_score.js
    • Added a JavaScript module implementing the 'm001-enh' 4-factor weighted composite scoring function for credit class creator proposals, including a self-test.
  • mechanisms/m001-enh-credit-class-approval/reference-impl/test_vectors/vector_v0_sample.expected.json
    • Added expected output JSON for the 'm001_score.js' self-test, defining the anticipated scores and KPI results.
  • mechanisms/m001-enh-credit-class-approval/reference-impl/test_vectors/vector_v0_sample.input.json
    • Added input JSON for the 'm001_score.js' self-test, providing sample proposal data and pre-computed factor scores.
  • mechanisms/m001-enh-credit-class-approval/schemas/README.md
    • Added documentation explaining the purpose and contents of the 'm001-enh' JSON schemas for output artifacts.
  • mechanisms/m001-enh-credit-class-approval/schemas/m001_agent_score.schema.json
    • Added a JSON schema defining the structure for 'm001-enh' agent pre-screening score outputs.
  • mechanisms/m001-enh-credit-class-approval/schemas/m001_kpi.schema.json
    • Added a JSON schema defining the structure for 'm001-enh' KPI metrics outputs.
  • mechanisms/m001-enh-credit-class-approval/schemas/m001_proposal.schema.json
    • Added a JSON schema defining the structure for 'm001-enh' ClassCreatorProposal lifecycle objects.
  • package.json
    • Updated the package configuration to include "type": "module", enabling ES Module support.
Activity
  • No human activity has been recorded on this pull request yet.
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

The pull request introduces the M001-ENH mechanism specification, reference implementation, and associated schemas and datasets. The documentation is comprehensive, and the new files are well-structured. Several inconsistencies and minor improvements have been identified in the specification and reference implementation, particularly concerning the explicit definition of transition logic and data structure alignment, which should be addressed for clarity and correctness. The changes also include enabling ESM support in package.json.

Comment on lines +78 to +79
- If no M010 score: `f_reputation = 500` (neutral default)
- Historical proposal success rate is a secondary factor: `f_reputation = 0.7 × m010_score + 0.3 × (historical_pass_rate × 1000)`
Copy link
Contributor

Choose a reason for hiding this comment

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

high

There's an inconsistency in how the M010 reputation score is scaled. This specification states that m010_score is 0-1 in v0, but 0-1000 in v1. However, the m001_score.js reference implementation and m001_agent_score.schema.json expect admin_reputation to be in the 0-1000 range directly. This implies that if m010_score is used as admin_reputation in v0, it needs to be explicitly scaled (multiplied by 1000) before being passed to the computeM001Score function. This discrepancy should be clarified in the documentation or handled within the implementation to prevent incorrect scoring.

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.

const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));

const fMeth = clamp(factors.methodology_quality ?? 0, 0, 1000);
const fRep = clamp(factors.admin_reputation ?? 500, 0, 1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This line directly uses factors.admin_reputation assuming it's already scaled to 0-1000. This is consistent with the test vectors and the m001_agent_score.schema.json but conflicts with the SPEC.md and reference-impl/README.md which state that the M010 score is 0-1 in v0. Ensure that the input admin_reputation is consistently scaled to 0-1000 before being passed to this function, or implement the scaling logic here.

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.

Comment on lines +60 to +63
"type": "integer",
"minimum": 0,
"maximum": 1000,
"description": "Admin/proposer reputation from M010 (weight: 0.3)"
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 admin_reputation property is defined with a minimum: 0 and maximum: 1000. This aligns with the m001_score.js implementation and test vectors, but it's important to ensure this is consistent with the source of admin_reputation (M010 reputation signal) as described in SPEC.md and reference-impl/README.md, which mention a 0-1 scale for v0. This reinforces the high-severity issue identified in SPEC.md regarding score scaling.

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.
  2. 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.

@@ -0,0 +1,32 @@
# m001-enh — Credit Class Approval Voting Enhancement (v0 advisory)

m001-enh enhances the Regen Network credit class creator allowlist with **agent pre-screening**, **tiered approval thresholds**, and **deposit escrow** (v1). It builds on the existing `x/ecocredit` governance process with structured quality assessment before community vote.
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 phrase "deposit escrow (v1)" here might be slightly redundant given that the "What it does not do (v0)" section explicitly states that deposit escrow is not on-chain in v0. Consider rephrasing for improved clarity, perhaps by removing "(v1)" from this introductory sentence.

Where `data_available_factors` counts factors with non-default/non-estimated inputs:
- M010 reputation score exists (not defaulted to 500)
- Methodology document fully resolvable and parseable
- At least 3 existing classes for meaningful similarity comparison
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 condition "At least 3 existing classes for meaningful similarity comparison" is a specific threshold. Consider adding a brief rationale for why '3' was chosen, or if this value should be configurable in the future.

Comment on lines +1 to +5
export function median(nums) {
if (!nums.length) return null;
const s = [...nums].sort((a, b) => a - b);
const mid = Math.floor(s.length / 2);
return s.length % 2 ? s[mid] : (s[mid - 1] + s[mid]) / 2;
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 median function is defined but does not appear to be used anywhere within m001_kpi.js. If it's not intended for immediate use, consider removing it to keep the codebase clean and avoid dead code. If it's for future use, perhaps add a comment indicating its purpose.

const expected = JSON.parse(fs.readFileSync(expectedPath, "utf8"));

const results = input.proposals.map(p => computeM001Score({
proposal: p.proposal,
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 condition factors.sufficient_classes !== false is functionally correct but can be simplified. For boolean checks, if (factors.sufficient_classes) is more idiomatic and readable.

  if (factors.sufficient_classes) available++;

… dead code

- SPEC.md: clarify M010 score scaling (v0: multiply by 1000; v1: direct)
- SPEC.md: add rationale for 3-class similarity threshold
- README.md: rephrase deposit escrow v1 note for clarity
- m001_kpi.js: remove unused median() function
- m001_score.js: simplify confidence checks from !== false to truthy

Fixes Gemini review on PR regen-network#19.

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