@tokenfactory/acc-runner 0.42.0 → 0.43.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/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/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/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 +13 -0
- package/dist/program.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 +252 -51
- 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 +11 -0
- package/dist/task-runner.d.ts.map +1 -1
- package/dist/task-runner.js +69 -0
- package/dist/task-runner.js.map +1 -1
- package/dist/watch.d.ts +8 -0
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +28 -0
- package/dist/watch.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
+
//# sourceMapp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AgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAUnE"}
|
|
@@ -0,0 +1,148 @@
|
|
|
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 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.`;
|
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AAY,CAAC,GAAG,EAAE,WAAW,CAAC;QAC3C,cAAc,EAAE,eAAe,CAAC,GAAG,EAAE,cAAc,CAAC;QACpD,QAAQ,EAAE,OAAO,GAAG,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,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;
|
|
@@ -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,EAAsE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACxI,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAmB,KAAK,QAAQ,EA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AAG,IAAI,CAM3E;AA8ED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACxC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,gBAAgB,CAWlB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAwB/E;AA+KD,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,GAChB,iBAAiB,CA08DnB"}
|
package/dist/task-runner.js
CHANGED
|
@@ -46,6 +46,7 @@ import { parseConflictMeta, resolveConflict, MAX_CONFLICT_ATTEMPTS, } from "./ru
|
|
|
46
46
|
import { parseReworkMeta, renderReworkPrompt, reconcileReworkBranch as defaultReconcileReworkBranch, fetchPrHeadRef as defaultFetchPrHeadRef, } from "./runtime/rework.js";
|
|
47
47
|
import { assertResolutionIntegrity, isConflictResolutionTask, summariseFailures, } from "./runtime/resolution-integrity.js";
|
|
48
48
|
import { runPreprGate as defaultRunPreprGate, } from "./prepr-gate.js";
|
|
49
|
+
import { revalidateMigrationSeq as defaultRevalidateMigrationSeq, } from "./migration-seq-guard.js";
|
|
49
50
|
import { commitGuardSkipRequested, gitConfigHooksEnv, installCommitGuardSync, } from "./commit-guard.js";
|
|
50
51
|
import { readLiveAllowedGlobs } from "./locks/index.js";
|
|
51
52
|
const LOG_BATCH_BYTES = 4 * 1024;
|
|
@@ -727,6 +728,8 @@ export function runTask(taskId, deps) {
|
|
|
727
728
|
const runPreprGate = deps.runPreprGate ??
|
|
728
729
|
((workdir, baseRef) => defaultRunPreprGate(workdir, { baseRef }));
|
|
729
730
|
const reconcileRework = deps.reconcileReworkBranch ?? defaultReconcileReworkBranch;
|
|
731
|
+
const revalidateSeq = deps.revalidateMigrationSeq ??
|
|
732
|
+
((workdir, opts) => defaultRevalidateMigrationSeq(workdir, opts));
|
|
730
733
|
// FU-9: default seeds the worktree from the warm parent clone (see
|
|
731
734
|
// ensureWorktreeNodeModules); logs via the runner's stderr so a doctor can see it.
|
|
732
735
|
const ensureWorktreeDeps = deps.ensureWorktreeDeps ??
|
|
@@ -1318,6 +1321,62 @@ export function runTask(taskId, deps) {
|
|
|
1318
1321
|
error: `conflict-resolution integrity guardrail rejected resolution (${summary})`,
|
|
1319
1322
|
};
|
|
1320
1323
|
};
|
|
1324
|
+
/**
|
|
1325
|
+
* MIG-SEQ-GUARD: last thing before `git push`, re-validate this branch's
|
|
1326
|
+
* NEW migration seq against a FRESHLY-FETCHED integration head. The seq was
|
|
1327
|
+
* chosen at worktree-fork time; by push time a sibling migration may have
|
|
1328
|
+
* merged and taken it, and until now that only surfaced as a migration-lint
|
|
1329
|
+
* failure on the PR — a whole run spent on a rename the runner can do
|
|
1330
|
+
* itself. When the number is gone the migration is renumbered to the next
|
|
1331
|
+
* free contiguous seq (filename + self-record + verify messages + every
|
|
1332
|
+
* test that reads it by path) and committed, so the push carries the fix.
|
|
1333
|
+
*
|
|
1334
|
+
* Never blocks: the guard is fail-open by construction and this returns
|
|
1335
|
+
* void. A renumber emits `migration.seq_renumbered` so the move is visible
|
|
1336
|
+
* on the History tab rather than being a silent rewrite.
|
|
1337
|
+
*/
|
|
1338
|
+
const runMigrationSeqGuard = async (rework) => {
|
|
1339
|
+
let result;
|
|
1340
|
+
try {
|
|
1341
|
+
result = await revalidateSeq(workdir, {
|
|
1342
|
+
integrationBranch,
|
|
1343
|
+
baseRef: resolvedBaseRef,
|
|
1344
|
+
remote: "origin",
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
catch (err) {
|
|
1348
|
+
// The guard already fails open internally; this catches a stub/dep that
|
|
1349
|
+
// throws so a seq check can never be the reason a push does not happen.
|
|
1350
|
+
process.stderr.write(`[acc-runner] migration seq guard crashed (push proceeds): ` +
|
|
1351
|
+
`${err.message?.slice(0, 200)}\n`);
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
if (!result.renumbered || !result.move) {
|
|
1355
|
+
// Quiet on the no-op path — the overwhelming majority of pushes touch
|
|
1356
|
+
// no migration at all, and an event per push would be pure noise.
|
|
1357
|
+
if (result.skipped && result.skipped !== "no-new-migrations") {
|
|
1358
|
+
process.stderr.write(`[acc-runner] migration seq guard: ${result.detail}\n`);
|
|
1359
|
+
}
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
await appendEvent(deps.supabase, taskId, "log", {
|
|
1363
|
+
phase: "push",
|
|
1364
|
+
stream: "stdout",
|
|
1365
|
+
event: "migration.seq_renumbered",
|
|
1366
|
+
branch,
|
|
1367
|
+
rework,
|
|
1368
|
+
integration_branch: integrationBranch,
|
|
1369
|
+
from_seq: result.move.fromSeq,
|
|
1370
|
+
to_seq: result.move.toSeq,
|
|
1371
|
+
file: result.move.file,
|
|
1372
|
+
new_file: result.move.newFile,
|
|
1373
|
+
remote_max_seq: result.remoteMaxSeq ?? null,
|
|
1374
|
+
message: result.detail,
|
|
1375
|
+
renumber_output: result.move.output,
|
|
1376
|
+
runner_id: deps.session.runnerId,
|
|
1377
|
+
});
|
|
1378
|
+
process.stderr.write(`[acc-runner] migration seq guard: ${result.detail}\n`);
|
|
1379
|
+
};
|
|
1321
1380
|
try {
|
|
1322
1381
|
// POOL-P1b: clone-on-demand source provisioning. When the flag is on and
|
|
1323
1382
|
// repoPath resolved to the per-repo cache path above, clone the task's
|
|
@@ -2166,6 +2225,11 @@ export function runTask(taskId, deps) {
|
|
|
2166
2225
|
return { taskId, status: "failed", phase: "push", error: msg };
|
|
2167
2226
|
}
|
|
2168
2227
|
}
|
|
2228
|
+
// MIG-SEQ-GUARD: after the no-advance check (which compares heads) and
|
|
2229
|
+
// immediately before the push, so the freshest possible integration head
|
|
2230
|
+
// decides the seq. A renumber adds a commit, which is also what makes the
|
|
2231
|
+
// advance check above meaningful on a rework that only moved a number.
|
|
2232
|
+
await runMigrationSeqGuard(true);
|
|
2169
2233
|
try {
|
|
2170
2234
|
await git.push(workdir, branch);
|
|
2171
2235
|
}
|
|
@@ -2325,6 +2389,11 @@ export function runTask(taskId, deps) {
|
|
|
2325
2389
|
runner_id: deps.session.runnerId,
|
|
2326
2390
|
});
|
|
2327
2391
|
}
|
|
2392
|
+
// MIG-SEQ-GUARD: the LAST thing before the push. It deliberately runs
|
|
2393
|
+
// after the pre-PR gate rather than inside it — the gate's own MIGFIX-01
|
|
2394
|
+
// renumber reads the fork-time worktree snapshot, and only a fresh fetch
|
|
2395
|
+
// here can see a sibling that merged while the gate was running.
|
|
2396
|
+
await runMigrationSeqGuard(false);
|
|
2328
2397
|
// 5. Push + open PR. Both run from the worktree so the operator's
|
|
2329
2398
|
// shared clone never has the task branch checked out.
|
|
2330
2399
|
let prUrl = "";
|