@codyswann/lisa 4.109.1 → 4.109.2
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/all/copy-overwrite/scripts/lib/completion-proof-github.mjs +58 -3
- package/all/copy-overwrite/scripts/lib/completion-proof-publisher.mjs +58 -141
- package/all/copy-overwrite/scripts/lib/evidence-prune-records.mjs +57 -11
- package/all/copy-overwrite/scripts/lib/evidence-release-capacity.mjs +228 -0
- package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +1 -0
- package/all/copy-overwrite/scripts/lisa-work-item.mjs +16 -15
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +14 -4
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +38 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +28 -21
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/lisa/.codex-plugin/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/lisa/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/lisa/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/lisa/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/lisa-agy/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/lisa-agy/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-agy/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-agy/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/lisa-copilot/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/lisa-copilot/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-copilot/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-copilot/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/lisa-cursor/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/lisa-cursor/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-cursor/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-cursor/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/lisa-devin/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/lisa-devin/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-devin/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-devin/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-expo/.codex-plugin/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-expo/.codex-plugin/skills/jira-journey/SKILL.md +1 -1
- package/plugins/lisa-expo/.codex-plugin/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-expo/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-expo/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-expo/skills/jira-journey/SKILL.md +1 -1
- package/plugins/lisa-expo/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-agy/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-expo-agy/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-expo-agy/skills/jira-journey/SKILL.md +1 -1
- package/plugins/lisa-expo-agy/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-expo-copilot/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-expo-copilot/skills/jira-journey/SKILL.md +1 -1
- package/plugins/lisa-expo-copilot/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-expo-cursor/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-expo-cursor/skills/jira-journey/SKILL.md +1 -1
- package/plugins/lisa-expo-cursor/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-expo-devin/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-expo-devin/skills/jira-journey/SKILL.md +1 -1
- package/plugins/lisa-expo-devin/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-rails/.codex-plugin/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-rails/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-rails/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-agy/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-rails-agy/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-rails-copilot/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-rails-cursor/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/lisa-rails-devin/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/skills/lisa-github-evidence/SKILL.md +7 -3
- package/plugins/src/base/skills/lisa-jira-evidence/SKILL.md +10 -7
- package/plugins/src/base/skills/lisa-jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/src/base/skills/lisa-jira-journey/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/src/base/skills/lisa-linear-evidence/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-tracker-evidence/references/completion-authorization.md +27 -8
- package/plugins/src/expo/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/src/expo/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/plugins/src/expo/skills/jira-journey/SKILL.md +1 -1
- package/plugins/src/expo/skills/jira-journey/scripts/generate-templates.py +10 -5
- package/plugins/src/rails/skills/jira-evidence/SKILL.md +11 -5
- package/plugins/src/rails/skills/jira-evidence/scripts/post-evidence.sh +21 -2
- package/scripts/two-channel-couplings.json +1 -1
- package/typescript/copy-overwrite/.prettierignore +1 -0
|
@@ -25,6 +25,16 @@ export const EVIDENCE_RELEASE_ASSET_LIMIT = 1000;
|
|
|
25
25
|
* operator reads what to change instead of an opaque upload failure (#4692).
|
|
26
26
|
*/
|
|
27
27
|
export const EVIDENCE_RELEASE_NEAR_FULL = 950;
|
|
28
|
+
/**
|
|
29
|
+
* The highest overflow suffix the publisher rolls over to: `<release>-2`
|
|
30
|
+
* through `<release>-99` (CodySwannGT/lisa#4838). One monthly release filled in
|
|
31
|
+
* under two weeks on a busy host; 98 overflow releases hold about 93,000 more
|
|
32
|
+
* files per period, and the bound keeps both the roll-over loop and the set of
|
|
33
|
+
* names the validator accepts finite.
|
|
34
|
+
*/
|
|
35
|
+
export const EVIDENCE_RELEASE_MAX_OVERFLOW = 99;
|
|
36
|
+
/** `-2` … `-99`: no `-0`, no `-1`, no leading zero, so each name is unique. */
|
|
37
|
+
const OVERFLOW_SUFFIX = "(?:-(?:[2-9]|[1-9]\\d))?";
|
|
28
38
|
const MONTH_TOKEN = "{YYYY-MM}";
|
|
29
39
|
const MONTH_PATTERN = "\\d{4}-(?:0[1-9]|1[0-2])";
|
|
30
40
|
const RELEASE_TAG = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
@@ -133,19 +143,64 @@ export function evidenceReleaseOverride(
|
|
|
133
143
|
return value;
|
|
134
144
|
}
|
|
135
145
|
|
|
136
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* The release a roll-over writes to at a position: the resolved name itself
|
|
148
|
+
* first, then `<name>-2`, `<name>-3`, and so on (CodySwannGT/lisa#4838).
|
|
149
|
+
* @param {string} base - The resolved or pinned concrete release name.
|
|
150
|
+
* @param {number} index - 1 for the name itself, 2 or more for an overflow.
|
|
151
|
+
* @returns {string} The concrete release name at that position.
|
|
152
|
+
*/
|
|
153
|
+
export function overflowReleaseTag(base, index) {
|
|
154
|
+
return index <= 1 ? base : `${base}-${index}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The release this run publishes to, and whether it was pinned.
|
|
159
|
+
*
|
|
160
|
+
* The one resolver behind both `evidence-release` and
|
|
161
|
+
* `publish-completion-proof`, so the release the publisher uploads to is
|
|
162
|
+
* always the one `evidence-release` prints in the same environment. The
|
|
163
|
+
* publisher used to resolve the current-month name itself and ignore
|
|
164
|
+
* `LISA_EVIDENCE_RELEASE`, so a full month blocked every completion even when
|
|
165
|
+
* the operator pinned a release with room (CodySwannGT/lisa#4838).
|
|
166
|
+
* @param {object} [policy] - `verification.completion` from the Lisa config.
|
|
167
|
+
* @param {object} [env] - The environment holding `LISA_EVIDENCE_RELEASE`.
|
|
168
|
+
* @param {Date} [now] - Resolution time for a `{YYYY-MM}` template.
|
|
169
|
+
* @returns {{tag: string, pinned: boolean}} The validated concrete release;
|
|
170
|
+
* `pinned` when `LISA_EVIDENCE_RELEASE` named it, which never rolls over.
|
|
171
|
+
*/
|
|
172
|
+
export function targetEvidenceRelease(
|
|
173
|
+
policy = {},
|
|
174
|
+
env = process.env,
|
|
175
|
+
now = new Date()
|
|
176
|
+
) {
|
|
177
|
+
// The whole accepted set first, history included, so a malformed
|
|
178
|
+
// `acceptedEvidenceReleases` is refused before any GitHub call (#4838).
|
|
179
|
+
acceptedEvidenceReleases(policy);
|
|
180
|
+
const pinned = env.LISA_EVIDENCE_RELEASE?.trim();
|
|
181
|
+
return pinned
|
|
182
|
+
? { tag: evidenceReleaseOverride(policy, pinned), pinned: true }
|
|
183
|
+
: { tag: resolveEvidenceRelease(policy, now), pinned: false };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* An anchored pattern where only `{YYYY-MM}` and an overflow suffix vary; all
|
|
188
|
+
* else is literal. The suffix is what keeps proof in `<release>-2` and later
|
|
189
|
+
* overflow releases validating on `finish` (CodySwannGT/lisa#4838).
|
|
190
|
+
*/
|
|
137
191
|
function templatePattern(template) {
|
|
138
192
|
const literal = template
|
|
139
193
|
.split(MONTH_TOKEN)
|
|
140
194
|
.map(part => part.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&"));
|
|
141
|
-
return new RegExp(`^${literal.join(MONTH_PATTERN)}$`);
|
|
195
|
+
return new RegExp(`^${literal.join(MONTH_PATTERN)}${OVERFLOW_SUFFIX}$`);
|
|
142
196
|
}
|
|
143
197
|
|
|
144
198
|
/**
|
|
145
199
|
* Whether a release tag holds evidence the validator accepts.
|
|
146
200
|
* @param {object} [policy] - `verification.completion` from the Lisa config.
|
|
147
201
|
* @param {string} tag - Release tag read from native asset metadata.
|
|
148
|
-
* @returns {boolean} True for the legacy, configured or listed releases
|
|
202
|
+
* @returns {boolean} True for the legacy, configured or listed releases, and
|
|
203
|
+
* for their `-2` … `-99` overflow releases.
|
|
149
204
|
*/
|
|
150
205
|
export function isAcceptedEvidenceRelease(policy, tag) {
|
|
151
206
|
return (
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
CompletionProofError,
|
|
10
10
|
PROOF_KIND,
|
|
11
11
|
PROOF_MARKER,
|
|
12
|
-
MAX_NATIVE_JSON_BYTES,
|
|
13
12
|
MAX_RECORD_BYTES,
|
|
14
13
|
sha256,
|
|
15
14
|
primarySpecProjection,
|
|
@@ -19,136 +18,74 @@ import {
|
|
|
19
18
|
isId,
|
|
20
19
|
} from "./completion-proof-shape.mjs";
|
|
21
20
|
import {
|
|
22
|
-
EVIDENCE_RELEASE_ASSET_LIMIT,
|
|
23
|
-
EVIDENCE_RELEASE_NEAR_FULL,
|
|
24
21
|
githubProofTransport,
|
|
25
|
-
|
|
22
|
+
targetEvidenceRelease,
|
|
26
23
|
} from "./completion-proof-github.mjs";
|
|
24
|
+
import {
|
|
25
|
+
ensureEvidenceRelease,
|
|
26
|
+
excerpt,
|
|
27
|
+
fullReleaseMessage,
|
|
28
|
+
releaseAssets,
|
|
29
|
+
uploadHitLimit,
|
|
30
|
+
} from "./evidence-release-capacity.mjs";
|
|
27
31
|
import { completionRecordId } from "./completion-proof-reader.mjs";
|
|
28
32
|
import { evaluateAcceptedRecord } from "./completion-authorization.mjs";
|
|
29
33
|
|
|
30
34
|
const READ_ERROR = "read-error";
|
|
31
35
|
const WRITE_ERROR = "write-error";
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
function fullReleaseMessage(tag, repository, count) {
|
|
35
|
-
const held =
|
|
36
|
-
count === undefined
|
|
37
|
-
? `is at GitHub's ${EVIDENCE_RELEASE_ASSET_LIMIT}-file limit`
|
|
38
|
-
: `holds ${count} of GitHub's ${EVIDENCE_RELEASE_ASSET_LIMIT}-file limit`;
|
|
39
|
-
return `The evidence release \`${tag}\` in ${repository} ${held}, so new proof can't be uploaded. Set \`verification.completion.evidenceRelease\` in .lisa.config.json to a rotating name such as \`pr-assets-{YYYY-MM}\` (older proof keeps validating), or prune old evidence (CodySwannGT/lisa#4720).`;
|
|
40
|
-
}
|
|
37
|
+
export { ensureEvidenceRelease };
|
|
41
38
|
|
|
42
|
-
/**
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const path = `${transport.root}/releases/tags/${tag}`;
|
|
55
|
-
const result = run("gh", ["api", path], {
|
|
56
|
-
allowFailure: true,
|
|
57
|
-
maxBuffer: MAX_NATIVE_JSON_BYTES,
|
|
58
|
-
});
|
|
59
|
-
if (result.status === 0 && !result.error) {
|
|
60
|
-
try {
|
|
61
|
-
return JSON.parse(result.stdout);
|
|
62
|
-
} catch {
|
|
63
|
-
throw new CompletionProofError(
|
|
64
|
-
READ_ERROR,
|
|
65
|
-
"The evidence release metadata is not complete JSON."
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (/HTTP 404/.test(result.stderr ?? "")) return null;
|
|
70
|
-
return transport.json(path);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Whether a failed upload means the release is full. GitHub's 422 also covers
|
|
75
|
-
* an asset name that already exists, so a bare 422 is not enough: the error
|
|
76
|
-
* has to name the limit, or a fresh count has to show the release at it.
|
|
77
|
-
*/
|
|
78
|
-
function uploadHitLimit(stderr, transport, release) {
|
|
79
|
-
if (/asset[^\n]*limit|limit[^\n]*asset/i.test(stderr)) return null;
|
|
80
|
-
if (!/HTTP 422/.test(stderr)) return false;
|
|
81
|
-
const count = releaseAssets(transport, release).length;
|
|
82
|
-
return count + 1 >= EVIDENCE_RELEASE_ASSET_LIMIT ? count : false;
|
|
39
|
+
/** Upload one file to a release; the failure's diagnostics, or null on success. */
|
|
40
|
+
function attemptUpload(context, transport, evidence, file) {
|
|
41
|
+
const uploaded = context.run(
|
|
42
|
+
"gh",
|
|
43
|
+
["release", "upload", evidence.tag, file, "--repo", context.repository],
|
|
44
|
+
{ allowFailure: true }
|
|
45
|
+
);
|
|
46
|
+
// probe-direction: fail-closed — null means only a zero exit with no spawn
|
|
47
|
+
// error; every other outcome returns the failure and the caller refuses.
|
|
48
|
+
if (uploaded.status === 0 && !uploaded.error) return null;
|
|
49
|
+
const stderr = uploaded.stderr ?? "";
|
|
50
|
+
return { stderr, full: uploadHitLimit(stderr, transport, evidence.release) };
|
|
83
51
|
}
|
|
84
52
|
|
|
85
53
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* host and stopped every completion (CodySwannGT/lisa#4692); the refusal here
|
|
92
|
-
* tells the operator what to change instead.
|
|
93
|
-
* @param {Function} run - The canonical child-process runner.
|
|
94
|
-
* @param {object} transport - The bounded GitHub proof transport.
|
|
95
|
-
* @param {object} [policy] - `verification.completion` from the Lisa config.
|
|
96
|
-
* @param {object} [options] - Optional resolution inputs.
|
|
97
|
-
* @param {Date} [options.now] - Resolution time for a `{YYYY-MM}` template.
|
|
98
|
-
* @param {string} [options.tag] - An already-validated concrete tag to use.
|
|
99
|
-
* @returns {{tag: string, release: object, count: number}} The usable release.
|
|
54
|
+
* Upload the record to the target release, rolling over once to the next
|
|
55
|
+
* overflow release when GitHub reports the release full mid-upload (another
|
|
56
|
+
* publisher filled it after the capacity check). A pinned release is refused
|
|
57
|
+
* instead, as it is before the upload (CodySwannGT/lisa#4838).
|
|
58
|
+
* @returns {object} The release the record now lives in.
|
|
100
59
|
*/
|
|
101
|
-
|
|
102
|
-
const tag
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"gh",
|
|
109
|
-
[
|
|
110
|
-
"release",
|
|
111
|
-
"create",
|
|
112
|
-
tag,
|
|
113
|
-
"--repo",
|
|
114
|
-
transport.repository,
|
|
115
|
-
"--title",
|
|
116
|
-
`Lisa evidence ${tag}`,
|
|
117
|
-
"--notes",
|
|
118
|
-
"Evidence storage only — not a product release. Completion-proof and verification evidence assets, managed by Lisa.",
|
|
119
|
-
"--latest=false",
|
|
120
|
-
],
|
|
121
|
-
{ allowFailure: true }
|
|
122
|
-
);
|
|
123
|
-
release = readRelease(run, transport, tag);
|
|
124
|
-
const reason = excerpt(created.stderr);
|
|
125
|
-
requireProof(
|
|
126
|
-
release,
|
|
127
|
-
`The evidence release \`${tag}\` does not exist in ${transport.repository} and could not be created; check that the publisher can create releases there.${reason ? ` GitHub said: ${reason}` : ""}`,
|
|
128
|
-
WRITE_ERROR
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
const assets = releaseAssets(transport, release);
|
|
132
|
-
if (assets.length >= EVIDENCE_RELEASE_NEAR_FULL)
|
|
133
|
-
throw new CompletionProofError(
|
|
134
|
-
WRITE_ERROR,
|
|
135
|
-
fullReleaseMessage(tag, transport.repository, assets.length)
|
|
136
|
-
);
|
|
137
|
-
return { tag, release, count: assets.length };
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** Every asset on a release, from the complete paginated native listing. */
|
|
141
|
-
function releaseAssets(transport, release) {
|
|
142
|
-
const pages = transport.json(
|
|
143
|
-
`${transport.root}/releases/${release.id}/assets?per_page=100`,
|
|
144
|
-
true
|
|
60
|
+
function uploadProof(context, transport, target, file) {
|
|
61
|
+
const options = { tag: target.tag, pinned: target.pinned };
|
|
62
|
+
let evidence = ensureEvidenceRelease(
|
|
63
|
+
context.run,
|
|
64
|
+
transport,
|
|
65
|
+
context.policy,
|
|
66
|
+
options
|
|
145
67
|
);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
68
|
+
let failure = attemptUpload(context, transport, evidence, file);
|
|
69
|
+
if (failure && failure.full !== false && !target.pinned) {
|
|
70
|
+
evidence = ensureEvidenceRelease(context.run, transport, context.policy, {
|
|
71
|
+
...options,
|
|
72
|
+
from: evidence.index + 1,
|
|
73
|
+
});
|
|
74
|
+
failure = attemptUpload(context, transport, evidence, file);
|
|
75
|
+
}
|
|
76
|
+
if (!failure) return evidence;
|
|
77
|
+
const reason = excerpt(failure.stderr);
|
|
78
|
+
throw new CompletionProofError(
|
|
79
|
+
WRITE_ERROR,
|
|
80
|
+
failure.full === false
|
|
81
|
+
? `Immutable completion-proof upload failed; no acceptance locator was published.${reason ? ` GitHub said: ${reason}` : ""}`
|
|
82
|
+
: fullReleaseMessage(
|
|
83
|
+
evidence.tag,
|
|
84
|
+
context.repository,
|
|
85
|
+
failure.full ?? undefined,
|
|
86
|
+
{ pinned: target.pinned, policy: context.policy }
|
|
87
|
+
)
|
|
150
88
|
);
|
|
151
|
-
return pages.flat();
|
|
152
89
|
}
|
|
153
90
|
|
|
154
91
|
/** Recover the monotonic native index without treating old malformed proof as valid. */
|
|
@@ -217,6 +154,10 @@ function publisherIdentity(context, input, transport, repository) {
|
|
|
217
154
|
|
|
218
155
|
/** Strict immutable publication, followed by exact native readback and locator. */
|
|
219
156
|
export function publishCompletionProof(context, input) {
|
|
157
|
+
// Resolved first, so an invalid LISA_EVIDENCE_RELEASE is refused before any
|
|
158
|
+
// read or write, exactly as `evidence-release` refuses it (#4838).
|
|
159
|
+
const target =
|
|
160
|
+
context.evidenceTarget ?? targetEvidenceRelease(context.policy);
|
|
220
161
|
const transport = githubProofTransport(
|
|
221
162
|
context.run,
|
|
222
163
|
context.repository,
|
|
@@ -277,36 +218,12 @@ export function publishCompletionProof(context, input) {
|
|
|
277
218
|
);
|
|
278
219
|
const digest = sha256(bytes);
|
|
279
220
|
const name = `${recordId}-r${record.revision}-${digest}.json`;
|
|
280
|
-
const evidence = ensureEvidenceRelease(
|
|
281
|
-
context.run,
|
|
282
|
-
transport,
|
|
283
|
-
context.policy
|
|
284
|
-
);
|
|
285
221
|
const temporary = mkdtempSync(join(tmpdir(), "lisa-completion-proof-"));
|
|
286
222
|
try {
|
|
287
223
|
mkdirSync(temporary, { recursive: true });
|
|
288
224
|
const file = join(temporary, name);
|
|
289
225
|
writeFileSync(file, bytes);
|
|
290
|
-
const
|
|
291
|
-
"gh",
|
|
292
|
-
["release", "upload", evidence.tag, file, "--repo", context.repository],
|
|
293
|
-
{ allowFailure: true }
|
|
294
|
-
);
|
|
295
|
-
if (uploaded.status !== 0 || uploaded.error) {
|
|
296
|
-
const stderr = uploaded.stderr ?? "";
|
|
297
|
-
const full = uploadHitLimit(stderr, transport, evidence.release);
|
|
298
|
-
const reason = excerpt(stderr);
|
|
299
|
-
throw new CompletionProofError(
|
|
300
|
-
WRITE_ERROR,
|
|
301
|
-
full === false
|
|
302
|
-
? `Immutable completion-proof upload failed; no acceptance locator was published.${reason ? ` GitHub said: ${reason}` : ""}`
|
|
303
|
-
: fullReleaseMessage(
|
|
304
|
-
evidence.tag,
|
|
305
|
-
context.repository,
|
|
306
|
-
full ?? undefined
|
|
307
|
-
)
|
|
308
|
-
);
|
|
309
|
-
}
|
|
226
|
+
const evidence = uploadProof(context, transport, target, file);
|
|
310
227
|
const matching = releaseAssets(transport, evidence.release).filter(
|
|
311
228
|
asset => asset.name === name
|
|
312
229
|
);
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* @module scripts/lib/evidence-prune-records
|
|
16
16
|
*/
|
|
17
17
|
import {
|
|
18
|
+
EVIDENCE_RELEASE_MAX_OVERFLOW,
|
|
18
19
|
isAcceptedEvidenceRelease,
|
|
20
|
+
overflowReleaseTag,
|
|
19
21
|
resolveEvidenceRelease,
|
|
20
22
|
} from "./completion-proof-github.mjs";
|
|
21
23
|
import { COMPLETION_RECORD, EvidencePruneError } from "./evidence-prune.mjs";
|
|
@@ -61,18 +63,61 @@ export function evidenceSnapshot(gh, policy, tag) {
|
|
|
61
63
|
};
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The releases the publisher may write a new record into that the snapshot
|
|
68
|
+
* did not list: the release it resolves to now and its overflow releases,
|
|
69
|
+
* plus the pinned release.
|
|
70
|
+
*
|
|
71
|
+
* The publisher writes to the first overflow position with room and creates
|
|
72
|
+
* the first one that is missing, so a new release is either a missing name
|
|
73
|
+
* below the highest one that exists (a gap left by a deleted release) or the
|
|
74
|
+
* name just past it. Each unlisted name up to one past the highest known
|
|
75
|
+
* release is therefore looked up, and a gap does not stop the walk: stopping
|
|
76
|
+
* at a missing `-2` skipped a `-4` created past an existing `-3`, and the
|
|
77
|
+
* prune deleted a file a record there pinned (CodySwannGT/lisa#4838). The
|
|
78
|
+
* walk costs one lookup per gap plus one, not one per possible name, and it
|
|
79
|
+
* never passes `-99`.
|
|
80
|
+
*/
|
|
81
|
+
function publisherReleases(gh, accepted, resolved, pinned) {
|
|
82
|
+
const listed = tag => accepted.some(release => release.tag_name === tag);
|
|
83
|
+
let ceiling = 2;
|
|
84
|
+
for (let index = 1; index <= EVIDENCE_RELEASE_MAX_OVERFLOW; index += 1)
|
|
85
|
+
if (listed(overflowReleaseTag(resolved, index))) ceiling = index + 1;
|
|
86
|
+
const extra = [];
|
|
87
|
+
for (
|
|
88
|
+
let index = 1;
|
|
89
|
+
index <= Math.min(ceiling, EVIDENCE_RELEASE_MAX_OVERFLOW);
|
|
90
|
+
index += 1
|
|
91
|
+
) {
|
|
92
|
+
const tag = overflowReleaseTag(resolved, index);
|
|
93
|
+
if (listed(tag)) continue;
|
|
94
|
+
const release = gh.release(tag);
|
|
95
|
+
if (!release) continue;
|
|
96
|
+
extra.push(release);
|
|
97
|
+
ceiling = Math.max(ceiling, index + 1);
|
|
98
|
+
}
|
|
99
|
+
const pinnedRelease =
|
|
100
|
+
pinned && !listed(pinned) && !extra.some(row => row.tag_name === pinned)
|
|
101
|
+
? gh.release(pinned)
|
|
102
|
+
: null;
|
|
103
|
+
return pinnedRelease ? [...extra, pinnedRelease] : extra;
|
|
104
|
+
}
|
|
105
|
+
|
|
64
106
|
/**
|
|
65
107
|
* A re-read of records published since the snapshot, for the check made
|
|
66
108
|
* before each delete.
|
|
67
109
|
*
|
|
68
110
|
* It re-lists the snapshot's accepted releases plus every release the
|
|
69
111
|
* publisher can write a new record into: the one it resolves to now, so a
|
|
70
|
-
* rotation across a month boundary during a long run is still seen
|
|
71
|
-
*
|
|
72
|
-
* and
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
112
|
+
* rotation across a month boundary during a long run is still seen; that
|
|
113
|
+
* release's overflow releases, which the publisher creates once it is full
|
|
114
|
+
* (CodySwannGT/lisa#4838); and the one `LISA_EVIDENCE_RELEASE` pins, which the
|
|
115
|
+
* publisher uses instead when set and creates when absent. It does not re-list
|
|
116
|
+
* the repository's releases on every delete: on a repository with thousands
|
|
117
|
+
* of releases that alone is twenty-odd calls per file, and GitHub does not
|
|
118
|
+
* list releases newest first, so the first page alone would not do. Walking
|
|
119
|
+
* the overflow chain costs one lookup per gap plus one past the highest
|
|
120
|
+
* release.
|
|
76
121
|
* @param {object} gh - The prune's GitHub operations.
|
|
77
122
|
* @param {object} policy - `verification.completion` from the Lisa config.
|
|
78
123
|
* @param {object[]} accepted - The snapshot's accepted releases.
|
|
@@ -85,11 +130,12 @@ export function evidenceSnapshot(gh, policy, tag) {
|
|
|
85
130
|
export function recordRescanner(gh, policy, accepted, options = {}) {
|
|
86
131
|
const clock = options.clock ?? (() => new Date());
|
|
87
132
|
return known => {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.
|
|
133
|
+
const extra = publisherReleases(
|
|
134
|
+
gh,
|
|
135
|
+
accepted,
|
|
136
|
+
resolveEvidenceRelease(policy, clock()),
|
|
137
|
+
options.pinned
|
|
138
|
+
);
|
|
93
139
|
const fresh = [...accepted, ...extra]
|
|
94
140
|
.flatMap(release => gh.assets(release))
|
|
95
141
|
.filter(asset => isRecord(asset) && !known.has(asset.id));
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// This file is managed by Lisa and IS replaced on each `lisa` run.
|
|
2
|
+
// Do not edit directly — durable changes belong upstream in Lisa.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Find, create and capacity-check the GitHub release new evidence goes to,
|
|
6
|
+
* rolling a full release over to its next overflow release.
|
|
7
|
+
*
|
|
8
|
+
* GitHub caps a release at 1000 assets and then answers every upload with a
|
|
9
|
+
* raw HTTP 422. A single hardcoded `pr-assets` release filled in days on a busy
|
|
10
|
+
* host (CodySwannGT/lisa#4692); rotating it monthly was not enough either, as a
|
|
11
|
+
* monthly release then filled in under two weeks and no work item could
|
|
12
|
+
* complete until the month turned (CodySwannGT/lisa#4838). So a full resolved
|
|
13
|
+
* release rolls over to `<release>-2`, `-3`, … each created and checked the
|
|
14
|
+
* same way, and the validator accepts those names. A release pinned with
|
|
15
|
+
* `LISA_EVIDENCE_RELEASE` is an exact choice and never rolls over. Nothing is
|
|
16
|
+
* ever deleted here.
|
|
17
|
+
*/
|
|
18
|
+
import {
|
|
19
|
+
CompletionProofError,
|
|
20
|
+
MAX_NATIVE_JSON_BYTES,
|
|
21
|
+
requireProof,
|
|
22
|
+
} from "./completion-proof-shape.mjs";
|
|
23
|
+
import {
|
|
24
|
+
EVIDENCE_RELEASE_ASSET_LIMIT,
|
|
25
|
+
EVIDENCE_RELEASE_MAX_OVERFLOW,
|
|
26
|
+
EVIDENCE_RELEASE_NEAR_FULL,
|
|
27
|
+
overflowReleaseTag,
|
|
28
|
+
resolveEvidenceRelease,
|
|
29
|
+
usableTag,
|
|
30
|
+
} from "./completion-proof-github.mjs";
|
|
31
|
+
|
|
32
|
+
const READ_ERROR = "read-error";
|
|
33
|
+
const WRITE_ERROR = "write-error";
|
|
34
|
+
const NOTES =
|
|
35
|
+
"Evidence storage only — not a product release. Completion-proof and verification evidence assets, managed by Lisa.";
|
|
36
|
+
|
|
37
|
+
/** How the count reads in a refusal; unknown when GitHub only named the limit. */
|
|
38
|
+
function held(count) {
|
|
39
|
+
return count === undefined
|
|
40
|
+
? `is at GitHub's ${EVIDENCE_RELEASE_ASSET_LIMIT}-file limit`
|
|
41
|
+
: `holds ${count} of GitHub's ${EVIDENCE_RELEASE_ASSET_LIMIT}-file limit`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* What an operator can do about a full release. Suggesting rotation to a
|
|
46
|
+
* project that already rotates is noise, so it leads with pruning then.
|
|
47
|
+
*/
|
|
48
|
+
function fullReleaseAdvice(policy, tag) {
|
|
49
|
+
const prune = `prune old evidence with \`node scripts/lisa-evidence-prune.mjs --release ${tag}\` (CodySwannGT/lisa#4720)`;
|
|
50
|
+
return String(policy?.evidenceRelease ?? "").includes("{YYYY-MM}")
|
|
51
|
+
? `To make room, ${prune}; next month's release starts empty.`
|
|
52
|
+
: `Set \`verification.completion.evidenceRelease\` in .lisa.config.json to a rotating name such as \`pr-assets-{YYYY-MM}\` (older proof keeps validating), or ${prune}.`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The operator-readable refusal for a release GitHub will not take more files in.
|
|
57
|
+
* @param {string} tag - The full release.
|
|
58
|
+
* @param {string} repository - `owner/name`.
|
|
59
|
+
* @param {number} [count] - Its asset count, when known.
|
|
60
|
+
* @param {object} [options] - How the release was chosen.
|
|
61
|
+
* @param {boolean} [options.pinned] - Whether `LISA_EVIDENCE_RELEASE` chose it.
|
|
62
|
+
* @param {object} [options.policy] - `verification.completion`, for the advice.
|
|
63
|
+
* @returns {string} The refusal.
|
|
64
|
+
*/
|
|
65
|
+
export function fullReleaseMessage(tag, repository, count, options = {}) {
|
|
66
|
+
if (options.pinned)
|
|
67
|
+
return `The evidence release \`${tag}\` that LISA_EVIDENCE_RELEASE pins in ${repository} ${held(count)}, so new proof can't be uploaded. A pinned release is an exact choice and never rolls over: unset LISA_EVIDENCE_RELEASE so Lisa moves to an overflow release with room, or pin a release that has room.`;
|
|
68
|
+
return `The evidence release \`${tag}\` in ${repository} ${held(count)}, so new proof can't be uploaded. ${fullReleaseAdvice(options.policy, tag)}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The refusal once every overflow release of a period is full. */
|
|
72
|
+
function exhaustedMessage(base, repository, policy) {
|
|
73
|
+
const last = overflowReleaseTag(base, EVIDENCE_RELEASE_MAX_OVERFLOW);
|
|
74
|
+
return `Every evidence release from \`${base}\` to \`${last}\` in ${repository} holds ${EVIDENCE_RELEASE_NEAR_FULL} or more of GitHub's ${EVIDENCE_RELEASE_ASSET_LIMIT}-file limit, so new proof can't be uploaded. ${fullReleaseAdvice(policy, base)}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The last few lines of a native CLI's diagnostics, bounded for a message.
|
|
79
|
+
* @param {string} [stderr] - Raw diagnostics.
|
|
80
|
+
* @returns {string} At most the last 400 characters.
|
|
81
|
+
*/
|
|
82
|
+
export function excerpt(stderr) {
|
|
83
|
+
const text = String(stderr ?? "").trim();
|
|
84
|
+
return text.length > 400 ? `…${text.slice(-400)}` : text;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Read a release by tag in one call; `null` only for GitHub's explicit 404.
|
|
89
|
+
* Any other failure goes through the bounded transport, which reports it as a
|
|
90
|
+
* read error instead of guessing the release is absent and creating it.
|
|
91
|
+
*/
|
|
92
|
+
function readRelease(run, transport, tag) {
|
|
93
|
+
const path = `${transport.root}/releases/tags/${tag}`;
|
|
94
|
+
const result = run("gh", ["api", path], {
|
|
95
|
+
allowFailure: true,
|
|
96
|
+
maxBuffer: MAX_NATIVE_JSON_BYTES,
|
|
97
|
+
});
|
|
98
|
+
if (result.status === 0 && !result.error) {
|
|
99
|
+
try {
|
|
100
|
+
return JSON.parse(result.stdout);
|
|
101
|
+
} catch {
|
|
102
|
+
throw new CompletionProofError(
|
|
103
|
+
READ_ERROR,
|
|
104
|
+
"The evidence release metadata is not complete JSON."
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (/HTTP 404/.test(result.stderr ?? "")) return null;
|
|
109
|
+
return transport.json(path);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Every asset on a release, from the complete paginated native listing.
|
|
114
|
+
* @param {object} transport - The bounded GitHub proof transport.
|
|
115
|
+
* @param {{id: number}} release - Native release metadata.
|
|
116
|
+
* @returns {object[]} Every asset.
|
|
117
|
+
*/
|
|
118
|
+
export function releaseAssets(transport, release) {
|
|
119
|
+
const pages = transport.json(
|
|
120
|
+
`${transport.root}/releases/${release.id}/assets?per_page=100`,
|
|
121
|
+
true
|
|
122
|
+
);
|
|
123
|
+
requireProof(
|
|
124
|
+
pages.every(Array.isArray),
|
|
125
|
+
"The native completion-asset listing is incomplete.",
|
|
126
|
+
READ_ERROR
|
|
127
|
+
);
|
|
128
|
+
return pages.flat();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Whether a failed upload means the release is full. GitHub's 422 also covers
|
|
133
|
+
* an asset name that already exists, so a bare 422 is not enough: the error
|
|
134
|
+
* has to name the limit, or a fresh count has to show the release at it.
|
|
135
|
+
* @param {string} stderr - The failed upload's diagnostics.
|
|
136
|
+
* @param {object} transport - The bounded GitHub proof transport.
|
|
137
|
+
* @param {{id: number}} release - The release uploaded to.
|
|
138
|
+
* @returns {number|null|false} The fresh count when it shows the release at
|
|
139
|
+
* the limit, `null` when GitHub named the limit, `false` when not full.
|
|
140
|
+
*/
|
|
141
|
+
export function uploadHitLimit(stderr, transport, release) {
|
|
142
|
+
if (/asset[^\n]*limit|limit[^\n]*asset/i.test(stderr)) return null;
|
|
143
|
+
if (!/HTTP 422/.test(stderr)) return false;
|
|
144
|
+
const count = releaseAssets(transport, release).length;
|
|
145
|
+
return count + 1 >= EVIDENCE_RELEASE_ASSET_LIMIT ? count : false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** A release by tag, created when absent; a concurrent creator may win. */
|
|
149
|
+
function openRelease(run, transport, tag) {
|
|
150
|
+
let release = readRelease(run, transport, tag);
|
|
151
|
+
if (!release) {
|
|
152
|
+
const created = run(
|
|
153
|
+
"gh",
|
|
154
|
+
[
|
|
155
|
+
"release",
|
|
156
|
+
"create",
|
|
157
|
+
tag,
|
|
158
|
+
"--repo",
|
|
159
|
+
transport.repository,
|
|
160
|
+
"--title",
|
|
161
|
+
`Lisa evidence ${tag}`,
|
|
162
|
+
"--notes",
|
|
163
|
+
NOTES,
|
|
164
|
+
"--latest=false",
|
|
165
|
+
],
|
|
166
|
+
{ allowFailure: true }
|
|
167
|
+
);
|
|
168
|
+
release = readRelease(run, transport, tag);
|
|
169
|
+
const reason = excerpt(created.stderr);
|
|
170
|
+
requireProof(
|
|
171
|
+
release,
|
|
172
|
+
`The evidence release \`${tag}\` does not exist in ${transport.repository} and could not be created; check that the publisher can create releases there.${reason ? ` GitHub said: ${reason}` : ""}`,
|
|
173
|
+
WRITE_ERROR
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
return { tag, release, count: releaseAssets(transport, release).length };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Resolve the evidence release, create it when absent, and refuse or roll
|
|
181
|
+
* over before uploading when it is nearly full.
|
|
182
|
+
* @param {Function} run - The canonical child-process runner.
|
|
183
|
+
* @param {object} transport - The bounded GitHub proof transport.
|
|
184
|
+
* @param {object} [policy] - `verification.completion` from the Lisa config.
|
|
185
|
+
* @param {object} [options] - Optional resolution inputs.
|
|
186
|
+
* @param {Date} [options.now] - Resolution time for a `{YYYY-MM}` template.
|
|
187
|
+
* @param {string} [options.tag] - An already-validated concrete tag to use.
|
|
188
|
+
* @param {boolean} [options.pinned] - The tag is an exact choice: refuse it
|
|
189
|
+
* when full instead of rolling over.
|
|
190
|
+
* @param {number} [options.from] - The overflow position to start at; 1 (the
|
|
191
|
+
* tag itself) by default, higher after an upload found a release full.
|
|
192
|
+
* @returns {{tag: string, release: object, count: number, index: number}} The
|
|
193
|
+
* usable release and its overflow position.
|
|
194
|
+
*/
|
|
195
|
+
export function ensureEvidenceRelease(run, transport, policy, options = {}) {
|
|
196
|
+
const base =
|
|
197
|
+
options.tag ?? resolveEvidenceRelease(policy, options.now ?? new Date());
|
|
198
|
+
if (options.pinned) {
|
|
199
|
+
const pinned = openRelease(run, transport, base);
|
|
200
|
+
if (pinned.count >= EVIDENCE_RELEASE_NEAR_FULL)
|
|
201
|
+
throw new CompletionProofError(
|
|
202
|
+
WRITE_ERROR,
|
|
203
|
+
fullReleaseMessage(base, transport.repository, pinned.count, {
|
|
204
|
+
pinned: true,
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
return { ...pinned, index: 1 };
|
|
208
|
+
}
|
|
209
|
+
let last = { tag: base, count: undefined };
|
|
210
|
+
for (
|
|
211
|
+
let index = options.from ?? 1;
|
|
212
|
+
index <= EVIDENCE_RELEASE_MAX_OVERFLOW;
|
|
213
|
+
index += 1
|
|
214
|
+
) {
|
|
215
|
+
const tag = overflowReleaseTag(base, index);
|
|
216
|
+
if (!usableTag(tag))
|
|
217
|
+
throw new CompletionProofError(
|
|
218
|
+
WRITE_ERROR,
|
|
219
|
+
`${fullReleaseMessage(last.tag, transport.repository, last.count, { policy })} Lisa could not roll over to \`${tag}\`: the release name is too long for an overflow suffix (GitHub allows 100 characters), so shorten \`verification.completion.evidenceRelease\`.`
|
|
220
|
+
);
|
|
221
|
+
last = openRelease(run, transport, tag);
|
|
222
|
+
if (last.count < EVIDENCE_RELEASE_NEAR_FULL) return { ...last, index };
|
|
223
|
+
}
|
|
224
|
+
throw new CompletionProofError(
|
|
225
|
+
WRITE_ERROR,
|
|
226
|
+
exhaustedMessage(base, transport.repository, policy)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
@@ -26,6 +26,7 @@ const COMMON = [
|
|
|
26
26
|
"lib/completion-proof-reader.mjs",
|
|
27
27
|
"lib/completion-proof-shape.mjs",
|
|
28
28
|
"lib/completion-proof-source.mjs",
|
|
29
|
+
"lib/evidence-release-capacity.mjs",
|
|
29
30
|
"lib/usage-effectiveness.mjs",
|
|
30
31
|
"lib/usage-ledger-integrity.mjs",
|
|
31
32
|
"lib/usage-ledger.mjs",
|