From 5f3d3f929935e5e0ab2c46a631fd9bf80da46269 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 01:09:18 +0000 Subject: [PATCH] chore(scheduler): weekly event-schema-agent execution Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- ...9_01-04-56_event-schema-agent_completed.md | 28 ++++++++ scripts/agent/validate-events.mjs | 65 +++++++++++++++++-- 2 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 docs/agents/task-logs/weekly/2026-02-19_01-04-56_event-schema-agent_completed.md diff --git a/docs/agents/task-logs/weekly/2026-02-19_01-04-56_event-schema-agent_completed.md b/docs/agents/task-logs/weekly/2026-02-19_01-04-56_event-schema-agent_completed.md new file mode 100644 index 00000000..a3d9c611 --- /dev/null +++ b/docs/agents/task-logs/weekly/2026-02-19_01-04-56_event-schema-agent_completed.md @@ -0,0 +1,28 @@ +# Weekly Task: Event Schema Validation + +**Agent:** bitvid-event-schema-agent +**Date:** 2026-02-19 +**Status:** Completed + +## Summary +The event schema validation harness `scripts/agent/validate-events.mjs` was updated to support CLI arguments (`--out`, `--only`, `--dry-run`) and to walk the repository for runtime `build*Event` call sites. + +## Actions Taken +1. Updated `scripts/agent/validate-events.mjs` to include: + - CLI argument parsing. + - Automatic date-stamped output filename (default: `artifacts/validate-events-YYYYMMDD.json`). + - Repo walking logic using `grep` to identify dynamic usage of event builders. +2. Executed the validation harness: + - Command: `node scripts/agent/validate-events.mjs --out=artifacts/validate-events-20260219.json` + - Result: All 28 canonical builders passed validation. + - Detected: 118 runtime call sites for event builders. +3. Generated artifact: `artifacts/validate-events-20260219.json`. + +## Verification +- `npm run lint` passed. +- Validation script ran successfully with no errors. +- Report artifact generated and verified. + +## Next Steps +- Review the 118 runtime call sites for potential schema misuse (manual or future automated task). +- Continue weekly validation to ensure no regressions in event structure. diff --git a/scripts/agent/validate-events.mjs b/scripts/agent/validate-events.mjs index bb9f3c61..fd4efae9 100644 --- a/scripts/agent/validate-events.mjs +++ b/scripts/agent/validate-events.mjs @@ -32,18 +32,60 @@ import { } from "../../js/nostrEventSchemas.js"; import { buildNip71VideoEvent } from "../../js/nostr/nip71.js"; import fs from "fs"; +import { execSync } from "child_process"; +import path from "path"; -const REPORT_FILE = "artifacts/validate-events.json"; +// Parse CLI args +const args = process.argv.slice(2); +const getArg = (key) => { + const arg = args.find(a => a.startsWith(`--${key}=`)); + return arg ? arg.split('=')[1] : null; +}; +const hasArg = (key) => args.includes(`--${key}`); + +const now = new Date(); +const yyyymmdd = now.toISOString().slice(0, 10).replace(/-/g, ""); +const defaultOut = `artifacts/validate-events-${yyyymmdd}.json`; + +const OUT_FILE = getArg("out") || defaultOut; +const ONLY_BUILDER = getArg("only"); +const DRY_RUN = hasArg("dry-run"); // Valid 32-byte hex pubkey for testing const TEST_PUBKEY = "0000000000000000000000000000000000000000000000000000000000000001"; const TEST_EVENT_ID = "0000000000000000000000000000000000000000000000000000000000000002"; +function findCallSites() { + try { + // Grep for build*Event calls in js/ directory, excluding node_modules and dist + // We look for the pattern build[A-Z]...Event + const cmd = `grep -rn "build[A-Z][a-zA-Z]*Event" js/ --include="*.js" --exclude-dir=node_modules`; + const output = execSync(cmd, { encoding: 'utf-8' }); + return output.split('\n').filter(Boolean).map(line => { + // line format: file:line:content + const parts = line.split(':'); + if (parts.length < 3) return null; + return { + file: parts[0], + line: parts[1], + content: parts.slice(2).join(':').trim() + }; + }).filter(Boolean); + } catch (e) { + // grep returns exit code 1 if no matches found, which execSync treats as error + if (e.status === 1) return []; + console.warn("Could not find call sites via grep:", e.message); + return []; + } +} + function runValidation() { const results = []; const failures = []; const runTest = (name, builder, input, expectedType) => { + if (ONLY_BUILDER && !name.includes(ONLY_BUILDER)) return; + try { const event = builder(input); const validation = validateEventStructure(expectedType, event); @@ -78,7 +120,7 @@ function runValidation() { } }; - console.log("Starting event schema validation..."); + console.log(`Starting event schema validation... Output: ${OUT_FILE}`); // 1. Video Post runTest("buildVideoPostEvent", buildVideoPostEvent, { @@ -304,9 +346,22 @@ function runValidation() { } }, NOTE_TYPES.NIP71_VIDEO); - // Write Report - fs.writeFileSync(REPORT_FILE, JSON.stringify(results, null, 2)); - console.log(`\nReport written to ${REPORT_FILE}`); + // Find call sites + const callSites = findCallSites(); + console.log(`Found ${callSites.length} runtime call sites.`); + + const finalReport = { + results, + runtime_call_sites: callSites + }; + + if (!DRY_RUN) { + fs.mkdirSync(path.dirname(OUT_FILE), { recursive: true }); + fs.writeFileSync(OUT_FILE, JSON.stringify(finalReport, null, 2)); + console.log(`\nReport written to ${OUT_FILE}`); + } else { + console.log("\nDry run: Skipping report write."); + } if (failures.length > 0) { console.error(`\n⚠️ Found ${failures.length} validation failures.`);