Skip to content

fix: repair verify.mjs and add GitHub Actions CI#61

Open
brawlaphant wants to merge 2 commits intoregen-network:mainfrom
brawlaphant:pr/fix-verify-and-ci
Open

fix: repair verify.mjs and add GitHub Actions CI#61
brawlaphant wants to merge 2 commits intoregen-network:mainfrom
brawlaphant:pr/fix-verify-and-ci

Conversation

@brawlaphant
Copy link
Copy Markdown
Contributor

Summary

  • Fix syntax error in scripts/verify.mjs: missing closing brace on the m010 KPI schema check (line 119) that caused a parse failure
  • Extend verify.mjs to validate M014 (authority-validator-governance) and M015 (contribution-weighted-rewards) with requireFile checks, schema sanity checks, and self-tests
  • Add .github/workflows/verify.yml GitHub Actions CI workflow that runs verify.mjs and build-mechanism-index.mjs --check on push/PR to main

Test plan

  • node scripts/verify.mjs passes locally after changes
  • CI workflow runs successfully on this PR

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 significantly enhances the project's validation and continuous integration capabilities. It resolves a critical syntax error in the verification script, preventing parsing issues, and expands the script's coverage to include two new mechanisms, M014 and M015, ensuring their schemas and reference implementations are correctly structured and functional. Furthermore, the integration of a new GitHub Actions workflow automates these crucial verification steps, establishing a robust quality gate for future changes.

Highlights

  • Bug Fix: Repaired a syntax error in scripts/verify.mjs by adding a missing closing brace for the m010 KPI schema check, which previously caused a parse failure.
  • New Mechanism Validation: Extended scripts/verify.mjs to include validation for new mechanisms M014 (authority-validator-governance) and M015 (contribution-weighted-rewards). This includes requireFile checks for their core files, schema sanity checks for their KPI schemas, and execution of their reference implementation self-tests.
  • Continuous Integration: Introduced a new GitHub Actions CI workflow (.github/workflows/verify.yml) that automatically runs verify.mjs and build-mechanism-index.mjs --check on push and pull requests to the main branch, ensuring ongoing validation.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/verify.yml
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.

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
Copy Markdown
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 integrates two new mechanisms, m014 (authority-validator-governance) and m015 (contribution-weighted-rewards), into the scripts/verify.mjs script. The changes involve adding requireFile calls for all associated files (specs, schemas, datasets, reference implementations) and implementing schema sanity checks and self-tests for their KPI schemas. The review feedback suggests refactoring the newly added requireFile calls and the schema sanity/self-test blocks to improve readability, reduce repetition, and enhance maintainability and extensibility by using constants for paths and a loop for repetitive checks.

Comment on lines +115 to +131
// m014 core files
requireFile("mechanisms/m014-authority-validator-governance/SPEC.md");
requireFile("mechanisms/m014-authority-validator-governance/README.md");
requireFile("mechanisms/m014-authority-validator-governance/schemas/m014_kpi.schema.json");
requireFile("mechanisms/m014-authority-validator-governance/schemas/m014_performance.schema.json");
requireFile("mechanisms/m014-authority-validator-governance/schemas/m014_validator.schema.json");
requireFile("mechanisms/m014-authority-validator-governance/datasets/fixtures/v0_sample.json");
requireFile("mechanisms/m014-authority-validator-governance/reference-impl/m014_kpi.js");
requireFile("mechanisms/m014-authority-validator-governance/reference-impl/m014_score.js");

// m015 core files
requireFile("mechanisms/m015-contribution-weighted-rewards/SPEC.md");
requireFile("mechanisms/m015-contribution-weighted-rewards/schemas/m015_kpi.schema.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/schemas/m015_activity_score.schema.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/schemas/m015_stability_commitment.schema.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/datasets/fixtures/v0_sample.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/reference-impl/m015_score.js");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve readability and reduce repetition, you can define constants for the base paths of the mechanisms and use template literals for the file paths. This makes the code cleaner and easier to maintain.

Suggested change
// m014 core files
requireFile("mechanisms/m014-authority-validator-governance/SPEC.md");
requireFile("mechanisms/m014-authority-validator-governance/README.md");
requireFile("mechanisms/m014-authority-validator-governance/schemas/m014_kpi.schema.json");
requireFile("mechanisms/m014-authority-validator-governance/schemas/m014_performance.schema.json");
requireFile("mechanisms/m014-authority-validator-governance/schemas/m014_validator.schema.json");
requireFile("mechanisms/m014-authority-validator-governance/datasets/fixtures/v0_sample.json");
requireFile("mechanisms/m014-authority-validator-governance/reference-impl/m014_kpi.js");
requireFile("mechanisms/m014-authority-validator-governance/reference-impl/m014_score.js");
// m015 core files
requireFile("mechanisms/m015-contribution-weighted-rewards/SPEC.md");
requireFile("mechanisms/m015-contribution-weighted-rewards/schemas/m015_kpi.schema.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/schemas/m015_activity_score.schema.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/schemas/m015_stability_commitment.schema.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/datasets/fixtures/v0_sample.json");
requireFile("mechanisms/m015-contribution-weighted-rewards/reference-impl/m015_score.js");
// m014 core files
const m014Path = "mechanisms/m014-authority-validator-governance";
requireFile(`${m014Path}/SPEC.md`);
requireFile(`${m014Path}/README.md`);
requireFile(`${m014Path}/schemas/m014_kpi.schema.json`);
requireFile(`${m014Path}/schemas/m014_performance.schema.json`);
requireFile(`${m014Path}/schemas/m014_validator.schema.json`);
requireFile(`${m014Path}/datasets/fixtures/v0_sample.json`);
requireFile(`${m014Path}/reference-impl/m014_kpi.js`);
requireFile(`${m014Path}/reference-impl/m014_score.js`);
// m015 core files
const m015Path = "mechanisms/m015-contribution-weighted-rewards";
requireFile(`${m015Path}/SPEC.md`);
requireFile(`${m015Path}/schemas/m015_kpi.schema.json`);
requireFile(`${m015Path}/schemas/m015_activity_score.schema.json`);
requireFile(`${m015Path}/schemas/m015_stability_commitment.schema.json`);
requireFile(`${m015Path}/datasets/fixtures/v0_sample.json`);
requireFile(`${m015Path}/reference-impl/m015_score.js`);

Comment on lines +189 to +207
// Basic schema sanity — m014
const m014KpiSchema = readJson("mechanisms/m014-authority-validator-governance/schemas/m014_kpi.schema.json");
if (!m014KpiSchema.required || !m014KpiSchema.required.includes("mechanism_id")) {
console.error("m014 KPI schema missing required fields.");
process.exit(4);
}

// m014 self-test
run("node", ["mechanisms/m014-authority-validator-governance/reference-impl/m014_score.js"]);

// Basic schema sanity — m015
const m015KpiSchema = readJson("mechanisms/m015-contribution-weighted-rewards/schemas/m015_kpi.schema.json");
if (!m015KpiSchema.required || !m015KpiSchema.required.includes("mechanism_id")) {
console.error("m015 KPI schema missing required fields.");
process.exit(4);
}

// m015 self-test
run("node", ["mechanisms/m015-contribution-weighted-rewards/reference-impl/m015_score.js"]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The schema sanity checks and self-tests for m014 and m015 are repetitive. You can refactor this by creating a configuration array and looping through it to perform the checks. This will make the code more concise and easier to extend with new mechanisms.

Suggested change
// Basic schema sanity — m014
const m014KpiSchema = readJson("mechanisms/m014-authority-validator-governance/schemas/m014_kpi.schema.json");
if (!m014KpiSchema.required || !m014KpiSchema.required.includes("mechanism_id")) {
console.error("m014 KPI schema missing required fields.");
process.exit(4);
}
// m014 self-test
run("node", ["mechanisms/m014-authority-validator-governance/reference-impl/m014_score.js"]);
// Basic schema sanity — m015
const m015KpiSchema = readJson("mechanisms/m015-contribution-weighted-rewards/schemas/m015_kpi.schema.json");
if (!m015KpiSchema.required || !m015KpiSchema.required.includes("mechanism_id")) {
console.error("m015 KPI schema missing required fields.");
process.exit(4);
}
// m015 self-test
run("node", ["mechanisms/m015-contribution-weighted-rewards/reference-impl/m015_score.js"]);
// Schema sanity and self-tests for m014, m015
const mechanismsToTest = [
{ id: "m014", path: "m014-authority-validator-governance", selfTestScript: "m014_score.js" },
{ id: "m015", path: "m015-contribution-weighted-rewards", selfTestScript: "m015_score.js" },
];
for (const mech of mechanismsToTest) {
// Basic schema sanity
const kpiSchema = readJson(`mechanisms/${mech.path}/schemas/${mech.id}_kpi.schema.json`);
if (!kpiSchema.required || !kpiSchema.required.includes("mechanism_id")) {
console.error(`${mech.id} KPI schema missing required fields.`);
process.exit(4);
}
// self-test
run("node", [`mechanisms/${mech.path}/reference-impl/${mech.selfTestScript}`]);
}

Replace repetitive per-mechanism requireFile blocks, schema sanity
checks, and self-test invocations with a single MECHANISMS array that
declares each mechanism's files, KPI schema, and self-tests. Loops
iterate the registry for all common checks. m010-specific invariants
(challenge lifecycle guards, signal statuses) remain explicit.

Adding a new mechanism now requires only appending one entry to the
MECHANISMS array — no other code changes needed.

Addresses gemini-code-assist review feedback on PR regen-network#61.

Co-Authored-By: Claude Opus 4.6 (1M context) <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