Repository navigation
feat(meter): sk-meter moves here as workers/meter, deployed by deploy.yml's meter job - #103
Conversation
….yml's meter job The billing guard's code (src, allowances, tests, baseline and offline drill) moves from the retiring control repository at c1e3253, plan v6 F3. Same Worker name, cron and KV binding; its settings still come from the Infisical sync. deploy.yml gains a meter job that deploys it with this repo's token, checks the live version and rolls back in the job. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head ac8e3e5.
No merge blockers found, so I'm approving.
What I checked and how
- Checks:
validateandvisual-diffboth finished withsuccesson the head (github.json.checks). - Acceptance criteria: I did not check these. The PR closes no issue (
.closing_issuesis empty). Its body saysRefs setkernel/hq#1449, which is allowed for partial work, and this run has no access to hq to read that issue's criteria or its## Files likely touched. I checked the PR against what its own body says it does:workers/meter/is added: Worker,allowances.json, tests,tools/,wrangler.toml(namesk-meter, cron7 * * * *,GUARDKV binding,keep_vars = true, no[vars]).package.jsonaddstest:meter.checknow coversworkers/meter/src/*.jsandworkers/meter/tools/*.mjs.validaterunstest:meterand dry-runs both Workers.deploy.ymladds themeterjob and passes its result toreport.AGENTS.mdandworkers/meter/README.mddocument both.
- Tests: I ran
node --teston the sixworkers/meter/test/*.test.jsfiles locally (Node v24.21.0):tests 81, pass 81, fail 0. This matches the PR body. I did not runtools/drill.mjs, because it is code the PR adds and is not part ofvalidate. - The
meterjob (.github/workflows/deploy.yml:212-266), read line by line:- It needs
check, so it only runs on main aftervalidatepasses. - It asks for
id-token: writeandcontents: readand nothing else. npm ci --ignore-scriptsruns before the token is fetched, and the job runs only lockfile wrangler (4.146.0).- wrangler runs under
env -iwith onlyPATH,HOME,CI,WRANGLER_SEND_METRICSandCLOUDFLARE_API_TOKEN. The OIDC request variables and the page'sGITHUB_WEBHOOK_SECRET/BUZZ_PRIVATE_KEYnever reach it. - The script runs under bash's
-e. A failedwrangler deployorwrangler rollbackfails the job.live()andversions viewfailures turn into empty strings, which the script handles: a mismatch triggers a rollback, and an emptybeforeexits 1. The final[ ] && … || …is exempt from-e, soexit 1is reached. --config workers/meter/wrangler.tomlis appended after the arguments of every wrangler call.deployments status,versions view,deployandrollbackall accept the global--config.
- It needs
- Security (R3): the Infisical step and identity are the same as
deployandrollback.wrangler.tomlhas no build command, so the job runs no repo code. It sets no vars or secrets on the Worker (keep_vars = true).- I searched the added lines for credentials and found none. The only token-like value is the test fake
CF_ANALYTICS_TOKEN: "test-token"inworkers/meter/test/fakes.js. - The KV namespace id and the Infisical identity id are identifiers, not secrets, and the identity id is already public in this file.
- What goes live on merge: the next push to main deploys sk-meter from this repo, and every push after it redeploys it. The PR body says so plainly.
- I searched the added lines for credentials and found none. The only token-like value is the test fake
- Prompt injection: I found no text in the PR or the code that tries to direct the review.
Not checked
- hq
tools/check-deploy-contract.py --repo setkernel-liveagainst the new job.AGENTS.mdsays this workflow must keep passing it, but this run has no hq checkout. - Whether the
setkernel-live-deployInfisical identity accepts a token from a job other thandeployandrollback. The PR says the identity is bound to the workflow file, not to a job. I can't see the identity's settings, and the first push to main will show whether it is right. - Whether the Workers Editor token can deploy a script with a cron trigger and a KV binding on
sk-meter. The first deploy will show this too.
Nits (non-blocking)
AGENTS.md:40-41still says the identity accepts the workflow "in thedeployandrollbackjobs only". Themeterjob now uses it as well. The header comment atdeploy.yml:10was updated, but this line was not.deploy.ymlreport:- If sk-meter's rollback fails, or nothing was live to roll back to, the issue is labelled
agent-readyonly. The page's failed rollback addsowner, which is the contractAGENTS.mddescribes. - The body also says "Nothing was rolled back: no smoke failed after a deploy." even when
meterdid roll back. - Consider writing a step output from
meter(for examplerolled-backorrollback-failed) and addingownerwhen the guard may be left broken.
- If sk-meter's rollback fails, or nothing was live to roll back to, the issue is labelled
deploy.yml:249: ifwrangler deployuploads and deploys the version but then fails (for example while updating the cron trigger),-eexits before the check, so nothing rolls back. The job still fails andreportopens the issue. Wrapping the deploy aswrangler deploy … || deploy_failed=1and running the check either way would cover this.deploy.yml:264: the line saying the rollback succeeded is printed as::error::.::notice::would make the annotations easier to read, since the job still exits 1.
rigel-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head ac8e3e5.
What I checked and how
-
Checks:
validateandvisual-diffboth completed with success on the head. -
Acceptance criteria: not checked. The PR closes no issue (
closing_issuesis empty). It only saysRefs setkernel/hq#1449, and this run can't read that issue. I reviewed the PR against what its own body promises. -
Scope: not checked against a
## Files likely touchedlist, for the same reason. The 22 files match what the body describes:workers/meter/**,deploy.yml,package.jsonandAGENTS.md. -
Tests:
node --test workers/meter/test/*.test.js(thetest:meterscript) gavetests 81, pass 81, fail 0locally on Node v24.21.0. npm isn't on this runner, so I didn't runnpm run validatemyself. CI'svalidatecovers it, including thenode --checkloop and both dry-runs. -
Test-diff guard:
git diff origin/main...HEAD --diff-filter=MDlists onlydeploy.yml,AGENTS.mdandpackage.json. No existing test is edited or deleted, so noallow-test-changes:line is needed. -
Secrets: none added. The KV namespace id, the Infisical identity id (already in
deploy.yml) and the alert URL are identifiers, not secrets. I found no instructions aimed at reviewers in the PR text or code. -
Security (R3: a deploy workflow and the deploy token): I read the whole
meterjob.- It runs
npm ci --ignore-scripts, so no install scripts run. - The token is fetched with the same pinned action and identity as
deployandrollback. - wrangler runs under
env -iwith onlyPATH,HOME,CIandCLOUDFLARE_API_TOKEN. That drops the OIDC request variables and the page's two Worker secrets. workers/meter/wrangler.tomlhas no[build]command, so the deploy bundles the code without running it.keep_vars = trueand no[vars]block, so a deploy can't wipe what the Infisical sync set.
- It runs
-
Correctness: I traced every exit path of the meter job's script (
deploy.yml:244-267) and thereportjob. -
Not checked:
- whether the
setkernel-live-deployInfisical identity accepts a third job; - whether hq
tools/check-deploy-contract.py --repo setkernel-livestill passes with the new job (AGENTS.md says it must); - whether
env -idrops anything the self-hosted runner needs, such as a proxy or CA variables.
I have no access to hq, Infisical or the runner. Each of these would show up on the first push to main.
- whether the
Blocker
1. A failed sk-meter rollback never adds owner to the issue, and the issue says nothing was rolled back.
The meter job fails in three ways:
- The new version isn't live, and the job rolls back (
deploy.yml:263-266). - The rollback itself fails (
wrangler rollbackunderbash -e, or the "doesn't serve all traffic" branch at:265). - No version was live before (
:259-262).
In every case the page's rollback and smoke-again were skipped, so report reaches case "${ROLLBACK}:${SMOKE_AGAIN}" with skipped:skipped. That falls to the *) branch (deploy.yml:306-307), which sets rolled="Nothing was rolled back: no smoke failed after a deploy." and leaves more='[]' (:292).
So when sk-meter's rollback fails, sk-meter may be left on an unknown version: neither this run's nor the previous one. The issue then:
- states something false ("Nothing was rolled back");
- carries only
agent-ready.
That breaks this repo's deploy contract. AGENTS.md "Deploy" and the workflow header both say the issue gets owner too if the rollback fails. For sk-meter that matters more than for the page, because it's the billing guard.
The meter ${METER} (… its log says whether it rolled back) text added to the body doesn't fix this: the label and the rolled sentence are still wrong.
Suggested fix:
- Have the meter step write an output, for example
rollback=none|done|failed, to$GITHUB_OUTPUTbefore eachexit 1. - Pass it to
report. - Add
ownerwhen it isfailed, or when nothing was live before. - Word the
rolledtext for sk-meter separately, so it doesn't claim that nothing was rolled back.
Nits (non-blocking)
AGENTS.md:40-41still says the identity accepts the workflow "in thedeployandrollbackjobs only". The PR body says the identity is bound to the workflow file, not to a job, and this PR adds a third job that uses it. That sentence is now stale.workers/meter/tools/drill.mjs:2says "(make drill)", but this repo has no Makefile. The README's command isnode workers/meter/tools/drill.mjs.workers/meter/tools/baseline.mjs:15says "CI: thebaselineworkflow (workflow_dispatch)". Per the README and the PR body, that workflow wasn't moved and retires with the old repository.- The meter job's "is it live" test only checks that the
deploy <sha>version serves all traffic. It can't catch a version whose cron throws. The README points to sk-watch for failed cron events. Consider naming that in thedeploy.ymlheader too, so nobody reads the job as a smoke check.
The meter step records rollback=not-deployed|nothing-live|done|failed through an EXIT trap, and report words sk-meter's outcome on its own line and adds owner when the rollback failed or nothing was live to roll back to. Before, report saw the page's skipped:skipped and said nothing was rolled back (review on #103). Also: AGENTS.md says the identity is bound to the file, and two stale comments in the meter tools. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fixed in ff1841f, for rigel-setkernel's blocker. The meter step now records
Nits 1 to 4 are fixed too. The header now says the meter check is not a smoke and that sk-watch covers a cron that throws. — Claude Lead |
rigel-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head ff1841f.
This re-review covers ff1841f, the fix for the blocker in my review of ac8e3e5. That blocker is fixed, and I found no new ones, so I'm approving.
What I checked and how
- Checks:
validateandvisual-diffboth finished withsuccessonff1841f(github.json.checks). - Base: the head is up to date with
main.git merge-base origin/main HEADequalsorigin/main(443bd06). - What changed since my last review: I ran
git diff ac8e3e5 HEAD. It touches four files:deploy.yml(+44/-4),AGENTS.md, and one comment line each inworkers/meter/tools/drill.mjsandworkers/meter/tools/baseline.mjs. No test file changed. The tools changes are comment-only. - Acceptance criteria and scope: I did not check these, for the same reason as last time. The PR closes no issue (
closing_issuesis empty) and onlyRefs setkernel/hq#1449, which this run can't read. The 22 changed files still match what the PR body describes. - Test-diff guard:
git diff origin/main...HEAD --diff-filter=MDstill lists onlydeploy.yml,AGENTS.mdandpackage.json. Noallow-test-changes:line is needed. - Secrets and injection: the fix adds no credentials. I found nothing in the PR text, comments or code that tries to steer the review.
- YAML:
deploy.ymlparses.meter.outputs.rollbackis${{ steps.meter.outputs.rollback }}, andreportreads it asMETER_ROLLBACK: ${{ needs.meter.outputs.rollback }}.
The previous blocker is fixed
I traced every exit path of the meter step (deploy.yml:251-284). The script starts with state=not-deployed and an EXIT trap that writes rollback=${state} to $GITHUB_OUTPUT. The trap runs in the outer shell, not under env -i, so it can see GITHUB_OUTPUT. It fires on both bash -e failures and explicit exits.
| Path | state |
report result (:330-343) |
|---|---|---|
wrangler deploy fails (:262) |
not-deployed |
text only, agent-ready |
Live version is this run's (:266-269) |
empty | job passes; *) gives empty text |
No version was live before (:272-275) |
nothing-live |
owner |
wrangler rollback fails under -e (:277) |
failed (set at :263) |
owner |
Rollback doesn't take (:281-284) |
failed |
owner |
Rollback takes (:278-280) |
done |
text only |
- The
[ "$(live)" = "$before" ]test now sits inside anif, so a failinglivecan't trip-e. - The meter
caseonly ever setsmore='["owner"]'and never clears it, so anownerfrom the page's owncaseis kept. - The page's fallback text now reads "The page: nothing was rolled back, because no smoke failed after its deploy." It no longer speaks for sk-meter. The issue gets a separate
${meter_text}line.
AGENTS.md:40-47 and the header comments at deploy.yml:10 and :286-289 now match the code. My earlier nits 1 to 4 are fixed (AGENTS.md:40-42, drill.mjs:2, baseline.mjs:15, deploy.yml:212-213).
Not checked
- I did not run the step under a fake wrangler myself. Review mode blocked my own small bash script, so the table above comes from reading the code. The author's comment reports a local run of all six cases.
- Whether the
setkernel-live-deployidentity accepts themeterjob, and whether hqtools/check-deploy-contract.py --repo setkernel-livepasses. I have no hq or Infisical access. The first push tomainwill show both.
Nits (non-blocking)
deploy.yml:262and:332:wrangler deploycan fail after the new version is already live, for example while it updates the cron trigger.stateis stillnot-deployedat that point, so the issue says "the deploy failed before anything changed, so the version live before still serves", and that may not be true. This is vega-setkernel's earlier nit 3. Either setstateto something likedeploy-failedwith softer wording ("may or may not have changed; readwrangler deployments status"), or wrap the deploy aswrangler deploy … || deploy_failed=1and run the live check either way.deploy.yml:279: the success line "rolled back to …, which serves all traffic again" is still an::error::annotation.::notice::would be clearer, since the step exits 1 anyway.deploy.yml:288-289: after the reflow, "The runner image has curl and jq" / "but no gh." wraps at an odd point.
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head ff1841f.
I re-reviewed the PR at ff1841f, after my approval of ac8e3e5 was dismissed by the push. I found no merge blockers, so I'm approving.
What I checked and how
- Checks:
validateandvisual-diffboth finished withsuccessonff1841f(github.json.checks). - Base: the head is up to date with main.
git merge-base origin/main HEADandorigin/mainare both443bd06. - What changed since my last review:
git diff ac8e3e5 HEADtouchesdeploy.yml(+44/-4),AGENTS.md, and one comment line each inworkers/meter/tools/drill.mjsandbaseline.mjs. No test file changed. - Acceptance criteria and scope: not checked. The PR closes no issue (
.closing_issuesis empty). It saysRefs setkernel/hq#1449, and this run can't read that issue's criteria or its## Files likely touched. I checked the PR against what its body says it does. The 22 changed files are what the body describes:workers/meter/**,deploy.yml,package.jsonandAGENTS.md. - Tests: I ran
node --test workers/meter/test/*.test.js(thetest:meterscript) on Node v24.21.0:tests 81, pass 81, fail 0.- npm isn't on this runner, and the sandbox wouldn't let me run the
node --checkloop. CI'svalidatepassed, and it covers both, plus the two dry-runs.
- npm isn't on this runner, and the sandbox wouldn't let me run the
- Test-diff guard:
git diff origin/main...HEAD --diff-filter=MD --name-onlylists onlydeploy.yml,AGENTS.mdandpackage.json. No existing test is edited or deleted, so noallow-test-changes:line is needed. - Secrets: I grepped the added lines for secret, token, password and key. There are no credentials. The hits are variable names, comments, and the test fake
"test-token". The KV namespace id and the Infisical identity id are identifiers, not secrets. - Prompt injection: nothing in the PR text, comments or code tries to steer the review.
The meter step and report (deploy.yml:251-284, :313-347)
I read every exit path. The script starts with state=not-deployed and an EXIT trap that writes rollback=${state} to $GITHUB_OUTPUT.
- The trap runs in the outer shell, not under
env -i, so it can seeGITHUB_OUTPUT. It fires on-efailures and on explicitexit. state=failedis set right afterwrangler deploysucceeds. So a failedwrangler rollbackunder-ereportsfailed, andreportaddsowner.- Each path ends as follows:
- nothing was live before:
nothing-live, plusowner; - the rollback took:
done; - the rollback didn't take:
failed, plusowner; - the job passed: empty, and
meter_text="".
- nothing was live before:
[ "$(live)" = "$before" ]sits inside anif, so a failinglivecan't trip-e.before=$(live) || before=andmessage=$(…) || message=survivepipefail.- The meter
caseonly ever setsmore='["owner"]'. It never clears anownerthat the page'scaseset. - The page's fallback text now speaks only for the page.
live()and theversions viewjq filters are the same as the page'sdeployjob on main (deploy.yml:105,:108). That job already parses wrangler's JSON successfully.- wrangler runs under
env -iwith onlyPATH,HOME,CI,WRANGLER_SEND_METRICSandCLOUDFLARE_API_TOKEN. That drops the OIDC request variables and the page's Worker secrets. npm ci --ignore-scriptsruns before the token is fetched.workers/meter/wrangler.tomlhas no build command,keep_vars = true, and no[vars].
This fixes rigel-setkernel's blocker and nit 2 from my earlier review. AGENTS.md:40-47 and the header comments at deploy.yml:10 and :286-289 now match the code.
Security (R3)
- What goes live on merge: the next push to main deploys sk-meter from this repo, and every later push redeploys it. The PR body says this plainly.
- An owner-path PR also needs Raghav's approval, but he opened this one.
Not checked
- I didn't run the step under a fake wrangler. It is workflow code from the PR, and this mode runs only the repo's checks. The trace above comes from reading the code. The author's comment reports a local run of all six cases.
- Whether the
setkernel-live-deployInfisical identity accepts themeterjob. - Whether hq
tools/check-deploy-contract.py --repo setkernel-livepasses with the new job (AGENTS.mdsays it must). - Whether the Workers Editor token can update sk-meter's cron and KV binding.
This run has no access to hq or Infisical. The first push to main will show all three.
Nits (non-blocking)
- This is still my earlier nit 3.
wrangler deploycan fail after the new version is already live, for example while it updates the cron trigger (deploy.yml:262).stateis stillnot-deployedat that point, so the issue says the version live before still serves (:332). That may be false. Two possible fixes:- soften that text;
- or run the deploy as
wrangler deploy … || deploy_failed=1and do the live check either way.
deploy.yml:279: the success line "rolled back to …, which serves all traffic again" is still an::error::.::notice::would read better, since the step exits 1 anyway.- The issue body still ends with
README "Reading a failed smoke"(deploy.yml:350). A meter-only failure has no smoke, so pointing it atworkers/meter/README.mdwould help the agent that picks it up.
# Conflicts: # AGENTS.md # package.json
# Conflicts: # workers/meter/README.md # workers/meter/src/notify.js # workers/meter/test/notify.test.js # workers/meter/wrangler.toml
…l relay (#105) * feat(meter): sk-meter moves here as workers/meter, deployed by deploy.yml's meter job The billing guard's code (src, allowances, tests, baseline and offline drill) moves from the retiring control repository at c1e3253, plan v6 F3. Same Worker name, cron and KV binding; its settings still come from the Infisical sync. deploy.yml gains a meter job that deploys it with this repo's token, checks the live version and rolls back in the job. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(meter): alerts carry { title, message } for the ops Worker's email relay The buzz-alerts bridge sk-meter posted to was removed in hq#1261, so its alerts have nowhere to go. The body now also carries title and message, which the ops Worker's POST /alert emails (plan v6 E3b). The old fields stay, so nothing breaks before the Worker's two settings change. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(deploy): a failed sk-meter rollback reaches the issue, with owner The meter step records rollback=not-deployed|nothing-live|done|failed through an EXIT trap, and report words sk-meter's outcome on its own line and adds owner when the rollback failed or nothing was live to roll back to. Before, report saw the page's skipped:skipped and said nothing was rolled back (review on #103). Also: AGENTS.md says the identity is bound to the file, and two stale comments in the meter tools. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…oyed (#104) * feat(meter): sk-meter moves here as workers/meter, deployed by deploy.yml's meter job The billing guard's code (src, allowances, tests, baseline and offline drill) moves from the retiring control repository at c1e3253, plan v6 F3. Same Worker name, cron and KV binding; its settings still come from the Infisical sync. deploy.yml gains a meter job that deploys it with this repo's token, checks the live version and rolls back in the job. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(status): sk-status's code moves here as workers/status, not deployed The /status read model (Board Durable Object, views, Access check, phone page) moves from the retiring control repository at c1e3253, plan v6 F3, with its tests. It has never been deployed and its only writer is being retired, so nothing deploys it here; its README lists the first deploy's owner steps if the page is wanted. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(deploy): a failed sk-meter rollback reaches the issue, with owner The meter step records rollback=not-deployed|nothing-live|done|failed through an EXIT trap, and report words sk-meter's outcome on its own line and adds owner when the rollback failed or nothing was live to roll back to. Before, report saw the page's skipped:skipped and said nothing was rolled back (review on #103). Also: AGENTS.md says the identity is bound to the file, and two stale comments in the meter tools. Refs setkernel/hq#1449 — Claude Lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Refs setkernel/hq#1449 (plan v6 box F3, setkernel/hq#1247): Raghav decided on 2026-11-09 that the status and meter code leaves the retiring control repository for this one. This is the meter half. sk-status follows in its own PR.
What changes
workers/meter/: sk-meter's Worker code,allowances.json, its tests,tools/baseline.mjsand the offline drill, copied from that repository'smeter/atc1e3253. The only edits are to comments and test data, so they no longer name the private repository. The Worker name, cron (7 * * * *) andGUARDKV binding are unchanged. Its settings still come from the Infisical sync, which targets the Worker by name.Not moved: the Workers Logs
readingstool and thebaselineand livedrillworkflows. Each reads Infisical through an identity bound to a workflow file in that repository, so they retire with it. The README says so..github/workflows/deploy.yml: a newmeterjob aftercheck, using the samesetkernel-live-deployidentity. That identity is bound to this workflow file on main, not to a job. The token is Workers Editor on the account, so it can deploy an existing Worker and bind an existing KV namespace. The job:--config workers/meter/wrangler.toml;deploy <sha>serves all traffic;reportopens the issue.wrangler runs under
env -iwith the token alone, so the page's two Worker secrets never reach sk-meter.package.json:test:meter,checkcoversworkers/meter, andvalidateruns both and dry-runs both Workers.AGENTS.md: what the repo holds, the commands, the deploy and the layout.
What merging does
Merging deploys sk-meter live from this repo on the next push to main. Every later push redeploys it, as it does the page. The sk-meter that is live now was deployed from the old repository. Its PR there (removing
meter/and the deploy workflows) should merge after this one has deployed once.Checks
npm run validatelocally (Node 24, macOS): it passed. That covers check,npm test,test:worker,test:meter(81 tests, 0 failing), and a dry-run of both Workers. The sk-meter dry-run showsenv.GUARD (f79ca12aeb9347f9851f5dfd53313f39) KV Namespace.node workers/meter/tools/drill.mjsprinteddrill: passed.hqandsetkernel-cloudflare, which this repo already names, and the Infisical project slugsk-ctl-workers, which the Worker's settings live in.Risk class
R3: it changes a deploy workflow and puts a second Worker on this repo's deploy token. Rollback: revert this PR. sk-meter keeps its last version, and its cron keeps running.
— Claude Lead
🤖 Generated with Claude Code