@tokenfactory/acc-runner 0.42.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -3
- package/dist/companion-run.d.ts.map +1 -1
- package/dist/companion-run.js +20 -0
- package/dist/companion-run.js.map +1 -1
- package/dist/config.d.ts +72 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +117 -3
- package/dist/config.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +13 -3
- package/dist/doctor.js.map +1 -1
- package/dist/engines/account-probe.d.ts +24 -0
- package/dist/engines/account-probe.d.ts.map +1 -1
- package/dist/engines/account-probe.js +18 -1
- package/dist/engines/account-probe.js.map +1 -1
- package/dist/engines/registry.d.ts +17 -6
- package/dist/engines/registry.d.ts.map +1 -1
- package/dist/engines/registry.js +38 -13
- package/dist/engines/registry.js.map +1 -1
- package/dist/git-auth/github-token-source.d.ts +54 -0
- package/dist/git-auth/github-token-source.d.ts.map +1 -0
- package/dist/git-auth/github-token-source.js +44 -0
- package/dist/git-auth/github-token-source.js.map +1 -0
- package/dist/git-auth/index.d.ts +4 -0
- package/dist/git-auth/index.d.ts.map +1 -1
- package/dist/git-auth/index.js +4 -0
- package/dist/git-auth/index.js.map +1 -1
- package/dist/git-auth/installation-token.d.ts +95 -0
- package/dist/git-auth/installation-token.d.ts.map +1 -0
- package/dist/git-auth/installation-token.js +192 -0
- package/dist/git-auth/installation-token.js.map +1 -0
- package/dist/local-repo/command.d.ts +28 -0
- package/dist/local-repo/command.d.ts.map +1 -0
- package/dist/local-repo/command.js +178 -0
- package/dist/local-repo/command.js.map +1 -0
- package/dist/local-repo/index.d.ts +119 -0
- package/dist/local-repo/index.d.ts.map +1 -0
- package/dist/local-repo/index.js +141 -0
- package/dist/local-repo/index.js.map +1 -0
- package/dist/machine-capabilities/index.d.ts +21 -0
- package/dist/machine-capabilities/index.d.ts.map +1 -0
- package/dist/machine-capabilities/index.js +21 -0
- package/dist/machine-capabilities/index.js.map +1 -0
- package/dist/machine-capabilities/probe.d.ts +61 -0
- package/dist/machine-capabilities/probe.d.ts.map +1 -0
- package/dist/machine-capabilities/probe.js +243 -0
- package/dist/machine-capabilities/probe.js.map +1 -0
- package/dist/machine-capabilities/redact.d.ts +42 -0
- package/dist/machine-capabilities/redact.d.ts.map +1 -0
- package/dist/machine-capabilities/redact.js +160 -0
- package/dist/machine-capabilities/redact.js.map +1 -0
- package/dist/machine-capabilities/report.d.ts +107 -0
- package/dist/machine-capabilities/report.d.ts.map +1 -0
- package/dist/machine-capabilities/report.js +211 -0
- package/dist/machine-capabilities/report.js.map +1 -0
- package/dist/machine-capabilities/types.d.ts +115 -0
- package/dist/machine-capabilities/types.d.ts.map +1 -0
- package/dist/machine-capabilities/types.js +11 -0
- package/dist/machine-capabilities/types.js.map +1 -0
- package/dist/mcp-spawn.d.ts +19 -0
- package/dist/mcp-spawn.d.ts.map +1 -1
- package/dist/mcp-spawn.js +52 -26
- package/dist/mcp-spawn.js.map +1 -1
- package/dist/migration-seq-guard.d.ts +78 -0
- package/dist/migration-seq-guard.d.ts.map +1 -0
- package/dist/migration-seq-guard.js +304 -0
- package/dist/migration-seq-guard.js.map +1 -0
- package/dist/node-version.d.ts +132 -0
- package/dist/node-version.d.ts.map +1 -0
- package/dist/node-version.js +318 -0
- package/dist/node-version.js.map +1 -0
- package/dist/prepr-gate.d.ts +120 -0
- package/dist/prepr-gate.d.ts.map +1 -1
- package/dist/prepr-gate.js +202 -3
- package/dist/prepr-gate.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +34 -0
- package/dist/program.js.map +1 -1
- package/dist/provider-auth.d.ts +51 -1
- package/dist/provider-auth.d.ts.map +1 -1
- package/dist/provider-auth.js +83 -2
- package/dist/provider-auth.js.map +1 -1
- package/dist/runtime/review-chunking.d.ts +101 -0
- package/dist/runtime/review-chunking.d.ts.map +1 -0
- package/dist/runtime/review-chunking.js +192 -0
- package/dist/runtime/review-chunking.js.map +1 -0
- package/dist/runtime/review-diff.d.ts +30 -0
- package/dist/runtime/review-diff.d.ts.map +1 -0
- package/dist/runtime/review-diff.js +59 -0
- package/dist/runtime/review-diff.js.map +1 -0
- package/dist/runtime/reviewer.d.ts +40 -19
- package/dist/runtime/reviewer.d.ts.map +1 -1
- package/dist/runtime/reviewer.js +283 -68
- package/dist/runtime/reviewer.js.map +1 -1
- package/dist/serve-scope/command.d.ts +12 -0
- package/dist/serve-scope/command.d.ts.map +1 -0
- package/dist/serve-scope/command.js +89 -0
- package/dist/serve-scope/command.js.map +1 -0
- package/dist/serve-scope/index.d.ts +130 -0
- package/dist/serve-scope/index.d.ts.map +1 -0
- package/dist/serve-scope/index.js +148 -0
- package/dist/serve-scope/index.js.map +1 -0
- package/dist/task-runner.d.ts +22 -2
- package/dist/task-runner.d.ts.map +1 -1
- package/dist/task-runner.js +142 -25
- package/dist/task-runner.js.map +1 -1
- package/dist/watch.d.ts +21 -0
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +109 -1
- package/dist/watch.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AX-H2 (SERVE-SCOPE-CONSENT): the `acc-runner serve-scope` command.
|
|
3
|
+
*
|
|
4
|
+
* The plumbing around ./index.ts's pure decision tree — load the session, read
|
|
5
|
+
* THIS machine's row, plan, print, and (only then) send. Deliberately thin: every
|
|
6
|
+
* rule worth testing lives in planServeScopeChange, and this file is the part
|
|
7
|
+
* that needs a keychain and a network.
|
|
8
|
+
*
|
|
9
|
+
* The read is a plain PostgREST select on acc.runners rather than a new RPC. The
|
|
10
|
+
* columns are readable through the existing `runners_select` policy, so adding a
|
|
11
|
+
* reader would have meant a new browser-reachable STABLE SECURITY DEFINER
|
|
12
|
+
* function and a fight with migration 0299 §4.1 for no gain.
|
|
13
|
+
*/
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
import { loadConfig } from "../config.js";
|
|
16
|
+
import { createRunnerClient } from "../supabase.js";
|
|
17
|
+
import { getTokenProvider } from "../token-provider.js";
|
|
18
|
+
import { expiresSoon, refreshAccessToken } from "../runtime/auth-lifecycle.js";
|
|
19
|
+
import { describeServeScope, isMigrationPending, planServeScopeChange, serveScopeOf, submitServeScope, } from "./index.js";
|
|
20
|
+
const SELECT_COLUMNS = "id, machine, bound_user_id, serve_scope, serve_scope_source, serve_scope_consent_at";
|
|
21
|
+
export async function serveScopeCommand(opts = {}) {
|
|
22
|
+
const out = opts.out ?? ((line) => console.log(line));
|
|
23
|
+
const cfg = loadConfig();
|
|
24
|
+
const tokenProvider = getTokenProvider();
|
|
25
|
+
let session = await tokenProvider.load();
|
|
26
|
+
if (!session) {
|
|
27
|
+
throw new Error("not signed in — run `acc-runner login` first");
|
|
28
|
+
}
|
|
29
|
+
if (tokenProvider.canRefresh() && expiresSoon(session)) {
|
|
30
|
+
session = await refreshAccessToken(cfg, session);
|
|
31
|
+
await tokenProvider.save(session);
|
|
32
|
+
}
|
|
33
|
+
const sb = createRunnerClient(cfg, session.access_token, session.realtime_config);
|
|
34
|
+
const { data, error } = await sb
|
|
35
|
+
.from("runners")
|
|
36
|
+
.select(SELECT_COLUMNS)
|
|
37
|
+
.eq("id", session.runner_id)
|
|
38
|
+
.maybeSingle();
|
|
39
|
+
if (error) {
|
|
40
|
+
// HALT-before-apply means every environment has a window where this command
|
|
41
|
+
// is merged and the columns are not there yet. Say which it is: "run psql"
|
|
42
|
+
// and "something is broken" have different remedies.
|
|
43
|
+
if (isMigrationPending(error)) {
|
|
44
|
+
throw new Error("serve-scope is unavailable — migration 0314 has not been applied to this environment yet. " +
|
|
45
|
+
"Until it is, this machine keeps serving exactly what it serves today.");
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`could not read this machine's serve scope: ${error.message}`);
|
|
48
|
+
}
|
|
49
|
+
if (!data) {
|
|
50
|
+
throw new Error(`runner ${session.runner_id} is not visible to this session — re-run \`acc-runner login\``);
|
|
51
|
+
}
|
|
52
|
+
const row = data;
|
|
53
|
+
const current = serveScopeOf(row.serve_scope);
|
|
54
|
+
const viewerIsOwner = typeof row.bound_user_id === "string" && row.bound_user_id === session.user_id;
|
|
55
|
+
out(describeServeScope(row));
|
|
56
|
+
const plan = planServeScopeChange({
|
|
57
|
+
requested: opts.scope ?? null,
|
|
58
|
+
current,
|
|
59
|
+
confirmed: opts.yes === true,
|
|
60
|
+
viewerIsOwner,
|
|
61
|
+
});
|
|
62
|
+
switch (plan.action) {
|
|
63
|
+
case "show":
|
|
64
|
+
if (current === "owner" && viewerIsOwner) {
|
|
65
|
+
out(chalk.dim(" Consent to serve the whole org with `acc-runner serve-scope org --yes`."));
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
case "refuse":
|
|
69
|
+
// A refusal is the product working, so it exits non-zero via the caller's
|
|
70
|
+
// guard but reads as an explanation rather than a stack trace.
|
|
71
|
+
throw new Error(plan.reason);
|
|
72
|
+
default: {
|
|
73
|
+
const result = await submitServeScope(sb, {
|
|
74
|
+
runnerId: session.runner_id,
|
|
75
|
+
scope: plan.scope,
|
|
76
|
+
reason: opts.reason ?? null,
|
|
77
|
+
source: "cli",
|
|
78
|
+
});
|
|
79
|
+
const verb = result.decision === "granted"
|
|
80
|
+
? "consented — this machine now serves the whole org"
|
|
81
|
+
: result.decision === "revoked"
|
|
82
|
+
? "revoked — this machine now serves its owner only"
|
|
83
|
+
: `unchanged (${result.serve_scope})`;
|
|
84
|
+
out(chalk.green(`✓ ${verb}. Recorded in the consent ledger.`));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/serve-scope/command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,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,CAAC,MAAM,CAAC,CAAC;QAE/B,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,EAAE,EAAE;gBACxC,QAAQ,EAAE,OAAO,CAAC,SAAS;gBAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI;gBAC3B,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;YACH,MAAM,IAAI,GACR,MAAM,CAAC,QAAQ,KAAK,SAAS;gBAC3B,CAAC,CAAC,mDAAmD;gBACrD,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS;oBAC7B,CAAC,CAAC,kDAAkD;oBACpD,CAAC,CAAC,cAAc,MAAM,CAAC,WAAW,GAAG,CAAC;YAC5C,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,mCAAmC,CAAC,CAAC,CAAC;YAC/D,OAAO;QACT,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AX-H2 (SERVE-SCOPE-CONSENT): the machine's own half of the consent.
|
|
3
|
+
* AUTH_APPROVAL_BRIEF.md §7.2, Phase H, gap G-18.
|
|
4
|
+
*
|
|
5
|
+
* `acc-runner serve-scope` is where the person sitting at the machine decides
|
|
6
|
+
* whether it serves only their work or the whole org's. That placement is the
|
|
7
|
+
* point, not a convenience: the thing being consented to — this laptop's gh
|
|
8
|
+
* credential, git identity and Claude subscription — is in front of them, and
|
|
9
|
+
* migration 0314 §5 will only accept the answer from the machine's bound owner
|
|
10
|
+
* anyway. A web form an admin could fill in on their behalf would be a checkbox,
|
|
11
|
+
* not a consent.
|
|
12
|
+
*
|
|
13
|
+
* THREE RULES THIS MODULE ENFORCES ON ITS CALLERS
|
|
14
|
+
* ----------------------------------------------------------------------------
|
|
15
|
+
* 1. WIDENING IS NEVER SILENT. {@link planServeScopeChange} refuses to widen to
|
|
16
|
+
* `org` unless the caller passed an explicit confirmation. `--yes` is
|
|
17
|
+
* accepted for scripted enrolment, but the DEFAULT of a bare
|
|
18
|
+
* `acc-runner serve-scope org` is a refusal with the consequences printed,
|
|
19
|
+
* not a shrug-and-apply.
|
|
20
|
+
* 2. NARROWING IS ALWAYS ALLOWED. Revoking needs no confirmation and no flag.
|
|
21
|
+
* Withdrawal must never be harder than the grant — that asymmetry is
|
|
22
|
+
* deliberate and it matches 0314 §5's server-side rule.
|
|
23
|
+
* 3. THE SERVER IS THE GATE. Everything here is a convenience over
|
|
24
|
+
* `acc.set_runner_serve_scope`, which re-checks ownership in the database.
|
|
25
|
+
* A refusal printed by this file is courtesy; a refusal from the RPC is
|
|
26
|
+
* security.
|
|
27
|
+
*
|
|
28
|
+
* The command is fully injectable (transport / stdout / confirm) so the whole
|
|
29
|
+
* decision tree is asserted with no network, no keychain and no database.
|
|
30
|
+
*/
|
|
31
|
+
/** The vocabulary, mirroring `acc.runner_serve_scopes()` (0314 §2). */
|
|
32
|
+
export declare const SERVE_SCOPES: readonly ["owner", "org"];
|
|
33
|
+
export type ServeScope = (typeof SERVE_SCOPES)[number];
|
|
34
|
+
/** What a machine is until somebody decides otherwise. */
|
|
35
|
+
export declare const DEFAULT_SERVE_SCOPE: ServeScope;
|
|
36
|
+
/** The RPC surface this module needs — a supabase-js client satisfies it. */
|
|
37
|
+
export interface ServeScopeTransport {
|
|
38
|
+
rpc(fn: string, args: Record<string, unknown>): PromiseLike<{
|
|
39
|
+
data?: unknown;
|
|
40
|
+
error?: {
|
|
41
|
+
message: string;
|
|
42
|
+
} | null;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* True when a PostgREST error means "migration 0314 is not applied here yet"
|
|
47
|
+
* rather than a genuine fault. The HALT-before-apply rule guarantees this window
|
|
48
|
+
* exists on every environment between merge and promotion, and the two cases
|
|
49
|
+
* have different remedies — "a human runs psql" versus "something is broken".
|
|
50
|
+
* PostgREST reports an unknown column as 42703 and an unknown relation as 42P01;
|
|
51
|
+
* the message check is the belt for clients that do not surface the code.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isMigrationPending(error: unknown): boolean;
|
|
54
|
+
/** The row shape `acc.runners` hands back for this machine. */
|
|
55
|
+
export interface ServeScopeRunnerRow {
|
|
56
|
+
id: string;
|
|
57
|
+
machine?: string | null;
|
|
58
|
+
bound_user_id?: string | null;
|
|
59
|
+
serve_scope?: unknown;
|
|
60
|
+
serve_scope_source?: unknown;
|
|
61
|
+
serve_scope_consent_at?: string | null;
|
|
62
|
+
}
|
|
63
|
+
/** Narrow an unknown to a ServeScope, or null when it is not one. */
|
|
64
|
+
export declare function parseServeScope(value: unknown): ServeScope | null;
|
|
65
|
+
/**
|
|
66
|
+
* The scope to treat a row as having. Anything unreadable folds to `owner`, NOT
|
|
67
|
+
* to `org`: an unreadable consent is an ungiven consent. The fold direction is
|
|
68
|
+
* the safety property — a CLI talking to a server that predates migration 0314
|
|
69
|
+
* (no column, `undefined`) must report owner-only rather than invent agreement.
|
|
70
|
+
*/
|
|
71
|
+
export declare function serveScopeOf(value: unknown): ServeScope;
|
|
72
|
+
/** What one `serve-scope` invocation should do, before anything is sent. */
|
|
73
|
+
export type ServeScopePlan =
|
|
74
|
+
/** Print the current posture; no write. */
|
|
75
|
+
{
|
|
76
|
+
action: "show";
|
|
77
|
+
}
|
|
78
|
+
/** Widening was asked for without confirmation — refuse and explain. */
|
|
79
|
+
| {
|
|
80
|
+
action: "refuse";
|
|
81
|
+
reason: string;
|
|
82
|
+
}
|
|
83
|
+
/** Already there. Still sent, so the re-affirmation is recorded (0314 §5). */
|
|
84
|
+
| {
|
|
85
|
+
action: "reaffirm";
|
|
86
|
+
scope: ServeScope;
|
|
87
|
+
} | {
|
|
88
|
+
action: "grant";
|
|
89
|
+
scope: "org";
|
|
90
|
+
} | {
|
|
91
|
+
action: "revoke";
|
|
92
|
+
scope: "owner";
|
|
93
|
+
};
|
|
94
|
+
export interface ServeScopeChangeInput {
|
|
95
|
+
/** The scope the operator asked for. Absent ⇒ show. */
|
|
96
|
+
requested?: string | null;
|
|
97
|
+
/** The machine's current scope, as the server reports it. */
|
|
98
|
+
current: ServeScope;
|
|
99
|
+
/** The operator passed --yes (or answered an interactive prompt). */
|
|
100
|
+
confirmed?: boolean;
|
|
101
|
+
/** True when the signed-in session owns this machine. */
|
|
102
|
+
viewerIsOwner: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The whole decision tree, as a pure function. Ordered most-refusing first, so a
|
|
106
|
+
* case that falls through has been considered rather than defaulted into.
|
|
107
|
+
*/
|
|
108
|
+
export declare function planServeScopeChange(input: ServeScopeChangeInput): ServeScopePlan;
|
|
109
|
+
/** What the RPC hands back (0314 §5's RETURNS TABLE). */
|
|
110
|
+
export interface ServeScopeResult {
|
|
111
|
+
runner_id: string;
|
|
112
|
+
serve_scope: ServeScope;
|
|
113
|
+
previous_scope: ServeScope | null;
|
|
114
|
+
decision: string;
|
|
115
|
+
consent_at: string | null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Send one decision. Thin by design: the argument names are the RPC's, so a
|
|
119
|
+
* signature change is a compile-time break here rather than a runtime error on
|
|
120
|
+
* somebody's laptop.
|
|
121
|
+
*/
|
|
122
|
+
export declare function submitServeScope(transport: ServeScopeTransport, args: {
|
|
123
|
+
runnerId: string;
|
|
124
|
+
scope: ServeScope;
|
|
125
|
+
reason?: string | null;
|
|
126
|
+
source?: string;
|
|
127
|
+
}): Promise<ServeScopeResult>;
|
|
128
|
+
/** The one-line posture a person reads at the terminal. */
|
|
129
|
+
export declare function describeServeScope(row: ServeScopeRunnerRow): string;
|
|
130
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serve-scope/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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|
|
3
|
+
* AUTH_APPROVAL_BRIEF.md §7.2, Phase H, gap G-18.
|
|
4
|
+
*
|
|
5
|
+
* `acc-runner serve-scope` is where the person sitting at the machine decides
|
|
6
|
+
* whether it serves only their work or the whole org's. That placement is the
|
|
7
|
+
* point, not a convenience: the thing being consented to — this laptop's gh
|
|
8
|
+
* credential, git identity and Claude subscription — is in front of them, and
|
|
9
|
+
* migration 0314 §5 will only accept the answer from the machine's bound owner
|
|
10
|
+
* anyway. A web form an admin could fill in on their behalf would be a checkbox,
|
|
11
|
+
* not a consent.
|
|
12
|
+
*
|
|
13
|
+
* THREE RULES THIS MODULE ENFORCES ON ITS CALLERS
|
|
14
|
+
* ----------------------------------------------------------------------------
|
|
15
|
+
* 1. WIDENING IS NEVER SILENT. {@link planServeScopeChange} refuses to widen to
|
|
16
|
+
* `org` unless the caller passed an explicit confirmation. `--yes` is
|
|
17
|
+
* accepted for scripted enrolment, but the DEFAULT of a bare
|
|
18
|
+
* `acc-runner serve-scope org` is a refusal with the consequences printed,
|
|
19
|
+
* not a shrug-and-apply.
|
|
20
|
+
* 2. NARROWING IS ALWAYS ALLOWED. Revoking needs no confirmation and no flag.
|
|
21
|
+
* Withdrawal must never be harder than the grant — that asymmetry is
|
|
22
|
+
* deliberate and it matches 0314 §5's server-side rule.
|
|
23
|
+
* 3. THE SERVER IS THE GATE. Everything here is a convenience over
|
|
24
|
+
* `acc.set_runner_serve_scope`, which re-checks ownership in the database.
|
|
25
|
+
* A refusal printed by this file is courtesy; a refusal from the RPC is
|
|
26
|
+
* security.
|
|
27
|
+
*
|
|
28
|
+
* The command is fully injectable (transport / stdout / confirm) so the whole
|
|
29
|
+
* decision tree is asserted with no network, no keychain and no database.
|
|
30
|
+
*/
|
|
31
|
+
/** The vocabulary, mirroring `acc.runner_serve_scopes()` (0314 §2). */
|
|
32
|
+
export const SERVE_SCOPES = ["owner", "org"];
|
|
33
|
+
/** What a machine is until somebody decides otherwise. */
|
|
34
|
+
export const DEFAULT_SERVE_SCOPE = "owner";
|
|
35
|
+
/**
|
|
36
|
+
* True when a PostgREST error means "migration 0314 is not applied here yet"
|
|
37
|
+
* rather than a genuine fault. The HALT-before-apply rule guarantees this window
|
|
38
|
+
* exists on every environment between merge and promotion, and the two cases
|
|
39
|
+
* have different remedies — "a human runs psql" versus "something is broken".
|
|
40
|
+
* PostgREST reports an unknown column as 42703 and an unknown relation as 42P01;
|
|
41
|
+
* the message check is the belt for clients that do not surface the code.
|
|
42
|
+
*/
|
|
43
|
+
export function isMigrationPending(error) {
|
|
44
|
+
if (!error || typeof error !== "object")
|
|
45
|
+
return false;
|
|
46
|
+
const e = error;
|
|
47
|
+
if (e.code === "42703" || e.code === "42P01" || e.code === "PGRST204")
|
|
48
|
+
return true;
|
|
49
|
+
const msg = typeof e.message === "string" ? e.message.toLowerCase() : "";
|
|
50
|
+
return (msg.includes("serve_scope") &&
|
|
51
|
+
(msg.includes("does not exist") ||
|
|
52
|
+
msg.includes("could not find") ||
|
|
53
|
+
msg.includes("schema cache")));
|
|
54
|
+
}
|
|
55
|
+
/** Narrow an unknown to a ServeScope, or null when it is not one. */
|
|
56
|
+
export function parseServeScope(value) {
|
|
57
|
+
if (typeof value !== "string")
|
|
58
|
+
return null;
|
|
59
|
+
const v = value.trim().toLowerCase();
|
|
60
|
+
// The two spellings a person actually types at a terminal.
|
|
61
|
+
if (v === "owner-only" || v === "owner_only" || v === "me")
|
|
62
|
+
return "owner";
|
|
63
|
+
if (v === "org-wide" || v === "org_wide" || v === "team")
|
|
64
|
+
return "org";
|
|
65
|
+
return SERVE_SCOPES.includes(v) ? v : null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The scope to treat a row as having. Anything unreadable folds to `owner`, NOT
|
|
69
|
+
* to `org`: an unreadable consent is an ungiven consent. The fold direction is
|
|
70
|
+
* the safety property — a CLI talking to a server that predates migration 0314
|
|
71
|
+
* (no column, `undefined`) must report owner-only rather than invent agreement.
|
|
72
|
+
*/
|
|
73
|
+
export function serveScopeOf(value) {
|
|
74
|
+
return parseServeScope(value) ?? DEFAULT_SERVE_SCOPE;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The whole decision tree, as a pure function. Ordered most-refusing first, so a
|
|
78
|
+
* case that falls through has been considered rather than defaulted into.
|
|
79
|
+
*/
|
|
80
|
+
export function planServeScopeChange(input) {
|
|
81
|
+
const requested = input.requested == null ? null : parseServeScope(input.requested);
|
|
82
|
+
if (input.requested != null && requested == null) {
|
|
83
|
+
return {
|
|
84
|
+
action: "refuse",
|
|
85
|
+
reason: `unknown serve scope "${input.requested}" — expected "owner" or "org"`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (requested == null)
|
|
89
|
+
return { action: "show" };
|
|
90
|
+
if (requested === "org") {
|
|
91
|
+
if (!input.viewerIsOwner) {
|
|
92
|
+
return {
|
|
93
|
+
action: "refuse",
|
|
94
|
+
reason: "only this machine's owner can consent to serving the whole org — sign in as the owner on this machine (`acc-runner login`)",
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (!input.confirmed) {
|
|
98
|
+
return {
|
|
99
|
+
action: "refuse",
|
|
100
|
+
reason: "org-wide serving lends this machine's gh credential, git identity and Claude subscription to everyone in the org. " +
|
|
101
|
+
"Re-run with --yes to consent, or leave it owner-only.",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return input.current === "org" ? { action: "reaffirm", scope: "org" } : { action: "grant", scope: "org" };
|
|
105
|
+
}
|
|
106
|
+
// Narrowing. No confirmation, no flag, no owner check beyond what the server
|
|
107
|
+
// does — withdrawal must never be harder than the grant.
|
|
108
|
+
return input.current === "owner"
|
|
109
|
+
? { action: "reaffirm", scope: "owner" }
|
|
110
|
+
: { action: "revoke", scope: "owner" };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Send one decision. Thin by design: the argument names are the RPC's, so a
|
|
114
|
+
* signature change is a compile-time break here rather than a runtime error on
|
|
115
|
+
* somebody's laptop.
|
|
116
|
+
*/
|
|
117
|
+
export async function submitServeScope(transport, args) {
|
|
118
|
+
const { data, error } = await transport.rpc("set_runner_serve_scope", {
|
|
119
|
+
p_runner_id: args.runnerId,
|
|
120
|
+
p_scope: args.scope,
|
|
121
|
+
p_reason: args.reason ?? null,
|
|
122
|
+
p_source: args.source ?? "cli",
|
|
123
|
+
});
|
|
124
|
+
if (error) {
|
|
125
|
+
throw new Error(`serve-scope update refused: ${error.message}`);
|
|
126
|
+
}
|
|
127
|
+
const row = Array.isArray(data) ? data[0] : undefined;
|
|
128
|
+
return {
|
|
129
|
+
runner_id: typeof row?.runner_id === "string" ? row.runner_id : args.runnerId,
|
|
130
|
+
serve_scope: serveScopeOf(row?.serve_scope),
|
|
131
|
+
previous_scope: parseServeScope(row?.previous_scope),
|
|
132
|
+
decision: typeof row?.decision === "string" ? row.decision : "unknown",
|
|
133
|
+
consent_at: typeof row?.consent_at === "string" ? row.consent_at : null,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** The one-line posture a person reads at the terminal. */
|
|
137
|
+
export function describeServeScope(row) {
|
|
138
|
+
const scope = serveScopeOf(row.serve_scope);
|
|
139
|
+
const machine = row.machine ?? row.id;
|
|
140
|
+
if (scope === "org") {
|
|
141
|
+
const consented = row.serve_scope_source === "owner_consent";
|
|
142
|
+
return consented
|
|
143
|
+
? `${machine}: serving the WHOLE ORG — consented${row.serve_scope_consent_at ? ` ${row.serve_scope_consent_at.slice(0, 10)}` : ""}.`
|
|
144
|
+
: `${machine}: serving the WHOLE ORG — carried over from before consent was recorded, never explicitly agreed.`;
|
|
145
|
+
}
|
|
146
|
+
return `${machine}: serving its OWNER ONLY. Other people's tasks are not dispatched here.`;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serve-scope/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;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CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QACtE,UAAU,EAAE,OAAO,GAAG,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;KACxE,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,kBAAkB,CAAC,GAAwB;IACzD,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,EAAE,CAAC;IACtC,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,GAAG,CAAC,kBAAkB,KAAK,eAAe,CAAC;QAC7D,OAAO,SAAS;YACd,CAAC,CAAC,GAAG,OAAO,sCAAsC,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;YACpI,CAAC,CAAC,GAAG,OAAO,mGAAmG,CAAC;IACpH,CAAC;IACD,OAAO,GAAG,OAAO,yEAAyE,CAAC;AAC7F,CAAC"}
|
package/dist/task-runner.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { type ConflictResolutionDeps } from "./runtime/conflict-resolver.js";
|
|
|
13
13
|
import { type ReconcileResult, type ReconcileReworkOptions } from "./runtime/rework.js";
|
|
14
14
|
import { type AssertResolutionOptions, type ResolutionIntegrityDeps, type ResolutionIntegrityResult } from "./runtime/resolution-integrity.js";
|
|
15
15
|
import { type PreprGateResult } from "./prepr-gate.js";
|
|
16
|
+
import { type SeqGuardOptions, type SeqGuardResult } from "./migration-seq-guard.js";
|
|
16
17
|
import type { RunnerSupabaseClient } from "./supabase.js";
|
|
17
18
|
export interface CostEventPayload extends NormalizedUsage {
|
|
18
19
|
task_id: string;
|
|
@@ -191,6 +192,16 @@ export interface RunTaskDeps {
|
|
|
191
192
|
* tests inject a stub so the rework path doesn't shell out to a real merge.
|
|
192
193
|
*/
|
|
193
194
|
reconcileReworkBranch?: (opts: ReconcileReworkOptions) => Promise<ReconcileResult>;
|
|
195
|
+
/**
|
|
196
|
+
* MIG-SEQ-GUARD: re-validate this branch's NEW migration sequence against a
|
|
197
|
+
* FRESHLY-FETCHED integration head immediately before push, and auto-renumber
|
|
198
|
+
* it when a sibling migration merged and took the number since this worktree
|
|
199
|
+
* forked. Runs on BOTH push paths (fresh + rework). Defaults to
|
|
200
|
+
* `revalidateMigrationSeq`; tests inject a stub so the unit suite never
|
|
201
|
+
* fetches. Fail-open — it can only ever turn a PR CI would reject into one it
|
|
202
|
+
* accepts, never block a push.
|
|
203
|
+
*/
|
|
204
|
+
revalidateMigrationSeq?: (workdir: string, opts: SeqGuardOptions) => Promise<SeqGuardResult>;
|
|
194
205
|
}
|
|
195
206
|
export interface RunTaskController {
|
|
196
207
|
taskId: string;
|
|
@@ -348,8 +359,13 @@ export declare function recordClaudeUnavailable(now: number): ClaudeUnavailableD
|
|
|
348
359
|
* both `--output-format=json` (extracts .result) and plain text. Falls
|
|
349
360
|
* back to the entire stdout (capped) if no `## Summary` heading is
|
|
350
361
|
* present — that way the PR body still tells the reviewer what happened.
|
|
362
|
+
*
|
|
363
|
+
* NS MM-2: `engineId` is optional and appended last so every pre-existing
|
|
364
|
+
* caller (api/github/webhook.ts, the packages/acc-runner test suite) keeps
|
|
365
|
+
* compiling unchanged and keeps resolving `claude-code` — only the in-file
|
|
366
|
+
* per-task call site now forwards `task.engine`.
|
|
351
367
|
*/
|
|
352
|
-
export declare function extractReportFromOutput(stdout: string): string;
|
|
368
|
+
export declare function extractReportFromOutput(stdout: string, engineId?: string | null): string;
|
|
353
369
|
/**
|
|
354
370
|
* v0.35-B: extract the PR number from a `gh pr create` URL. Returns null
|
|
355
371
|
* when the URL doesn't carry a `/pull/<int>` segment so the caller can
|
|
@@ -361,8 +377,12 @@ export declare function parsePrNumber(url: string | null | undefined): number |
|
|
|
361
377
|
* Build a cost event from claude's stdout. Always returns a payload
|
|
362
378
|
* (zero-cost when usage isn't parseable) so the cap-tracking surface
|
|
363
379
|
* stays consistent: one cost_events row per attempt.
|
|
380
|
+
*
|
|
381
|
+
* NS MM-2: `engineId` is optional and appended last for the same reason as
|
|
382
|
+
* `extractReportFromOutput` — every pre-existing caller keeps resolving
|
|
383
|
+
* `claude-code` unchanged.
|
|
364
384
|
*/
|
|
365
|
-
export declare function buildCostEvent(taskId: string, stdout: string, fallbackModel: string | null | undefined, runnerId: string | null | undefined): CostEventPayload;
|
|
385
|
+
export declare function buildCostEvent(taskId: string, stdout: string, fallbackModel: string | null | undefined, runnerId: string | null | undefined, engineId?: string | null): CostEventPayload;
|
|
366
386
|
/**
|
|
367
387
|
* v0.14-MESSAGING-RUNTIME-WIRE — dynamic-import the prelude module
|
|
368
388
|
* referenced by a runner profile and return its default-exported string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-runner.d.ts","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAS,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"task-runner.d.ts","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAS,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAwF,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1J,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzD,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