@kenkyou/supekku 0.1.0-alpha.7 → 0.1.0-alpha.9
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/{agent-reply-CKqbCSJ6.mjs → agent-reply-BVO6qcmJ.mjs} +1 -1
- package/dist/{archive-BHJlkQjL.mjs → archive-BDQ_oB6g.mjs} +6 -5
- package/dist/{journal-CletC1o_.mjs → archive-BEqNOztX.mjs} +102 -271
- package/dist/archive-F8QO5Uzt.mjs +1 -0
- package/dist/artifact-CQOFviqq.mjs +2 -0
- package/dist/{artifact-ht-_ab-q.mjs → artifact-DyPzfc7L.mjs} +5 -5
- package/dist/{browser-DsFc6whG.mjs → browser-GAOPQH9h.mjs} +1 -1
- package/dist/{challenge-brief-ByEEcHIp.mjs → challenge-brief-D6e2atsF.mjs} +7 -6
- package/dist/{change-BSCac-hT.mjs → change-B3CIaYav.mjs} +2 -1
- package/dist/change-Ueo8V0d5.mjs +1 -0
- package/dist/change-archive.md +4 -2
- package/dist/cli-publication.md +4 -0
- package/dist/{connection-DxmpUdAJ.mjs → connection-DxigvTHW.mjs} +15 -1
- package/dist/{doctor-BH9O3U_5.mjs → doctor-CKgYDYGQ.mjs} +1 -1
- package/dist/doctor-DxcQvrCD.mjs +1 -0
- package/dist/{feedback-4XuusCbH.mjs → feedback-Bd4AuswE.mjs} +1 -1
- package/dist/{feedback-PKiTi5qD.mjs → feedback-DIHPDle4.mjs} +4 -4
- package/dist/index.mjs +45 -19
- package/dist/{init-CL2fItAc.mjs → init-DL-jiGgQ.mjs} +2 -2
- package/dist/journal-7SNjewV7.mjs +271 -0
- package/dist/{local-xRU7p3F-.mjs → local-Dz8Zbwnw.mjs} +1 -1
- package/dist/{local-A2AY5rQ1.mjs → local-odic_qV5.mjs} +1 -1
- package/dist/{maintenance-B4ZLnUbx.mjs → maintenance-wIhESufF.mjs} +2 -2
- package/dist/{project-DJzuN18W.mjs → project-3tknDiOf.mjs} +1 -1
- package/dist/{project-lfHLrk6Y.mjs → project-BKg9kde5.mjs} +2 -2
- package/dist/{project-YQvOlymW.mjs → project-BMl3DPyE.mjs} +1 -1
- package/dist/{project-bb7Dgih2.mjs → project-CMFCxtKO.mjs} +1 -1
- package/dist/{project-connection-vkvxD1dF.mjs → project-connection-C0nYGopT.mjs} +3 -3
- package/dist/{publish-Mcse7Ibn.mjs → publish-DZAod5L7.mjs} +5 -3
- package/dist/records-D3wvkIuV.mjs +62 -0
- package/dist/records-DZFyxxNq.mjs +639 -0
- package/dist/{review-status-DHcOnJs-.mjs → review-status-OBrm3vzd.mjs} +1 -1
- package/dist/skills/supekku-development/SKILL.md +2 -0
- package/dist/skills/supekku-development/references/change-archive.md +4 -2
- package/dist/skills/supekku-development/references/task-execution.md +8 -6
- package/dist/skills/supekku-development/references/workflow-records.md +77 -0
- package/dist/{status-BdIQMftm.mjs → status-B7GWMROT.mjs} +2 -2
- package/dist/{status-CZ07SyAP.mjs → status-DKLbxPPK.mjs} +5 -5
- package/dist/status-TcuF2Pd0.mjs +1 -0
- package/dist/task-JlFSBhEW.mjs +1 -0
- package/dist/{task-CUY_fL1e.mjs → task-dw_E1Rl2.mjs} +98 -15
- package/dist/task-execution.md +8 -6
- package/dist/viewer/assets/{core-XryUEwrO.js → core-BD2tv9Os.js} +1 -1
- package/dist/viewer/assets/{local-B7NmMY2e.js → local-Ba8cpiuE.js} +1 -1
- package/dist/viewer/assets/{local-B1h-m5xi.css → local-CvVckSDM.css} +1 -1
- package/dist/viewer/local.html +2 -2
- package/dist/workflow-records.md +77 -0
- package/package.json +16 -16
- package/dist/archive-DJg-0nGZ.mjs +0 -1
- package/dist/artifact--xKIG-w-.mjs +0 -2
- package/dist/change-CZfMqVRR.mjs +0 -1
- package/dist/doctor-qnCXeloq.mjs +0 -1
- package/dist/status-BRrn3Blu.mjs +0 -1
- package/dist/task-BJ7JFYIc.mjs +0 -1
- package/dist/task-snapshot-B40rnvav.mjs +0 -68
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as Check, t as CoreError, u as Type } from "./src-CRhxwFAN.mjs";
|
|
2
2
|
import { a as artifactId, r as LocalId } from "./artifact-local-Bfy69a9H.mjs";
|
|
3
3
|
import { t as Uuid } from "./api-C2o9bca2.mjs";
|
|
4
|
-
import { i as readBinding } from "./project-
|
|
4
|
+
import { i as readBinding } from "./project-BKg9kde5.mjs";
|
|
5
5
|
import { a as response, t as CommentView } from "./collaboration-Dw4ikptb.mjs";
|
|
6
6
|
import "./review-submissions-CY4IQpkU.mjs";
|
|
7
7
|
// ../../packages/contracts/src/agent-replies.ts
|
|
@@ -3,15 +3,15 @@ import { t as hash } from "./src-DeDtBfdV.mjs";
|
|
|
3
3
|
import { i as syncDocument, t as atomicReplace } from "./files-DphxaLNK.mjs";
|
|
4
4
|
import { n as workflowId } from "./change-DgUPVNsm.mjs";
|
|
5
5
|
import { n as inspectWorkflow } from "./verification-B4QMPPeA.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { n as checkedArchivePlan, r as mergeFormal, t as archiveReceipt } from "./archive-BEqNOztX.mjs";
|
|
7
7
|
import { t as readBounded } from "./files-Ca24RKdp.mjs";
|
|
8
8
|
import { n as withLocks } from "./locks-C4XYFwbg.mjs";
|
|
9
9
|
import { t as findProject } from "./project-directory-w_ITkI7O.mjs";
|
|
10
|
-
import { t as
|
|
10
|
+
import { n as openJournal, t as listArchiveOperations } from "./journal-7SNjewV7.mjs";
|
|
11
|
+
import { t as context } from "./local-odic_qV5.mjs";
|
|
11
12
|
import { t as readVerification } from "./verification-cEb-1z2d.mjs";
|
|
12
|
-
import { t as bundle } from "./change-
|
|
13
|
-
import {
|
|
14
|
-
import { n as taskCommand } from "./task-CUY_fL1e.mjs";
|
|
13
|
+
import { t as bundle } from "./change-B3CIaYav.mjs";
|
|
14
|
+
import { n as taskCommand, r as sourceFingerprint } from "./task-dw_E1Rl2.mjs";
|
|
15
15
|
import { randomUUID } from "node:crypto";
|
|
16
16
|
import { dirname, join } from "node:path";
|
|
17
17
|
import { link, lstat, mkdir, open, readdir, rename, unlink } from "node:fs/promises";
|
|
@@ -107,6 +107,7 @@ async function preview(root, id) {
|
|
|
107
107
|
taskId: t.id,
|
|
108
108
|
sourceHash: status.sourceHash,
|
|
109
109
|
eventHash: hash(JSON.stringify(status.events)),
|
|
110
|
+
...status.binding === "task" ? { inputHash: status.inputHash } : {},
|
|
110
111
|
events: status.events
|
|
111
112
|
});
|
|
112
113
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { l as Check, n as Hash, t as CoreError, u as Type } from "./src-CRhxwFAN.mjs";
|
|
2
|
+
import { t as hash } from "./src-DeDtBfdV.mjs";
|
|
3
|
+
import { t as WorkflowId } from "./change-DgUPVNsm.mjs";
|
|
4
4
|
import { n as inspectWorkflow, r as workflowMarkdown, t as validateVerification } from "./verification-B4QMPPeA.mjs";
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
7
|
-
import { chmodSync, existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
8
5
|
import { isDeepStrictEqual } from "node:util";
|
|
9
|
-
import Database from "better-sqlite3";
|
|
10
6
|
// ../../packages/contracts/src/archive.ts
|
|
11
7
|
const strict$1 = { additionalProperties: false };
|
|
12
8
|
const markdown = Type.String({ maxLength: 1024 ** 2 });
|
|
@@ -32,6 +28,7 @@ const ArchivePlanSchema = Type.Object({
|
|
|
32
28
|
}),
|
|
33
29
|
sourceHash: Hash,
|
|
34
30
|
eventHash: Hash,
|
|
31
|
+
inputHash: Type.Optional(Hash),
|
|
35
32
|
events: Type.Array(Type.Unknown(), {
|
|
36
33
|
minItems: 1,
|
|
37
34
|
maxItems: 1e4
|
|
@@ -77,7 +74,8 @@ const TaskEvidenceSchema = Type.Union([
|
|
|
77
74
|
...base,
|
|
78
75
|
kind: Type.Literal("start"),
|
|
79
76
|
authorization: text,
|
|
80
|
-
restart: Type.Optional(Type.Boolean())
|
|
77
|
+
restart: Type.Optional(Type.Boolean()),
|
|
78
|
+
binding: Type.Optional(Type.Literal("task"))
|
|
81
79
|
}, strict),
|
|
82
80
|
Type.Object({
|
|
83
81
|
...bound,
|
|
@@ -286,6 +284,96 @@ function acceptTaskEvent(task, events, e, current) {
|
|
|
286
284
|
if (e.kind === "review" && challengePolicy(task).level && !state.challenge?.passed) fail("Review requires a passing challenge of the current verification");
|
|
287
285
|
if (e.kind === "finish" && state.state !== "reviewed") fail("Finish requires current passing verification and review");
|
|
288
286
|
}
|
|
287
|
+
// ../../packages/workflow/src/binding.ts
|
|
288
|
+
const invalid = (message) => {
|
|
289
|
+
throw new CoreError("INVALID_WORKFLOW_DOCUMENT", message);
|
|
290
|
+
};
|
|
291
|
+
function canonical(value) {
|
|
292
|
+
if (Array.isArray(value)) return "[" + value.map(canonical).join(",") + "]";
|
|
293
|
+
if (value && typeof value === "object") return "{" + Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => JSON.stringify(k) + ":" + canonical(v)).join(",") + "}";
|
|
294
|
+
return JSON.stringify(value);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* What an attempt's evidence is bound to. An attempt whose start names task binding
|
|
298
|
+
* answers only for its own task; one that names nothing was started before task
|
|
299
|
+
* binding existed and stays bound to every document of the change. A task with no
|
|
300
|
+
* attempt yet will be started under task binding.
|
|
301
|
+
*/
|
|
302
|
+
function taskBinding(events) {
|
|
303
|
+
const start = events.findLast((e) => e.kind === "start");
|
|
304
|
+
return !start || start.binding === "task" ? "task" : "change";
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The fingerprint of each task of a change: its own entry in the task list, the
|
|
308
|
+
* wording of the requirements and scenarios it refers to, and the verification maps
|
|
309
|
+
* it refers to. Other tasks, the proposal, the design, requirements it does
|
|
310
|
+
* not refer to and the author's done/pending mark are deliberately left out, so
|
|
311
|
+
* editing them does not disturb evidence already recorded for this task.
|
|
312
|
+
*
|
|
313
|
+
* Expects a change that passes validation; anything else is refused.
|
|
314
|
+
*/
|
|
315
|
+
function taskFingerprints(input, parse = inspectWorkflow) {
|
|
316
|
+
const tasks = parse(input.files["tasks.md"] ?? invalid("Expected tasks document"));
|
|
317
|
+
if (tasks.meta.kind !== "tasks") return invalid("Expected tasks document");
|
|
318
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
319
|
+
const once = (key, source) => {
|
|
320
|
+
if (!parsed.has(key)) parsed.set(key, typeof source === "string" ? parse(source) : null);
|
|
321
|
+
return parsed.get(key);
|
|
322
|
+
};
|
|
323
|
+
const text = (doc, block) => (doc.blocks.get(block) ?? "").trim();
|
|
324
|
+
const result = /* @__PURE__ */ new Map();
|
|
325
|
+
for (const task of tasks.meta.tasks) {
|
|
326
|
+
const wanted = new Set(task.scenarios);
|
|
327
|
+
const requirements = task.requirements.map((reference) => {
|
|
328
|
+
const [capability, id] = reference.split("#");
|
|
329
|
+
const delta = once(`delta:${capability}`, input.files[`specs/${capability}.md`]);
|
|
330
|
+
if (!delta || delta.meta.kind !== "delta") return invalid("Expected delta");
|
|
331
|
+
const edit = delta.meta.changes.find((c) => (c.operation === "remove" ? c.requirementId : c.requirement.id) === id);
|
|
332
|
+
if (!edit) return invalid("Requirement is not in the change");
|
|
333
|
+
const scenarios = (edit.operation === "remove" ? edit.scenarios : edit.requirement.scenarios).filter((s) => wanted.has(`${capability}#${s.id}`)).map((s) => ({
|
|
334
|
+
reference: `${capability}#${s.id}`,
|
|
335
|
+
given: text(delta, s.given),
|
|
336
|
+
when: text(delta, s.when),
|
|
337
|
+
then: text(delta, s.then)
|
|
338
|
+
}));
|
|
339
|
+
if (edit.operation !== "remove") return {
|
|
340
|
+
reference,
|
|
341
|
+
operation: edit.operation,
|
|
342
|
+
statement: text(delta, edit.requirement.statement),
|
|
343
|
+
scenarios
|
|
344
|
+
};
|
|
345
|
+
const formal = once(`formal:${capability}`, input.baselines[capability]);
|
|
346
|
+
const original = formal?.meta.kind === "spec" ? formal.meta.requirements.find((r) => r.id === id) : null;
|
|
347
|
+
return {
|
|
348
|
+
reference,
|
|
349
|
+
operation: edit.operation,
|
|
350
|
+
reason: text(delta, edit.reason),
|
|
351
|
+
original: original && formal ? text(formal, original.statement) : null,
|
|
352
|
+
scenarios
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
const verification = task.verify.flatMap((step) => {
|
|
356
|
+
if (!step.reference) return [];
|
|
357
|
+
const content = input.verification?.[step.reference.split("#")[0]];
|
|
358
|
+
return [{
|
|
359
|
+
reference: step.reference,
|
|
360
|
+
map: typeof content === "string" ? hash(content) : null
|
|
361
|
+
}];
|
|
362
|
+
});
|
|
363
|
+
const { status: _status, ...entry } = task;
|
|
364
|
+
result.set(task.id, hash(canonical({
|
|
365
|
+
fingerprint: "task",
|
|
366
|
+
version: 1,
|
|
367
|
+
changeId: input.changeId,
|
|
368
|
+
task: entry,
|
|
369
|
+
description: text(tasks, task.description),
|
|
370
|
+
tddReason: task.tddReason ? text(tasks, task.tddReason) : null,
|
|
371
|
+
requirements,
|
|
372
|
+
verification
|
|
373
|
+
})));
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
289
377
|
// ../../packages/workflow/src/change.ts
|
|
290
378
|
const compareText = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
291
379
|
/** Names never read as task source: environment files and private or vendored directories. */
|
|
@@ -581,8 +669,10 @@ function checkedArchivePlan(value) {
|
|
|
581
669
|
const meta = inspectWorkflow(p.files["tasks.md"]).meta;
|
|
582
670
|
if (meta.kind !== "tasks") throw new Error("Expected tasks");
|
|
583
671
|
if (p.tasks.length !== meta.tasks.length || new Set(p.tasks.map((t) => t.taskId)).size !== p.tasks.length) throw new CoreError("PAYLOAD_UNSUPPORTED", "Archive task coverage mismatch");
|
|
672
|
+
const fingerprints = taskFingerprints(input);
|
|
584
673
|
for (const entry of p.tasks) {
|
|
585
674
|
const task = meta.tasks.find((t) => t.id === entry.taskId);
|
|
675
|
+
if (taskBinding(entry.events) === "task" ? entry.inputHash === void 0 || entry.inputHash !== fingerprints.get(entry.taskId) : entry.inputHash !== void 0) throw new CoreError("PAYLOAD_UNSUPPORTED", "Archive task fingerprint mismatch");
|
|
586
676
|
for (const raw of entry.events) {
|
|
587
677
|
const e = raw;
|
|
588
678
|
const { createdAt, inputHash, sourceHash, ...fields } = e;
|
|
@@ -604,7 +694,7 @@ function checkedArchivePlan(value) {
|
|
|
604
694
|
}
|
|
605
695
|
}
|
|
606
696
|
if (!task || hash(JSON.stringify(entry.events)) !== entry.eventHash || taskState(task, entry.events, {
|
|
607
|
-
inputHash: p.inputHash,
|
|
697
|
+
inputHash: entry.inputHash ?? p.inputHash,
|
|
608
698
|
sourceHash: entry.sourceHash
|
|
609
699
|
}).state !== "done") throw new CoreError("PAYLOAD_UNSUPPORTED", "Archive task evidence is incomplete");
|
|
610
700
|
}
|
|
@@ -633,270 +723,11 @@ function archiveReceipt(plan, operationId, preparedAt) {
|
|
|
633
723
|
attemptId: events[start].operationId,
|
|
634
724
|
sourceHash: t.sourceHash,
|
|
635
725
|
eventHash: t.eventHash,
|
|
726
|
+
...t.inputHash === void 0 ? {} : { inputHash: t.inputHash },
|
|
727
|
+
roundsWithFindings: events.filter((e) => e.kind === "challenge" && e.findings.length).length,
|
|
636
728
|
evidence: events.slice(start + 1)
|
|
637
729
|
};
|
|
638
730
|
})
|
|
639
731
|
};
|
|
640
732
|
}
|
|
641
|
-
|
|
642
|
-
function validatePlan(input) {
|
|
643
|
-
const value = structuredClone(planPayload(input));
|
|
644
|
-
const rebuilt = plan(value.base, value.revision);
|
|
645
|
-
const legacyId = hash(JSON.stringify({
|
|
646
|
-
revision: value.revision,
|
|
647
|
-
baseHash: value.baseHash,
|
|
648
|
-
targetHash: value.targetHash
|
|
649
|
-
}));
|
|
650
|
-
if (rebuilt.planId !== value.planId && legacyId !== value.planId || rebuilt.baseHash !== value.baseHash || rebuilt.targetHash !== value.targetHash || rebuilt.target !== value.target) throw new CoreError("PLAN_INVALID", "Plan content has been modified");
|
|
651
|
-
return freeze(value);
|
|
652
|
-
}
|
|
653
|
-
const CLI_VERSION = "0.0.0";
|
|
654
|
-
const migrationFiles = [
|
|
655
|
-
"0001_initial.sql",
|
|
656
|
-
"0002_identity.sql",
|
|
657
|
-
"0003_task_events.sql",
|
|
658
|
-
"0004_archive_operations.sql"
|
|
659
|
-
];
|
|
660
|
-
const migrations = () => migrationFiles.map((name, i) => ({
|
|
661
|
-
version: i + 1,
|
|
662
|
-
name,
|
|
663
|
-
sql: readFileSync(new URL("./migrations/" + name, import.meta.url), "utf8")
|
|
664
|
-
}));
|
|
665
|
-
function assertRegular(path) {
|
|
666
|
-
const stat = lstatSync(path);
|
|
667
|
-
if (!stat.isFile() || stat.isSymbolicLink()) throw new CoreError("INVALID_PATH", "Expected a regular file: " + path);
|
|
668
|
-
}
|
|
669
|
-
function assertNoRestore(path) {
|
|
670
|
-
if (existsSync(join(dirname(path), "restore-intent.json"))) throw new CoreError("RESTORE_INTERRUPTED", "Complete local db restore --resume before opening the journal");
|
|
671
|
-
}
|
|
672
|
-
function connect(path, readonly = false) {
|
|
673
|
-
if (!existsSync(path)) throw new CoreError("NOT_INITIALIZED", "Journal file does not exist");
|
|
674
|
-
assertRegular(path);
|
|
675
|
-
for (const suffix of [
|
|
676
|
-
"-wal",
|
|
677
|
-
"-shm",
|
|
678
|
-
"-journal"
|
|
679
|
-
]) if (existsSync(path + suffix)) assertRegular(path + suffix);
|
|
680
|
-
return new Database(path, {
|
|
681
|
-
readonly,
|
|
682
|
-
fileMustExist: true,
|
|
683
|
-
timeout: 5e3
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
function meta(db) {
|
|
687
|
-
return Number(db.pragma("user_version", { simple: true })) >= 2 ? db.prepare("SELECT * FROM journal_meta WHERE singleton=1").get() : void 0;
|
|
688
|
-
}
|
|
689
|
-
function inspectDatabase(db) {
|
|
690
|
-
const version = db.pragma("user_version", { simple: true });
|
|
691
|
-
if (version > 4) throw new CoreError("SCHEMA_TOO_NEW", "Update the CLI; journal schema is newer");
|
|
692
|
-
if (version < 1) throw new CoreError("MIGRATION_REQUIRED", "Unknown schema; refusing to reinitialize");
|
|
693
|
-
const rows = db.prepare("SELECT version,checksum FROM migrations ORDER BY version").all();
|
|
694
|
-
const available = migrations();
|
|
695
|
-
if (rows.length !== version || rows.some((r, i) => r.version !== i + 1 || r.checksum !== hash(available[i].sql))) throw new CoreError("MIGRATION_MISMATCH", "Migration ledger or checksum does not match");
|
|
696
|
-
const checks = db.pragma("integrity_check");
|
|
697
|
-
if (checks.length !== 1 || checks[0].integrity_check !== "ok" || db.pragma("foreign_key_check").length) throw new CoreError("JOURNAL_CORRUPT", "Database integrity check failed");
|
|
698
|
-
const operations = db.prepare("SELECT * FROM operations ORDER BY id").all();
|
|
699
|
-
for (const row of operations) try {
|
|
700
|
-
if (typeof row.id !== "string" || !row.id || typeof row.path !== "string" || typeof row.plan !== "string" || !["prepared", "written"].includes(String(row.write_state)) || ![
|
|
701
|
-
"not_run",
|
|
702
|
-
"running",
|
|
703
|
-
"passed",
|
|
704
|
-
"failed",
|
|
705
|
-
"interrupted"
|
|
706
|
-
].includes(String(row.verification)) || ![
|
|
707
|
-
"pending",
|
|
708
|
-
"sending",
|
|
709
|
-
"acknowledged",
|
|
710
|
-
"unknown"
|
|
711
|
-
].includes(String(row.report)) || version >= 2 && row.payload_version !== 1) throw new Error("Unsupported operation");
|
|
712
|
-
validatePlan(JSON.parse(row.plan));
|
|
713
|
-
} catch {
|
|
714
|
-
throw new CoreError("PAYLOAD_UNSUPPORTED", "Invalid or unsupported operation payload: " + String(row.id));
|
|
715
|
-
}
|
|
716
|
-
if (version >= 3) {
|
|
717
|
-
const rows = db.prepare("SELECT * FROM task_events ORDER BY sequence").all();
|
|
718
|
-
for (const row of rows) try {
|
|
719
|
-
workflowId(row.change_id);
|
|
720
|
-
const request = taskEvidence(JSON.parse(row.request)), event = JSON.parse(row.event);
|
|
721
|
-
if (!/^TASK-[0-9]{3,}$/.test(row.task_id) || row.task_id.length > 64 || row.operation_id !== request.operationId || !/^[a-f0-9]{64}$/.test(event.inputHash) || !/^[a-f0-9]{64}$/.test(event.sourceHash) || typeof event.createdAt !== "string" || !Number.isFinite(Date.parse(event.createdAt))) throw new Error();
|
|
722
|
-
const expected = {
|
|
723
|
-
...request,
|
|
724
|
-
inputHash: event.inputHash,
|
|
725
|
-
sourceHash: event.sourceHash,
|
|
726
|
-
createdAt: event.createdAt
|
|
727
|
-
};
|
|
728
|
-
if (Object.keys(event).length !== Object.keys(expected).length || Object.entries(expected).some(([k, v]) => !isDeepStrictEqual(event[k], v))) throw new Error();
|
|
729
|
-
if (request.kind !== "start" && (request.inputHash !== event.inputHash || request.sourceHash !== event.sourceHash)) throw new Error();
|
|
730
|
-
} catch {
|
|
731
|
-
throw new CoreError("PAYLOAD_UNSUPPORTED", "Invalid or unsupported task event payload");
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
const identity = meta(db);
|
|
735
|
-
if (version >= 2 && (!identity || !identity.database_id || !identity.checkout || ![0, 1].includes(identity.reconcile_required))) throw new CoreError("JOURNAL_CORRUPT", "Missing or invalid journal identity");
|
|
736
|
-
const archives = version >= 4 ? db.prepare("SELECT * FROM archive_operations ORDER BY operation_id").all() : [];
|
|
737
|
-
for (const row of archives) try {
|
|
738
|
-
const plan = checkedArchivePlan(JSON.parse(row.plan));
|
|
739
|
-
if (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(row.operation_id) || row.change_id !== plan.changeId || !["prepared", "completed"].includes(row.state) || !Number.isFinite(Date.parse(row.prepared_at))) throw new Error();
|
|
740
|
-
} catch {
|
|
741
|
-
throw new CoreError("PAYLOAD_UNSUPPORTED", "Invalid archive operation payload");
|
|
742
|
-
}
|
|
743
|
-
return {
|
|
744
|
-
schemaVersion: version,
|
|
745
|
-
identity,
|
|
746
|
-
operations,
|
|
747
|
-
archives
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
function migrate(db, identity, steps = migrations()) {
|
|
751
|
-
const from = db.pragma("user_version", { simple: true });
|
|
752
|
-
db.transaction(() => {
|
|
753
|
-
if (from === 0) db.exec("CREATE TABLE migrations (version INTEGER PRIMARY KEY, checksum TEXT NOT NULL)");
|
|
754
|
-
for (const step of steps.filter((s) => s.version > from)) {
|
|
755
|
-
const before = db.pragma("user_version", { simple: true });
|
|
756
|
-
if (step.version !== before + 1) throw new CoreError("MIGRATION_GAP", "Migration sequence is incomplete");
|
|
757
|
-
db.exec(step.sql);
|
|
758
|
-
if (step.version === 1) db.prepare("INSERT INTO migrations(version,checksum) VALUES (?,?)").run(step.version, hash(step.sql));
|
|
759
|
-
else db.prepare("INSERT INTO migrations(version,checksum,name,applied_at,cli_version) VALUES (?,?,?,?,?)").run(step.version, hash(step.sql), step.name, (/* @__PURE__ */ new Date()).toISOString(), CLI_VERSION);
|
|
760
|
-
db.pragma("user_version=" + step.version);
|
|
761
|
-
}
|
|
762
|
-
if (Number(db.pragma("user_version", { simple: true })) >= 2) {
|
|
763
|
-
db.prepare("INSERT OR IGNORE INTO journal_meta(singleton,database_id,checkout) VALUES (1,?,?)").run(identity.databaseId, identity.checkout);
|
|
764
|
-
db.prepare("UPDATE migrations SET name=? WHERE version=1 AND name='legacy'").run(migrationFiles[0]);
|
|
765
|
-
}
|
|
766
|
-
inspectDatabase(db);
|
|
767
|
-
}).immediate();
|
|
768
|
-
}
|
|
769
|
-
function newIdentity(checkout) {
|
|
770
|
-
return {
|
|
771
|
-
databaseId: randomUUID(),
|
|
772
|
-
checkout
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
function assertNoArchiveIntent(local) {
|
|
776
|
-
try {
|
|
777
|
-
lstatSync(join(local, "archive-intent.json"));
|
|
778
|
-
} catch (e) {
|
|
779
|
-
if (e.code === "ENOENT") return;
|
|
780
|
-
throw e;
|
|
781
|
-
}
|
|
782
|
-
throw new CoreError("RECOVERY_REQUIRED", "Resume archive before mutating or restoring local state");
|
|
783
|
-
}
|
|
784
|
-
// src/local/journal/index.ts
|
|
785
|
-
function openJournal(path, initialize = false) {
|
|
786
|
-
assertNoRestore(path);
|
|
787
|
-
if (!initialize && !existsSync(path)) throw new CoreError("NOT_INITIALIZED", "Run local init first");
|
|
788
|
-
const creating = !existsSync(path);
|
|
789
|
-
if (!creating) assertRegular(path);
|
|
790
|
-
const db = creating ? new Database(path, { timeout: 5e3 }) : connect(path);
|
|
791
|
-
try {
|
|
792
|
-
chmodSync(path, 384);
|
|
793
|
-
db.pragma("foreign_keys = ON");
|
|
794
|
-
db.pragma("synchronous = FULL");
|
|
795
|
-
if (creating) {
|
|
796
|
-
db.pragma("journal_mode = WAL");
|
|
797
|
-
migrate(db, newIdentity(realpathSync(dirname(path))));
|
|
798
|
-
}
|
|
799
|
-
const info = inspectDatabase(db);
|
|
800
|
-
if (info.schemaVersion < 4) throw new CoreError("MIGRATION_REQUIRED", "Run local db upgrade explicitly");
|
|
801
|
-
if (info.identity?.checkout !== realpathSync(dirname(path))) throw new CoreError("CHECKOUT_MISMATCH", "Journal belongs to another checkout");
|
|
802
|
-
if (db.pragma("journal_mode", { simple: true }) !== "wal") throw new CoreError("JOURNAL_MODE_INVALID", "Expected WAL journal");
|
|
803
|
-
function assertWritable(allowArchive = false) {
|
|
804
|
-
if (!allowArchive) assertNoArchiveIntent(dirname(path));
|
|
805
|
-
if (!allowArchive && db.prepare("SELECT 1 FROM archive_operations WHERE state='prepared'").get()) throw new CoreError("RECOVERY_REQUIRED", "Resume the pending archive before mutating local state");
|
|
806
|
-
if (meta(db)?.reconcile_required) throw new CoreError("RECONCILE_REQUIRED", "Reconcile restored data before any operation mutation");
|
|
807
|
-
}
|
|
808
|
-
return {
|
|
809
|
-
archiveGet(id) {
|
|
810
|
-
return db.prepare("SELECT * FROM archive_operations WHERE operation_id=?").get(id);
|
|
811
|
-
},
|
|
812
|
-
archiveForChange(id) {
|
|
813
|
-
return db.prepare("SELECT * FROM archive_operations WHERE change_id=?").get(id);
|
|
814
|
-
},
|
|
815
|
-
archivePrepare(row) {
|
|
816
|
-
assertWritable();
|
|
817
|
-
if (db.prepare("SELECT 1 FROM operations WHERE write_state='prepared'").get()) throw new CoreError("RECOVERY_REQUIRED", "Resume pending local operation first");
|
|
818
|
-
db.transaction(() => db.prepare("INSERT INTO archive_operations(operation_id,change_id,plan,prepared_at,state) VALUES (?,?,?,?,?)").run(row.operation_id, row.change_id, row.plan, row.prepared_at, row.state)).immediate();
|
|
819
|
-
},
|
|
820
|
-
archiveComplete(id) {
|
|
821
|
-
assertWritable(true);
|
|
822
|
-
db.prepare("UPDATE archive_operations SET state='completed' WHERE operation_id=?").run(id);
|
|
823
|
-
},
|
|
824
|
-
taskEvents(changeId, taskId) {
|
|
825
|
-
return db.prepare("SELECT event FROM task_events WHERE change_id=? AND task_id=? ORDER BY sequence").all(changeId, taskId).map((r) => JSON.parse(r.event));
|
|
826
|
-
},
|
|
827
|
-
taskRetry(operationId, changeId, taskId, request) {
|
|
828
|
-
const row = db.prepare("SELECT * FROM task_events WHERE operation_id=?").get(operationId);
|
|
829
|
-
if (!row) return null;
|
|
830
|
-
if (row.change_id !== changeId || row.task_id !== taskId || row.request !== request) throw new CoreError("IDEMPOTENCY_CONFLICT", "Operation ID belongs to different task evidence");
|
|
831
|
-
return JSON.parse(row.event);
|
|
832
|
-
},
|
|
833
|
-
appendTask(changeId, taskId, request, event) {
|
|
834
|
-
assertWritable();
|
|
835
|
-
db.transaction(() => db.prepare("INSERT INTO task_events(operation_id,change_id,task_id,request,event) VALUES (?,?,?,?,?)").run(event.operationId, changeId, taskId, request, JSON.stringify(event))).immediate();
|
|
836
|
-
return event;
|
|
837
|
-
},
|
|
838
|
-
settings() {
|
|
839
|
-
return {
|
|
840
|
-
journalMode: db.pragma("journal_mode", { simple: true }),
|
|
841
|
-
synchronous: db.pragma("synchronous", { simple: true }),
|
|
842
|
-
busyTimeout: db.pragma("busy_timeout", { simple: true }),
|
|
843
|
-
foreignKeys: db.pragma("foreign_keys", { simple: true })
|
|
844
|
-
};
|
|
845
|
-
},
|
|
846
|
-
assertWritable,
|
|
847
|
-
prepare(id, path, p) {
|
|
848
|
-
p = validatePlan(p);
|
|
849
|
-
assertWritable();
|
|
850
|
-
db.transaction(() => {
|
|
851
|
-
const old = db.prepare("SELECT * FROM operations WHERE id=?").get(id);
|
|
852
|
-
if (old) {
|
|
853
|
-
if (old.path !== path || JSON.parse(old.plan).planId !== p.planId) throw new CoreError("IDEMPOTENCY_CONFLICT", "Operation ID belongs to different content");
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
if (db.prepare("SELECT id FROM operations WHERE write_state='prepared'").get()) throw new CoreError("RECOVERY_REQUIRED", "Resume the pending operation first");
|
|
857
|
-
db.prepare("INSERT INTO operations(id,path,plan,write_state) VALUES (?,?,?,'prepared')").run(id, path, JSON.stringify(p));
|
|
858
|
-
}).immediate();
|
|
859
|
-
},
|
|
860
|
-
list() {
|
|
861
|
-
return db.prepare("SELECT id,path,write_state,verification,report FROM operations ORDER BY id").all();
|
|
862
|
-
},
|
|
863
|
-
get(id) {
|
|
864
|
-
const row = db.prepare("SELECT * FROM operations WHERE id=?").get(id);
|
|
865
|
-
if (!row) throw new CoreError("NOT_FOUND", "Operation not found");
|
|
866
|
-
return row;
|
|
867
|
-
},
|
|
868
|
-
written(id) {
|
|
869
|
-
assertWritable();
|
|
870
|
-
db.prepare("UPDATE operations SET write_state='written' WHERE id=?").run(id);
|
|
871
|
-
},
|
|
872
|
-
close() {
|
|
873
|
-
db.close();
|
|
874
|
-
},
|
|
875
|
-
async backup(path) {
|
|
876
|
-
await db.backup(path);
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
} catch (e) {
|
|
880
|
-
db.close();
|
|
881
|
-
throw e;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
/** Public discovery returns metadata only; never opens the normal writable journal adapter. */
|
|
885
|
-
function listArchiveOperations(path, all) {
|
|
886
|
-
assertNoRestore(path);
|
|
887
|
-
const db = connect(path, true);
|
|
888
|
-
try {
|
|
889
|
-
return db.transaction(() => {
|
|
890
|
-
const info = inspectDatabase(db);
|
|
891
|
-
if (info.schemaVersion < 4) throw new CoreError("MIGRATION_REQUIRED", "Run local db upgrade explicitly");
|
|
892
|
-
if (info.identity?.checkout !== realpathSync(dirname(path))) throw new CoreError("CHECKOUT_MISMATCH", "Journal belongs to another checkout");
|
|
893
|
-
if (db.pragma("journal_mode", { simple: true }) !== "wal") throw new CoreError("JOURNAL_MODE_INVALID", "Expected WAL journal");
|
|
894
|
-
return db.prepare(`SELECT operation_id AS operationId, change_id AS changeId,
|
|
895
|
-
state, prepared_at AS preparedAt FROM archive_operations
|
|
896
|
-
${all ? "" : "WHERE state='prepared'"} ORDER BY prepared_at DESC, operation_id ASC`).all();
|
|
897
|
-
})();
|
|
898
|
-
} finally {
|
|
899
|
-
db.close();
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
export { validateChange as _, assertNoRestore as a, taskState as b, inspectDatabase as c, newIdentity as d, archiveReceipt as f, validScopePath as g, deniedScopeName as h, assertNoArchiveIntent as i, meta as l, mergeFormal as m, openJournal as n, assertRegular as o, checkedArchivePlan as p, CLI_VERSION as r, connect as s, listArchiveOperations as t, migrate as u, acceptTaskEvent as v, taskEvidence as x, challengePolicy as y };
|
|
733
|
+
export { validScopePath as a, taskFingerprints as c, taskState as d, taskEvidence as f, deniedScopeName as i, acceptTaskEvent as l, checkedArchivePlan as n, validateChange as o, mergeFormal as r, taskBinding as s, archiveReceipt as t, challengePolicy as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as archiveCommand } from "./archive-BDQ_oB6g.mjs";
|
|
@@ -136,9 +136,9 @@ async function artifactCommand(action, args, project) {
|
|
|
136
136
|
if (action === "template") return artifactTemplate(args[0], args[1]);
|
|
137
137
|
const root = await findProject(project);
|
|
138
138
|
if (action === "status") {
|
|
139
|
-
const { artifactStatus } = await import("./status-
|
|
139
|
+
const { artifactStatus } = await import("./status-TcuF2Pd0.mjs");
|
|
140
140
|
if (!args.includes("--remote")) return artifactStatus(root, args[0]);
|
|
141
|
-
const { boundConnection } = await import("./project-connection-
|
|
141
|
+
const { boundConnection } = await import("./project-connection-C0nYGopT.mjs");
|
|
142
142
|
return artifactStatus(root, args[0], await boundConnection(root));
|
|
143
143
|
}
|
|
144
144
|
if ([
|
|
@@ -146,8 +146,8 @@ async function artifactCommand(action, args, project) {
|
|
|
146
146
|
"publish-status",
|
|
147
147
|
"publish-resume"
|
|
148
148
|
].includes(action)) {
|
|
149
|
-
const { publishArtifact, resumePublication } = await import("./publish-
|
|
150
|
-
const { boundConnection } = await import("./project-connection-
|
|
149
|
+
const { publishArtifact, resumePublication } = await import("./publish-DZAod5L7.mjs");
|
|
150
|
+
const { boundConnection } = await import("./project-connection-C0nYGopT.mjs");
|
|
151
151
|
const remote = await boundConnection(root);
|
|
152
152
|
return action === "publish" ? publishArtifact(root, args[0], args[2], args.includes("--dry-run"), remote, (operationId) => {
|
|
153
153
|
process.stderr.write(JSON.stringify({
|
|
@@ -227,7 +227,7 @@ async function artifactCommand(action, args, project) {
|
|
|
227
227
|
return { artifacts };
|
|
228
228
|
}
|
|
229
229
|
if (action === "feedback") {
|
|
230
|
-
const { feedback } = await import("./feedback-
|
|
230
|
+
const { feedback } = await import("./feedback-DIHPDle4.mjs");
|
|
231
231
|
return feedback(root, args);
|
|
232
232
|
}
|
|
233
233
|
if (action === "serve") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as CoreError } from "./src-CRhxwFAN.mjs";
|
|
2
|
-
import { n as serverOrigin } from "./connection-
|
|
2
|
+
import { n as serverOrigin } from "./connection-DxigvTHW.mjs";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
// src/remote/browser.ts
|
|
5
5
|
function browserCommand(platform, url) {
|
|
@@ -2,10 +2,10 @@ import { t as CoreError } from "./src-CRhxwFAN.mjs";
|
|
|
2
2
|
import { t as hash } from "./src-DeDtBfdV.mjs";
|
|
3
3
|
import { n as workflowId } from "./change-DgUPVNsm.mjs";
|
|
4
4
|
import { n as inspectWorkflow } from "./verification-B4QMPPeA.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { o as validateChange, u as challengePolicy } from "./archive-BEqNOztX.mjs";
|
|
6
6
|
import { t as findProject } from "./project-directory-w_ITkI7O.mjs";
|
|
7
|
-
import { t as bundle } from "./change-
|
|
8
|
-
import {
|
|
7
|
+
import { t as bundle } from "./change-B3CIaYav.mjs";
|
|
8
|
+
import { n as taskCommand, r as sourceFingerprint } from "./task-dw_E1Rl2.mjs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
// src/commands/challenge-brief.ts
|
|
11
11
|
const rules = [
|
|
@@ -86,8 +86,9 @@ async function challengeBrief(args, project) {
|
|
|
86
86
|
};
|
|
87
87
|
});
|
|
88
88
|
const { level, roundLimit } = challengePolicy(task);
|
|
89
|
+
const status = await taskCommand("status", [changeId, taskId], project);
|
|
89
90
|
const again = await capture();
|
|
90
|
-
if (again.inputHash !== current.inputHash || again.sourceHash !== current.sourceHash) throw new CoreError("LOCAL_CONFLICT", "Inputs changed while the brief was produced");
|
|
91
|
+
if (again.inputHash !== current.inputHash || again.sourceHash !== current.sourceHash || status.sourceHash !== current.sourceHash) throw new CoreError("LOCAL_CONFLICT", "Inputs changed while the brief was produced");
|
|
91
92
|
const text = [
|
|
92
93
|
`# Challenge brief: ${changeId} ${taskId}`,
|
|
93
94
|
"",
|
|
@@ -128,7 +129,7 @@ async function challengeBrief(args, project) {
|
|
|
128
129
|
"",
|
|
129
130
|
"## Content this brief describes",
|
|
130
131
|
"",
|
|
131
|
-
`- Documents: ${
|
|
132
|
+
`- Documents: ${status.inputHash}`,
|
|
132
133
|
`- Source: ${current.sourceHash}`,
|
|
133
134
|
"",
|
|
134
135
|
"A report is only valid for exactly this content. If the source changes, a new brief and a new round are needed.",
|
|
@@ -147,7 +148,7 @@ async function challengeBrief(args, project) {
|
|
|
147
148
|
level,
|
|
148
149
|
required: level > 0,
|
|
149
150
|
roundLimit,
|
|
150
|
-
inputHash:
|
|
151
|
+
inputHash: status.inputHash,
|
|
151
152
|
sourceHash: current.sourceHash,
|
|
152
153
|
scope: task.scope,
|
|
153
154
|
requirements,
|
|
@@ -2,10 +2,11 @@ import { t as CoreError } from "./src-CRhxwFAN.mjs";
|
|
|
2
2
|
import { t as hash } from "./src-DeDtBfdV.mjs";
|
|
3
3
|
import { n as workflowId } from "./change-DgUPVNsm.mjs";
|
|
4
4
|
import { n as inspectWorkflow, r as workflowMarkdown } from "./verification-B4QMPPeA.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { o as validateChange } from "./archive-BEqNOztX.mjs";
|
|
6
6
|
import { t as readBounded } from "./files-Ca24RKdp.mjs";
|
|
7
7
|
import { n as withLocks } from "./locks-C4XYFwbg.mjs";
|
|
8
8
|
import { t as findProject } from "./project-directory-w_ITkI7O.mjs";
|
|
9
|
+
import { i as assertNoArchiveIntent, n as openJournal } from "./journal-7SNjewV7.mjs";
|
|
9
10
|
import { t as readVerification } from "./verification-cEb-1z2d.mjs";
|
|
10
11
|
import { randomUUID } from "node:crypto";
|
|
11
12
|
import { join } from "node:path";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as changeCommand } from "./change-B3CIaYav.mjs";
|
package/dist/change-archive.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
supekku change archive-plan demo --project /path/to/project --json
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
預覽不建立 DB。回傳 `ready`、`blockers`,可封存時另有 `planHash` 和 `plan`,包含原文件、基準與目標內容、各任務 sourceHash
|
|
13
|
+
預覽不建立 DB。回傳 `ready`、`blockers`,可封存時另有 `planHash` 和 `plan`,包含原文件、基準與目標內容、各任務 sourceHash 和事件指紋;綁定任務指紋的任務另有它的 inputHash(任務指紋)。封存凍結的仍是整份 change:任務完成之後修改其他任務或 proposal 不妨礙封存,只要每個任務依自己的指紋仍是 done。Agent 應檢視前後差異,確認 scope 已包含相關程式、測試與設定;工具不證明 scope 完整,也不證明 Agent 的測試陳述真實。
|
|
14
14
|
|
|
15
15
|
計畫與完成紀錄各有64MiB上限,預覽會先檢查,超過時不建立封存操作。
|
|
16
16
|
|
|
@@ -39,11 +39,13 @@ completion.json 的 receiptVersion 為1,包含:
|
|
|
39
39
|
|
|
40
40
|
- operationId、changeId、preparedAt(操作準備時間)、planHash、inputHash。
|
|
41
41
|
- 每份正式檔案的相對路徑、beforeHash(新檔為null)與 afterHash。
|
|
42
|
-
- 每個任務的 taskId、attemptId、sourceHash、eventHash
|
|
42
|
+
- 每個任務的 taskId、attemptId、sourceHash、eventHash、inputHash(任務指紋;只有綁定任務指紋的任務才有,完成紀錄不保留 start 事件,所以這個欄位也是判斷綁定方式的依據。沒有這個欄位的任務,證據綁定最上層的 inputHash,也就是整份 change)、roundsWithFindings(這個任務所有 attempt 中含有確認發現的挑戰輪數)與該 attempt 的 TDD/Verify/Challenge/Review/finish 事件。較早版本寫下的完成紀錄沒有 roundsWithFindings。
|
|
43
43
|
- attestationOnly=true:這是當時 Agent 陳述與內容對應的歷史紀錄,不是防偽憑證或新 checkout 的執行權限。
|
|
44
44
|
|
|
45
45
|
此檔可進 Git;不包含 start 的授權文字,但其他事件的 command、summary、reviewer 與 findings 會保存,Agent 提交時必須去除敏感資訊。完整凍結計畫與事件仍保存在 `.supekku/.local/operations.sqlite`,不進 Git。
|
|
46
46
|
|
|
47
|
+
封存不會把紀錄送到任何地方。要讓專案管理者在 Web 上看到,需要另外、明確地執行 `supekku records publish`,見 [規格紀錄上傳與檢視](workflow-records.md);封存目錄中的文字會原樣上傳。
|
|
48
|
+
|
|
47
49
|
## 查詢封存操作
|
|
48
50
|
|
|
49
51
|
```sh
|
package/dist/cli-publication.md
CHANGED
|
@@ -47,6 +47,10 @@ HTML 使用獨立來源的既有隔離預覽,且須啟用既有互動政策;
|
|
|
47
47
|
|
|
48
48
|
開發驗證可執行 `pnpm test:publication:package`;它會建立臨時 PostgreSQL、loopback API、合成帳號與獨立 Keychain 項目,再從 npm tarball 驗證 connect 自動綁定、重跑與混合素材發布,最後清除測試憑證。此驗證不使用本機環境檔或真實專案。
|
|
49
49
|
|
|
50
|
+
## 規格紀錄
|
|
51
|
+
|
|
52
|
+
`supekku records publish --operation-id <UUID>` 把正式規格與已封存變更的完成紀錄上傳到已連線的專案,供管理者在 Web 逐條檢視。它沿用發布的授權(管理者的裝置),不需要重新連線;它是對外發布,需要使用者同意,不會隨封存自動執行。送出與不送出的內容、檢查與限制見 [規格紀錄上傳與檢視](workflow-records.md)。
|
|
53
|
+
|
|
50
54
|
## Web 評論唯讀存取
|
|
51
55
|
|
|
52
56
|
先執行新版 API migration(0018),再啟動新版 API/Web。裝置新增 feedback:read 權限,授權頁會說明評論與原文上下文讀取。既有裝置不會因 migration 或 token refresh 取得新權限;需要使用者執行:
|
|
@@ -40,6 +40,8 @@ function requestLimit(response, data) {
|
|
|
40
40
|
const seconds = parseRetryAfter(response.headers.get("retry-after") ?? response.headers.get("x-retry-after"));
|
|
41
41
|
return new LimitedRequest(seconds === void 0 ? "Request rate limit reached; retry manually later. No request was automatically resent." : `Request rate limit reached; retry manually after ${seconds} seconds. No request was automatically resent.`, seconds, body?.error === "slow_down" && body.code === "RATE_LIMITED");
|
|
42
42
|
}
|
|
43
|
+
const unchecked = documentCheckRefusal(response, code);
|
|
44
|
+
if (unchecked) return unchecked;
|
|
43
45
|
const messages = {
|
|
44
46
|
PUBLICATION_CONCURRENCY_LIMIT: "Publication concurrency limit reached; finish or cancel existing publication operations before retrying manually.",
|
|
45
47
|
UPLOAD_CONCURRENCY_LIMIT: "Upload concurrency limit reached; finish or cancel existing uploads before retrying manually.",
|
|
@@ -51,6 +53,18 @@ function requestLimit(response, data) {
|
|
|
51
53
|
};
|
|
52
54
|
if (!response.ok && code && messages[code]) return new CoreError(code, messages[code]);
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The server did not check what it was sent: it gave up on the check, or had no room to start
|
|
58
|
+
* one. Neither says the content is unfit. Nothing was stored, the server names a wait, and the
|
|
59
|
+
* request is never sent again by itself.
|
|
60
|
+
*/
|
|
61
|
+
function documentCheckRefusal(response, code) {
|
|
62
|
+
if (response.status !== 503) return void 0;
|
|
63
|
+
if (code !== "DOCUMENT_CHECK_ABANDONED" && code !== "DOCUMENT_CHECK_BUSY") return void 0;
|
|
64
|
+
const seconds = parseRetryAfter(response.headers.get("retry-after") ?? response.headers.get("x-retry-after"));
|
|
65
|
+
const wait = seconds === void 0 ? "later" : `after ${seconds} seconds`;
|
|
66
|
+
return new CoreError(code, (code === "DOCUMENT_CHECK_ABANDONED" ? "The server gave up checking the content before it finished (its time or memory limit for one check); nothing was stored. This does not say the content is unfit, but very large or unusually dense Markdown can exceed the limit every time." : "The server's document checks are busy, or this device is waiting after an abandoned check; nothing was stored.") + ` Retry manually ${wait} with the same operation ID. No request was automatically resent.`, seconds);
|
|
67
|
+
}
|
|
54
68
|
// src/remote/connection.ts
|
|
55
69
|
function serverOrigin(input) {
|
|
56
70
|
let u;
|
|
@@ -273,4 +287,4 @@ function createConnection(options) {
|
|
|
273
287
|
}
|
|
274
288
|
};
|
|
275
289
|
}
|
|
276
|
-
export { serverOrigin as n,
|
|
290
|
+
export { requestLimit as i, serverOrigin as n, documentCheckRefusal as r, createConnection as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as CoreError } from "./src-CRhxwFAN.mjs";
|
|
2
|
-
import { n as directoryPresence, s as projectObservation } from "./project-
|
|
2
|
+
import { n as directoryPresence, s as projectObservation } from "./project-CMFCxtKO.mjs";
|
|
3
3
|
import { t as nodeSupported } from "./package-Ci4aNmkW.mjs";
|
|
4
4
|
import { a as targetPath, i as skillStatus } from "./skills-DcxDoyH7.mjs";
|
|
5
5
|
import { join } from "node:path";
|