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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

opened this

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.ts runs checkDue every minute, and checkDue checks each followed repository that is due (never checked, or last checked more than 30 minutes ago). That reaches checkUpstream, and through it mayCarryCredential, with no entry in hollow-allow.ts. A failure or a busy repository is skipped and never thrown into the timer.
  • Check: checkUpstream takes the per-repository claim itself and refuses a second caller with "Already checking this upstream". ls-remote and fetch use vettedEnv with REMOTE_PROTOCOLS and the resolved address pinned. A token goes only to an https: upstream whose URL.origin equals the origin's webUrl origin. 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.

Closes #3977

commented

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.ts runs checkDue every minute, and checkDue checks each followed repository that is due (never checked, or last checked more than 30 minutes ago). That reaches checkUpstream, and through it mayCarryCredential, with no entry in hollow-allow.ts. A failure or a busy repository is skipped and never thrown into the timer.
  • Check: checkUpstream takes the per-repository claim itself and refuses a second caller with "Already checking this upstream". ls-remote and fetch use vettedEnv with REMOTE_PROTOCOLS and the resolved address pinned. A token goes only to an https: upstream whose URL.origin equals the origin's webUrl origin. 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

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:

  1. In ls-remote, refs/heads/main is a tail pattern, so it can also match something like refs/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.
  2. CHECK_REFUSALS.busy has no closing full stop, unlike the others. Fix it so the sentence reads the same at every door.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs