From c50447f68ff85aced1ab7ca0945df338df7cc0a4 Mon Sep 17 00:00:00 2001 From: Afolabi <35589781+Oba-One@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:44:18 -0800 Subject: [PATCH 1/5] Comments: add the comment codemod, extended to Astro components scripts/quality/comment-policy.mjs is Green Goods' codemod: its narrow pass removes banners, commented-out code, labels and notes that restate a name, and `--report triage` lists what a second pass sorts. Here it also reads an Astro component's frontmatter and ', + '', + '', + ].join('\n'); + const { code: purged, removed } = purgeSource(code, 'Example.astro'); + assert.deepEqual( + removed.map((comment) => comment.kind), + ['banner', 'banner'], + ); + assert.ok(!purged.includes('===== Props')); + assert.ok(!purged.includes('---------- Setup')); + assert.ok(purged.includes(''), 'template comments are markup, not code'); + assert.ok(purged.includes('"@context"'), 'a data script is not code'); + assert.ok(purged.startsWith('---\nconst { title } = Astro.props;\n---\n')); +}); + +test('a reason in Astro frontmatter survives the narrow pass', () => { + const code = + '---\n// Fetched at build time because the agent is not public during builds.\nconst data = await load();\n---\n

{data}

\n'; + assert.equal(purgeSource(code, 'Reason.astro').code, code); +}); From 7be6ae52440edb68350456093dff51011082a862 Mon Sep 17 00:00:00 2001 From: Afolabi <35589781+Oba-One@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:44:20 -0800 Subject: [PATCH 2/5] Comments: narrow purge of scripts Removes 33 banner comments from 7 files with `node scripts/quality/comment-policy.mjs --write scripts`. Co-Authored-By: Claude Opus 5.5 Agent-Model: claude-opus-5-5/high --- scripts/chapter-image-fields.integration.ts | 8 -------- scripts/directus-text-fields.integration.ts | 3 --- scripts/map-node-approval-guard.integration.ts | 5 ----- scripts/map-node-contract.test.ts | 3 --- scripts/pages-deploy-recovery.test.ts | 6 ------ scripts/snapshot-alert-episodes.integration.ts | 7 ------- scripts/ui-verify.ts | 4 ---- 7 files changed, 36 deletions(-) diff --git a/scripts/chapter-image-fields.integration.ts b/scripts/chapter-image-fields.integration.ts index 2f94b1a..04a38cc 100644 --- a/scripts/chapter-image-fields.integration.ts +++ b/scripts/chapter-image-fields.integration.ts @@ -183,7 +183,6 @@ try { await sql.unsafe(await readMigration(file)); } - // --- Backfill ----------------------------------------------------------- // Rows as they exist before 029: description in media only, no new columns. const legacyUpload = await uploadFile(); await insertChapter('legacy-approved', { @@ -237,7 +236,6 @@ try { assert.equal(Object.hasOwn(published ?? {}, 'imageAlt'), false); assert.equal(Object.hasOwn(published ?? {}, 'imageFileId'), false); - // --- Update request alt text and credit ----------------------------------- for (const file of migrations.filter((name) => name > IMAGE_MIGRATION && name < REQUEST_MIGRATION)) { await sql.unsafe(await readMigration(file)); } @@ -323,7 +321,6 @@ try { await editRequest(blank, { proposed_image_alt: '', proposed_image_credit: null }); assert.deepEqual(await requestDescription(blank), [null, null]); - // --- New rows ------------------------------------------------------------ // A seeded or imported chapter describes its sourced image in media only. await insertChapter('new-from-media', { media: sourced('new-from-media', { imageAlt: 'Imported alt.', imageCredit: 'Imported credit' }) }); let row = await chapterRow('new-from-media'); @@ -334,7 +331,6 @@ try { row = await chapterRow('new-blank'); assert.deepEqual([row.image_alt, row.image_credit], [null, null]); - // --- Direct edits while the sourced image shows -------------------------- const slug = 'direct'; await insertChapter(slug, { image: '/images/chapters/direct.jpg', @@ -378,7 +374,6 @@ try { row = await chapterRow(slug); assert.deepEqual([row.image_alt, row.image_credit], ['Corrected alt for the second image.', 'Second credit']); - // --- Uploads -------------------------------------------------------------- const firstUpload = await uploadFile(); const secondUpload = await uploadFile(); @@ -455,7 +450,6 @@ try { assert.deepEqual([row.image_alt, row.image_credit], [null, null]); assert.equal(Object.hasOwn((await publicChapter('social-only'))?.media ?? {}, 'imageAlt'), false); - // --- Accepted update requests --------------------------------------------- // Without an image the request describes the image the chapter shows. await acceptRequest(slug, { alt: 'Reviewed alt.' }); row = await chapterRow(slug); @@ -515,7 +509,6 @@ try { assert.deepEqual([row.image_alt, row.image_credit], ['Second accepted alt.', 'Second Photographer']); assert.equal(row.seo.ogImage, social); - // --- Prepared steward sync drafts ------------------------------------------- // The prep script starts a draft from the chapter's current values. Until a // steward edits it, it proposes nothing: accepting it as prepared leaves the // chapter as it was, whether it shows a sourced image or an uploaded one. @@ -569,7 +562,6 @@ try { await sql!`update content.chapter_update_requests set request_status = 'accepted' where id = ${rewritten}::uuid`; assert.deepEqual(await chapterFacts('prepared-upload'), { ...beforeRewrite, summary: 'A summary the steward rewrote.' }); - // --- Alerts --------------------------------------------------------------- // An unreviewed sourced image is withheld; the chapter stays, with one alert. await insertChapter('unreviewed', { image: '/images/chapters/unreviewed.jpg', diff --git a/scripts/directus-text-fields.integration.ts b/scripts/directus-text-fields.integration.ts index 1ac0227..d98365c 100644 --- a/scripts/directus-text-fields.integration.ts +++ b/scripts/directus-text-fields.integration.ts @@ -169,7 +169,6 @@ try { await sql.unsafe(await readMigration(file)); } - // --- Before 033 ------------------------------------------------------------- // Rows shaped like production: a request with its child rows, an initiative, // and a project. await sql`insert into content.chapters ${sql({ slug: 'proof', name: 'Proof chapter' })}`; @@ -201,7 +200,6 @@ try { // An untouched chapter arrived as '' and met the foreign key. assert.equal(await refusal(() => insertInitiative({ slug: 'no-chapter', title: 'No chapter' })), FOREIGN_KEY); - // --- 033 -------------------------------------------------------------------- const beforeMigration = await digest(); await sql.unsafe(textFieldMigration); // Defaults only: no row changes, updated_at included, and no review email queued. @@ -246,7 +244,6 @@ try { assert.equal(await refusal(() => insertInitiative({ slug: 'new-initiative', chapter_slug: 'proof', title: 'New initiative' })), null); assert.equal(await refusal(() => insertProject({ slug: 'new-project', guild_slug: 'proof-guild', name: 'New project' })), null); - // --- Optional fields ------------------------------------------------------------ // An emptied optional field now arrives as '', and its column takes it. const emptied = await refusal(() => sql!` update content.chapter_update_requests diff --git a/scripts/map-node-approval-guard.integration.ts b/scripts/map-node-approval-guard.integration.ts index 38dc0d5..4a3666c 100644 --- a/scripts/map-node-approval-guard.integration.ts +++ b/scripts/map-node-approval-guard.integration.ts @@ -199,7 +199,6 @@ try { await sql.unsafe(await readMigration(file)); } - // --- Rows saved before the guard ------------------------------------------ // Until now an approved node at 0,0 could be saved, as the June 2026 client // did for two nodes PRD-1409 later repaired. const legacyHidden = await insertNode({ status: 'approved', latitude: 0, longitude: 0, place_name: 'Port Harcourt' }); @@ -286,7 +285,6 @@ try { assert.deepEqual(await state(repairedFromZero), ['archived', '0.000000', '0.000000']); assert.deepEqual(await state(repairedFromEdge), ['approved', '90.000000', '97.762610']); - // --- Approving a pending node ---------------------------------------------- // At 0,0: refused with a readable error, and the node stays pending. const pendingAtZero = await insertNode({ latitude: 0, longitude: 0, place_name: 'Rotterdam, Netherlands' }); await assertRefused(() => editNode(pendingAtZero, { status: 'approved' }), pendingAtZero, 'null_island', 'approving at 0,0'); @@ -332,7 +330,6 @@ try { assert.equal(approved.status, 'approved'); assert.ok(approved.approved_at instanceof Date); - // --- Saving an approved node directly --------------------------------------- // Live onboarding and admin edits insert approved rows. Every problem the // shared rule names is refused with the guard's own message, before the // column checks from migrations 001 and 018 would refuse the row less clearly. @@ -357,7 +354,6 @@ try { // Pending rows may still hold 0,0, as the June 2026 client wrote them. await insertNode({ latitude: 0, longitude: 0 }); - // --- Owner update requests --------------------------------------------------- // A request that moves an approved node to 0,0 fails, and stays pending. const movedToZero = await insertNode({ status: 'approved', latitude: 6.5244, longitude: 3.3792, place_name: 'Lagos' }); const moveRequest = await insertUpdateRequest(movedToZero, { latitude: 0, longitude: 0 }); @@ -392,7 +388,6 @@ try { assert.equal(renamedNode.display_name, 'Renamed proof node'); assert.deepEqual(await state(renamed), ['approved', '-16.800000', '180.000000']); - // --- Applying it again ------------------------------------------------------- const settled = await everySubmission(); await sql.unsafe(guardMigration); assert.equal(await everySubmission(), settled, 'replaying the guard changed a stored row'); diff --git a/scripts/map-node-contract.test.ts b/scripts/map-node-contract.test.ts index 57a198b..2811f1d 100644 --- a/scripts/map-node-contract.test.ts +++ b/scripts/map-node-contract.test.ts @@ -3354,7 +3354,6 @@ test('home map inspector: the dock, the sheets and the compact tooltip (map-poli assert.doesNotMatch(component, /shouldRecoverMobileView/); }); -// --------------------------------------------------------------------------- // PRD-1409 (qa-map-data): nodes saved at impossible coordinates. // Live /map/state on 2026-11-06 held these public points. The June 2026 // add-node client produced them: a pin drag clamped to the mini-map edge gave @@ -3363,7 +3362,6 @@ test('home map inspector: the dock, the sheets and the compact tooltip (map-poli // are always refused. An exact edge point is refused from raw coordinates but // accepted from a confirmed place, because real places sit on the 180th // meridian (Fiji). Evidence: .plans/archive/website-qa-2026-11/handoffs/qa-map-data.md -// --------------------------------------------------------------------------- const LIVE_EDGE_POINTS = Object.freeze([ { place: 'Florida', lat: 90, long: 97.76261 }, { place: 'Taiwan', lat: 90, long: 176.912492 }, @@ -3816,7 +3814,6 @@ test('D2: the home map and footer drop the ecoregion layer and its credit', asyn }); // PRD-1409 review follow-ups: PostgreSQL rounding and chapter anchors. -// --------------------------------------------------------------------------- test('coordinates are judged at the six decimal places PostgreSQL stores', () => { // numeric(9, 6) rounds anything finer, so the rule judges the rounded value. diff --git a/scripts/pages-deploy-recovery.test.ts b/scripts/pages-deploy-recovery.test.ts index 22d5993..e911860 100644 --- a/scripts/pages-deploy-recovery.test.ts +++ b/scripts/pages-deploy-recovery.test.ts @@ -98,8 +98,6 @@ test('a re-run is not dated by a job it kept from the earlier attempt', () => { assert.equal(earliestJobStart(jobs, ''), null); }); -// --- Watching ----------------------------------------------------------------- - /** A scripted Pages pipeline on a virtual clock. Tests script GitHub's side through the hooks. */ function simulate(initialRuns: PagesRun[], startAt: string) { const clock = { nowMs: Date.parse(startAt) }; @@ -314,8 +312,6 @@ test('a fresh run that hangs in turn is cancelled and followed by another', asyn assert.equal(watch.startedReplacement, true); }); -// --- GitHub API ---------------------------------------------------------------- - type FakeResponse = { status?: number; body?: unknown }; function fakeGitHub( @@ -523,8 +519,6 @@ test('configuration names what is missing and rejects a malformed repository', ( assert.throws(() => readConfig({ ...env, PAGES_RUN_ID: 'latest' }), /must be a workflow run id/); }); -// --- Workflow wiring ----------------------------------------------------------- - test('the recovery workflow is wired to the Pages workflow it watches', () => { const workflows = new URL('../.github/workflows/', import.meta.url); const pages = readFileSync(new URL('github-pages.yml', workflows), 'utf8'); diff --git a/scripts/snapshot-alert-episodes.integration.ts b/scripts/snapshot-alert-episodes.integration.ts index 806f648..7875ce1 100644 --- a/scripts/snapshot-alert-episodes.integration.ts +++ b/scripts/snapshot-alert-episodes.integration.ts @@ -197,7 +197,6 @@ try { await sql.unsafe(await readFile(resolve(migrationsDir, file), 'utf8')); } - // --- An agent released ahead of the migration ------------------------------ // A merge deploys the agent, and 030 is applied by hand. On the schema before // 030 the agent must keep alerting the way it did. await insertChapter('healthy'); @@ -237,7 +236,6 @@ try { ); assert.equal(alertFailures().some((failure: any) => failure.step === 'open'), false); - // --- Migration 030 --------------------------------------------------------- const beforeMigration = await alertFingerprints(); assert.equal(beforeMigration.allColumns.length, 4); await sql.unsafe(episodeMigration); @@ -262,7 +260,6 @@ try { warnings.length = 0; - // --- Episodes -------------------------------------------------------------- // Production's rows are weeks old by the time 030 lands. The first render // ends the two episodes that were already over and leaves the other two open. await anHourLater(); @@ -313,7 +310,6 @@ try { await render(); assert.deepEqual(await alerts('still-dropped'), ['record_quarantined resolved sent']); - // --- A withheld image on a chapter that is then dropped ---------------------- // The chapter has an open image alert. A mailto: link now drops the chapter. // A dropped chapter is not in the snapshot, so nothing is known about its // image, and the image alert stays open. @@ -354,7 +350,6 @@ try { ]); assert.deepEqual(await deliver(), ['quarantined chapters/just-broken']); - // --- A collection the contract and Directus name differently ----------------- // The alert is stored under the Directus name. A render must look for it // under that same name, or it would end and reopen the episode every time. const reviewed = new Date(); @@ -377,7 +372,6 @@ try { assert.deepEqual(await alerts('proof-initiative'), ['record_quarantined open queued']); assert.deepEqual(await deliver(), ['quarantined chapter_initiatives/proof-initiative']); - // --- Renders at the same moment -------------------------------------------- await insertChapter('raced', { links: mailto }); await Promise.all(Array.from({ length: 8 }, () => render(pool))); assert.deepEqual(await alerts('raced'), ['record_quarantined open queued']); @@ -469,7 +463,6 @@ try { { code: '23514' } ); - // --- A render that changes nothing writes nothing ---------------------------- // The snapshot route is a public read path. Three alerts are open and all of // them still hold, so the render's transaction never needs a transaction id. assert.equal(await openAlertCount(), 3); diff --git a/scripts/ui-verify.ts b/scripts/ui-verify.ts index b2c5a6f..bfaa9ee 100644 --- a/scripts/ui-verify.ts +++ b/scripts/ui-verify.ts @@ -285,7 +285,6 @@ async function waitForExpression(client: CdpClient, sessionId: string, expressio // Non-fatal: continue with whatever rendered (a route may legitimately never settle one channel). } -// ── Route discovery from the built dist (overridable via CLI) ── function discoverRoutes(): string[] { const routes = new Set(); const walk = (absDir: string, urlPrefix: string) => { @@ -309,7 +308,6 @@ function slugFor(route: string): string { return s || 'home'; } -// ── Source CSS standard check ─────────────────────────────────────────────── function sourceFilesToScan(): string[] { const files: string[] = []; const walk = (absDir: string) => { @@ -672,7 +670,6 @@ try { } catch {} `; -// ── Channel 2 — accessibility tree ── async function auditAccessibilityTree(client: CdpClient, sessionId: string): Promise { const out: Violation[] = []; let tree; @@ -809,7 +806,6 @@ async function discoverWebMcp(client: CdpClient, origin: string, routes: string[ } } -// ── Per-route × width verification ── async function verifyRouteAtWidth(client: CdpClient, origin: string, route: string, width: number): Promise { const target = await client.send('Target.createTarget', { url: 'about:blank' }); const attached = await client.send('Target.attachToTarget', { targetId: target.targetId, flatten: true }); From e87778410a32682cb02758b5711af7ede65629ee Mon Sep 17 00:00:00 2001 From: Afolabi <35589781+Oba-One@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:44:23 -0800 Subject: [PATCH 3/5] Comments: narrow purge of the website, HomeMap.astro aside Removes 4 banner comments from packages/website/src/lib/home-map-layout.ts. HomeMap.astro (16 banners) is purged with its split in the Structure phase. Co-Authored-By: Claude Opus 5.5 Agent-Model: claude-opus-5-5/high --- packages/website/src/lib/home-map-layout.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/website/src/lib/home-map-layout.ts b/packages/website/src/lib/home-map-layout.ts index 126f05b..f7d001d 100644 --- a/packages/website/src/lib/home-map-layout.ts +++ b/packages/website/src/lib/home-map-layout.ts @@ -215,7 +215,6 @@ export function formatPickerCoordinate(value: number): string { return Number(fixed) === 0 ? (0).toFixed(6) : fixed; } -// ---- The map's view: what part of the drawing the stage shows ------------- // A stage as wide as the drawing (200 by 88 map units) shows all of it. A // phone's stage is at least 60svh tall (docs/design/map-polish-audit.md § 5), // so it shows the drawing's full height and part of its width, centred on the @@ -292,7 +291,6 @@ export function panMapView(view: MapBox, edge: MapEdge, drawing: MapBox = MAP_DR return { ...view, x: Math.min(Math.max(drawing.x, x), drawing.x + drawing.width - view.width) }; } -// ---- The inspector over the map ------------------------------------------- // docs/design/map-polish-audit.md § 5: "When the node would sit under the // dock, the map pans it into the open area", and on a phone "The map pans // the node above the sheet." The map never resizes, so the view moves: it may @@ -393,7 +391,6 @@ export function pointsBeyondView(view: MapBox, points: readonly MapPoint[]): Rec return { west, east }; } -// ---- Pins on the drawing's edge ------------------------------------------- // docs/design/map-polish-audit.md § 5, "Edge pins": "A valid point on the // map's edge, such as a confirmed place on the 180th meridian, still draws // half outside the drawing. The build keeps the audit's clamp: the rendered @@ -473,7 +470,6 @@ export function badgeFallbackCenter( return keepCircleInside(beside, targetRadius, view, cornerRadius); } -// ---- Labels at rest ------------------------------------------------------- // § 5: "Chapter labels at rest ... The highest featuredWeight goes first. // Each label tries right, left, above and below its dot, and hides when it // would touch another label, a pin, a badge, a bar or the dock." From 7e263367193ce139fdecc4e615e1f97923935a76 Mon Sep 17 00:00:00 2001 From: Afolabi <35589781+Oba-One@users.noreply.github.com> Date: Sat, 21 Nov 2026 13:37:46 -0800 Subject: [PATCH 4/5] Comments: drop the codemod test for Green Goods contract sources It checked packages/contracts/src/tokens/Garden.sol, which exists only in Green Goods; this repository has no deployed contract sources. Co-Authored-By: Claude Opus 5.5 Agent-Model: claude-opus-5-5/high --- scripts/quality/comment-policy.test.mjs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/scripts/quality/comment-policy.test.mjs b/scripts/quality/comment-policy.test.mjs index 8fdf3b4..84f98fb 100644 --- a/scripts/quality/comment-policy.test.mjs +++ b/scripts/quality/comment-policy.test.mjs @@ -148,19 +148,6 @@ test('a NatSpec line and a plain comment under it stay separate comments', () => assert.equal(purgeSource(code, 'Lib.sol').code, '/// @notice Kept.\nuint256 constant X = 1;\n'); }); -test('deployed contract sources are never rewritten', () => { - const out = []; - const log = console.log; - console.log = (line) => out.push(line); - try { - assert.equal(main(['--check', 'packages/contracts/src/tokens/Garden.sol']), 0); - } finally { - console.log = log; - } - assert.match(out.join('\n'), /Would remove 0 comment\(s\) from 0 file\(s\)/); - assert.match(out.join('\n'), /Skipped 1 deployed contract source file/); -}); - test("claims go to the owner's table, a named dependency needs a reason, and a bare mention is narration", () => { const code = [ '// TODO: drop once the indexer ships the field', From a438b8d61399de2caa768fe0b81c16c376236fe3 Mon Sep 17 00:00:00 2001 From: Afolabi <35589781+Oba-One@users.noreply.github.com> Date: Sat, 21 Nov 2026 13:41:26 -0800 Subject: [PATCH 5/5] Comments: read Astro scripts only from the template, unquoted types too A ';", '---', '

{example}

', ''].join( + '\n', + ); + assert.equal(purgeSource(code, 'Example.astro').code, code); +}); + +test('a data script with an unquoted type is left alone', () => { + const code = + '\n\n'; + const { code: purged, removed } = purgeSource(code, 'Data.astro'); + assert.deepEqual( + removed.map((comment) => comment.kind), + ['banner'], + ); + assert.ok(purged.includes('{"imports": {}}')); +});