fix: repair verify.mjs and add GitHub Actions CI#61
fix: repair verify.mjs and add GitHub Actions CI#61brawlaphant wants to merge 2 commits intoregen-network:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, 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
Ignored Files
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
scripts/verify.mjs
Outdated
| // 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"); |
There was a problem hiding this comment.
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.
| // 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`); |
scripts/verify.mjs
Outdated
| // 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"]); |
There was a problem hiding this comment.
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.
| // 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>
Summary
scripts/verify.mjs: missing closing brace on the m010 KPI schema check (line 119) that caused a parse failure.github/workflows/verify.ymlGitHub Actions CI workflow that runsverify.mjsandbuild-mechanism-index.mjs --checkon push/PR to mainTest plan
node scripts/verify.mjspasses locally after changes🤖 Generated with Claude Code