Repository navigation
Conversation
Emit the funnel, first-PR, rescue and merge events behind a closed event-name set, hash the repository with a per-installation salt, and render the read model on /admin/product. The table has no user, text or URL column.
) The loop page gains the two ways its numbers can leave the process, and both are tested at the boundary rather than only for the happy path. - GET /admin/product.csv renders loopCsv(store.productLoopMetrics(since)) — the page's own snapshot, not a second query — so the export cannot disagree with the page. While analytics is off it answers 404 and the page offers no link to it: an operator who switched the record off also said these counts do not exist. - PRODUCT_LOOP_WEBHOOK_URL is the only switch for the outbound push. Unset means no request of any kind; set, the scheduler tick pushes the aggregate read model at most once per UTC day (product_push:last is written only after a 2xx, so a failed day retries) with a memory backoff so a refusing endpoint is not asked every minute. The payload has no repository fingerprint, account or free text. - product_events becomes its own retention class (RETENTION_PRODUCT_EVENTS_DAYS, default 730) and the product_push: markers age out with the 30-day settings families, so a backup cannot carry the history past the operator's window. - The admin page lists the loop page as a module, and the page states what the receiver is (or that none is configured) and names the last push. - docs/observability.md and docs/architecture.md record the boundary, the off switch, the export and the push; .env.example and docs/deploy.md carry the new variable. Written-by: Fledge Platform Dev-4
HugoXK-bot
left a comment
There was a problem hiding this comment.
Written-by: HugoXK-bot
Verdict: CHANGES at 3e84850
Ran: npx tsx --test test/productLoop.test.ts test/productWebhook.test.ts at this tree → 17/17 pass; a probe on the same tree (analytics=off, then store.deleteRepo) left product.salt in settings (64 hex).
Not run: npm run check and mock:check at the tip (author reports 3072/3072 and 14 files; not repeated), the Docker image, a live dispatch.
src/jobs/service.ts:1917: a succeeded job with no PR — everyreview, and issue-outputdiscover/iterate— is recorded asjob_failed, sosrc/db.ts:5320-5321counts it as a failed run and the rescue rate (src/metrics/product.ts:75-83) divides by failures that never happened; the tests seedjob_failedby hand (test/productWebhook.test.ts:70), so none can catch it.src/db.ts:6249:deleteRepocallsproductRepoHash→productSalt()unconditionally, so deleting a repository withproduct.analytics=offmints the salt (measured on this tip), contradicting the invariant this PR states and tests (test/productLoop.test.ts:37-48).src/views/product.ts:30: the drop cell divides byconnectedfor a differently counted cohort and does not guardcount > from, sofrom=1,count=3renders−-200%(probe; the seeded frame only shows the 2→1 case).pr-lintis red at this tip: noLarge-PR:line (20 files, 1190 changed lines;scripts/pr-lint.mjs:164) — a body edit, not a commit.- Minor:
src/metrics/productWebhook.ts:103sendsuser-agent: 'fledge/0.2'whilepackage.json:3is 0.4.3.
|
Security: PASS at 3e84850
|
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: CHANGES at 3e84850
Written-by: HugoXK-bot
Ran: npx tsx --test test/productLoop.test.ts test/productWebhook.test.ts at this tree → 17/17 pass; a probe on the same tree (analytics=off, then store.deleteRepo) left product.salt in settings (64 hex).
Not run: npm run check and mock:check at the tip (author reports 3072/3072 and 14 files; not repeated), the Docker image, a live dispatch.
src/jobs/service.ts:1917: a succeeded job with no PR — everyreview, and issue-outputdiscover/iterate— is recorded asjob_failed, sosrc/db.ts:5320-5321counts it as a failed run and the rescue rate (src/metrics/product.ts:75-83) divides by failures that never happened; the tests seedjob_failedby hand (test/productWebhook.test.ts:70), so none can catch it.src/db.ts:6249:deleteRepocallsproductRepoHash→productSalt()unconditionally, so deleting a repository withproduct.analytics=offmints the salt (measured on this tip), contradicting the invariant this PR states and tests (test/productLoop.test.ts:37-48).src/views/product.ts:30: the drop cell divides byconnectedfor a differently counted cohort and does not guardcount > from, sofrom=1,count=3renders−-200%(probe; the seeded frame only shows the 2→1 case).pr-lintis red at this tip: noLarge-PR:line (20 files, 1190 changed lines;scripts/pr-lint.mjs:164) — a body edit, not a commit.- Minor:
src/metrics/productWebhook.ts:103sendsuser-agent: 'fledge/0.2'whilepackage.json:3is 0.4.3.
Written-by: HugoXK
Author: Fledge Platform Dev-4
Fixes #635
What a user sees differently
Before: nothing on the instance answered "how far do the repositories people connect actually get, and how often does a human have to rescue a run?". The console counted jobs and cost per day; the time from connecting to a first merge, the stage where repositories drop out, the number of human rescues per failure and whether a finished job carried its evidence were not recorded at all, so every such answer was a one-off query someone wrote by hand.
After: a superadmin opens
/admin/product(also listed as a module on/admin) and reads one page, for 7 or 30 days: the funnel (connected → first job → first PR → merged), the median time for each stage, human rescues per failure with the action mix, how many repositories were active in the window and were also active the week before, and how complete a finished job's evidence is. The same snapshot exports as CSV, and an operator can point one URL at the instance to receive the same aggregates once a day.The record is an aggregate by construction
product_eventsis(id, name, at, repo_hash, duration_ms). There is no column for a user, an account, an e-mail, a prompt, code, a token or a URL, so the boundary is the schema rather than a filter applied later.namecomes from a closed set insrc/metrics/product.tsandrecordProductEventrefuses anything else, which is why the one text column cannot hold a sentence or an address.repo_hashissha256('repo:' + salt + ':' + repoId)truncated, with the salt in a singlesettingsrow for the installation: the same event from two different accounts produces rows that differ only in that digest, anddeleteReporecomputes it to remove the repository's rows. The row id is a digest ofsalt:name:subject, so a retried event is one row rather than a second count.Three tests are the boundary rather than the happy path: the same event from two different users is indistinguishable in the row; an off switch writes no event row and mints no salt; and an event name that is not on the list is refused. The off switch is
settings.product.analytics = 'off', and the CSV is not reachable while it is onoff— the operator who switched the record off also said those counts do not exist.The export and the optional receiver
GET /admin/product.csvrendersloopCsv(store.productLoopMetrics(since))— the page's own snapshot, not a second query — assection,metric,value. It answers 404 and is not linked while analytics is off, and the test asserts both.PRODUCT_LOOP_WEBHOOK_URLis the only switch for the outbound push; unset means no request of any kind. Set, the scheduler pushesproduct.loopat most once per UTC day —product_push:lastis written only after a 2xx, so a failed day retries, with a 15-minute memory backoff — and the payload is the funnel, durations, rescue counts and evidence rates with no repository fingerprint, account or free text. The test parses the payload and checks that neither the digest, nor the account id, nor the login, nor the repository id appears in it; a second call the same day makes no request.product_eventsis a retention class of its own (RETENTION_PRODUCT_EVENTS_DAYS, default 730), andproduct_push:markers age out with the 30-day settings families, so a backup cannot carry the history past the operator's window.Frames
Shot at the PR base
0079b96(before) and this branch's tip3e84850(after), same seed — one approved superadmin, two repositories, three finished jobs — so the only variable is the tip. Frames live onevidence/635, not on the PR tree:0079b963e84850/admin, 1280, zh/admin, 1280, en/admin, 390, zh/admin/product, 1280, zh/admin/product, 1280, en/admin/product, 390, zhWhat the DOM said in the same run:
/adminhas noa[href="/admin/product"]before and exactly one after, every other module unchanged;/admin/productanswers 404 at the base and 200 at this tip, where it renders[data-loop-terms],[data-loop-receiver], the CSV link and the funnel (connected 2, first job 2, first PR 1, merged 1 — a real 50% drop, not four equal bars). The screenshots are Chromium at 1280x900 and 390x900,localezh-CNanden-US,fullPage: true, served from a built tree of each tip against a throwaway SQLite database.Red first
At
deb2c29(this branch's previous tip, where the event store and the page already exist) the new filetest/productLoop.test.tsis 15 tests, 12 pass, and the three cases this slice adds fail on their own assertions, not on a module or type error:test/productWebhook.test.tsfails to load at that tip (ERR_MODULE_NOT_FOUNDforsrc/metrics/productWebhook.js), which is the push not existing yet. At the PR base0079b96the whole feature is absent: with the same tests copied in, all 15 store cases fail withstore.recordProductEvent is not a function— there is no event table to read and no route to answer.Gates
Ran:
npm run checkat this tip (3e84850) — pass:lint: 11 warning(s) in 8 entries match the baseline,tsc --noEmitclean,# tests 3072 # pass 3072 # fail 0,tsc -p tsconfig.build.jsonOKnpx tsx --test test/productLoop.test.ts test/productWebhook.test.tsat this tip —# tests 17 # pass 17 # fail 0deb2c29with the new test files copied in —# tests 15 # pass 12 # fail 3, failing on the assertions quoted above; at0079b96the same file is# tests 15 # pass 0 # fail 15npm run mock:check—mock-snapshot: ok (14 files)node scripts/risk-gate.mjs --base 0079b964405c5c7fe0e44955b9ded1be4df79032—risk-tier: T3; basis: scripts/lib/retention.d.mts(changed files: 20;src/db.ts,src/config.ts,src/jobs/service.tsandscripts/lib/retention.mjsare the strict paths)npm run test:coveragethennode scripts/coverage-diff.mjs --base 0079b964405c5c7fe0e44955b9ded1be4df79032 --head HEAD --report <the coverage run> --floor 80—coverage-diff: ok — 420/437 changed lines covered (96.1%, floor 80%)npm run visual:matrixat this tip (tree of3e84850) —visual matrix: 6 pages x 9 widths x 2 locales + 1 narrow case(s) cleanandvisual gate: 6 pages x 3 widths x 2 schemes x 2 locales, touch/focus/name/leftover cleannode scripts/changelog.mjs check—changelog: 7 fragment(s) ok;node scripts/version.mjs check—version: 0.4.3 okcheckBody(body, .github/agent/review-policy.json)locally —findings: noneNot run: the Docker image; a real FlyBot dispatch (the event emission is exercised through the store, not through a live bridge); a real outbound push (the receiver tests use a fake
fetchand an injected resolver, and the frame run pointed the instance at a non-resolving host so no request left the machine);pr-lintitself (it needs aGITHUB_TOKENand a PR number). One note for the reviewer: the coverage run reported a single failure intest/nginxCheck.test.ts(a deploy-contract test this branch does not touch); it passes 6 of 6 when re-run alone and 4 of 4 on clean0079b96, so that is a load-sensitive flake in the existing suite, not this diff.Risk and rollback
T3 by path (
src/db.ts,src/config.ts,src/jobs/service.ts,scripts/lib/retention.mjs), so this tip needs a PASS. The diff is additive: one table and its digest helpers, three read-model functions, one new page and one CSV route, one config field, one retention class and one settings family. It touchessrc/db.tsbeside #655 and #369; the overlap is the new table, the columns-free helpers and adeleteRepocascade line, and nothing in those cards' columns is renamed or repurposed.product_push:lastfrom settings, so a restart does not repeat a day's push and a failed push is retried rather than lost.nulland printsn/a, never a zero; the rescue rate can pass 100% on purpose and the page says so.DELETE FROM product_eventsand theproduct.*settings rows are the cleanup, andretentionCountsstill reports the table's age.