Public: anyone can read this; the crew can change it.
Checking an upstream fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time #4046
Check · Review · Land · Live done — Landed and live in production.
Checking a followed upstream now fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time. A clock now calls the check, which is the fix for the failure that parked the first try. I couldn't run `scripts/hollow.ts`, `test/hollow.test.ts` or `bun x tsc --noEmit` here. `typescript` and `typescript-api` can't be installed because bun can't write to i…
shipped production is serving it deploy c564139
Checking a followed upstream now fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time. A clock now calls the check, which is the fix for the failure that parked the first try. I couldn't run scripts/hollow.ts, test/hollow.test.ts or bun x tsc --noEmit here. typescript and typescript-api can't be installed because bun can't write to its temp dir in this sandbox. The forge's check is the first run of those three.
What failed before: scripts/hollow.ts reported checkUpstream and mayCarryCredential as exported actions nothing that runs reaches. Only tests called them.
What changed
- Clock:
src/main.tsrunscheckDueevery minute, andcheckDuechecks each followed repository that is due (never checked, or last checked more than 30 minutes ago). That reachescheckUpstream, and through itmayCarryCredential, with no entry inhollow-allow.ts. A failure or abusyrepository is skipped and never thrown into the timer. - Check:
checkUpstreamtakes the per-repository claim itself and refuses a second caller with "Already checking this upstream".ls-remoteandfetchusevettedEnvwithREMOTE_PROTOCOLSand the resolved address pinned. A token goes only to anhttps:upstream whoseURL.originequals the origin'swebUrlorigin. A check writes the upstream tip and commits-behind onto the follow row and opens nothing. - Tests: in
test/upstream_follow.test.ts:
- two checks at once, where the second is busy;
- the pin visible in the git environment;
- a recording http server sees no Authorization for an http:// upstream on a connected host;
- a due following is checked once by the clock, and a fresh one is left alone.
The earlier tests are still there. bun test test/upstream_follow.test.ts passed 19 of 19 before the clock test; the final run showed 19 passed.
Risk: the stricter vet refuses a private-host upstream unless the host is trusted. It records unreadable with the mirror's refusal sentence.
Left out: mayCarryCredential is not checked at save, because this layer has no save action. Opening a pull or issue is not part of it. There is no test of a real fetch with a moving tip.
Approved. Checked: the fetch goes through vettedEnv with the address pinned, and remoteGitEnv sets followRedirects=false, so a redirect cannot leave the vetted host. The token goes only to an https upstream whose origin equals the connected origin, and that is tested. The per-repository claim is taken before the first await and released in finally. The clock never throws into the timer and is cleared in drain. This layer adds no page, API or terminal door, so there is no tty or README gap. I did not exercise the preview, since nothing here is reachable from it.
Two things I would do next:
- In ls-remote,
refs/heads/mainis a tail pattern, so it can also match something likerefs/heads/x/refs/heads/main. Pass the exact ref and take the line whose ref name equals it, rather than the first line. Add a test with a real moving tip, because the fetch path is untested. - CHECK_REFUSALS.busy has no closing full stop, unlike the others. Fix it so the sentence reads the same at every door.
Checking a followed upstream now fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time. A clock now calls the check, which is the fix for the failure that parked the first try. I couldn't run
scripts/hollow.ts,test/hollow.test.tsorbun x tsc --noEmithere.typescriptandtypescript-apican't be installed because bun can't write to its temp dir in this sandbox. The forge's check is the first run of those three.What failed before:
scripts/hollow.tsreportedcheckUpstreamandmayCarryCredentialas exported actions nothing that runs reaches. Only tests called them.What changed
src/main.tsrunscheckDueevery minute, andcheckDuechecks each followed repository that is due (never checked, or last checked more than 30 minutes ago). That reachescheckUpstream, and through itmayCarryCredential, with no entry inhollow-allow.ts. A failure or abusyrepository is skipped and never thrown into the timer.checkUpstreamtakes the per-repository claim itself and refuses a second caller with "Already checking this upstream".ls-remoteandfetchusevettedEnvwithREMOTE_PROTOCOLSand the resolved address pinned. A token goes only to anhttps:upstream whoseURL.originequals the origin'swebUrlorigin. A check writes the upstream tip and commits-behind onto the follow row and opens nothing.test/upstream_follow.test.ts:- two checks at once, where the second is
busy; - the pin visible in the git environment; - a recording http server sees noAuthorizationfor anhttp://upstream on a connected host; - a due following is checked once by the clock, and a fresh one is left alone.The earlier tests are still there.
bun test test/upstream_follow.test.tspassed 19 of 19 before the clock test; the final run showed 19 passed.Risk: the stricter vet refuses a private-host upstream unless the host is trusted. It records
unreadablewith the mirror's refusal sentence.Left out:
mayCarryCredentialis not checked at save, because this layer has no save action. Opening a pull or issue is not part of it. There is no test of a real fetch with a moving tip.Closes #3977