Files
loki/scripts/test/hosted-builder-pref.ts
CatoandClaude Fable 5.1 f7c4e35fdc feat(builder): a project can pin its work to the hosted runner — no Claude credential needed (#718)
builder_pref gains a third value, 'hosted'. A project pinned to it never
touches a runner PTY: the dispatch goes straight to the hosted runner
(Hermes in its own clone on the box, on the providers the box already holds
keys for — Copilot, Gemini, Groq), and the hosted runner closes the tracked
run with the pull request as evidence, so the outcome reaches the thread
that asked, like any other run.

Why now: the box's Claude Code credential died silently and every
self-dispatch hung, while Hermes on the same box answered fine. The
unattended path should not depend on a person's Claude subscription at all.

- statuses.ts: HOSTED_BUILDER_PREF / BUILDER_PREFS (channels stay what they
  were — nothing claims 'hosted' from a queue); API enum widened.
- inject-core: hosted branch before the channel pin; run id travels in the
  hosted_dispatch payload.
- hosted-runner: closeHostedRun() through updateOrchestrationRun (outcome
  turn, ledger, escalation bookkeeping all fire); delivered stamp at claim.
- Control → project profile → Runs on: third choice with its explanation.
- docs/development/cloud-local-workflows.md: the tier in the SSOT table.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 22:43:29 -07:00

46 lines
1.5 KiB
TypeScript

/**
* The hosted builder preference (lib/constants/statuses.ts + execution-access).
*
* "hosted" is a stored preference, not a runner channel: nothing claims it from
* a PTY queue, so the channel helpers must keep ignoring it while the API and
* the profile chooser accept it.
* Run: npx tsx scripts/test/hosted-builder-pref.ts
*/
import assert from "node:assert/strict";
import {
BUILDER_CHANNELS,
BUILDER_PREFS,
HOSTED_BUILDER_PREF,
isBuilderChannel,
isHostedBuilderPref,
DEFAULT_BUILDER_CHANNEL,
} from "@/lib/constants/statuses";
import { pickDispatchChannel } from "@/lib/execution-access";
let pass = 0;
function check(name: string, fn: () => void) {
fn();
pass++;
console.log(` ✓ ${name}`);
}
check("hosted is a preference the API accepts", () => {
assert.ok((BUILDER_PREFS as readonly string[]).includes(HOSTED_BUILDER_PREF));
assert.equal(isHostedBuilderPref("hosted"), true);
assert.equal(isHostedBuilderPref("cloud"), false);
});
check("hosted is NOT a runner channel — no PTY queue ever claims it", () => {
assert.equal(isBuilderChannel("hosted"), false);
assert.ok(!(BUILDER_CHANNELS as readonly string[]).includes("hosted"));
});
check("a hosted project still resolves to the default channel for anything that needs one", () => {
assert.equal(
pickDispatchChannel({ builderPref: "hosted", gitUrl: "https://github.com/bitbaum/loki" }),
DEFAULT_BUILDER_CHANNEL,
);
});
console.log(`\nhosted-builder-pref: ${pass} passed`);