strom-research 1.30.0 → 1.30.1
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/CHANGELOG.cs.md +13 -0
- package/CHANGELOG.de.md +14 -0
- package/CHANGELOG.md +13 -0
- package/CHANGELOG.pl.md +14 -0
- package/assets/lang/cs.json +36 -0
- package/assets/lang/de.json +36 -0
- package/assets/lang/pl.json +36 -0
- package/assets/strom-doc/CISLA.md +5 -0
- package/assets/strom-doc/PIN +1 -1
- package/assets/strom-doc/REJSTRIK.md +12 -0
- package/assets/strom-doc/cs/R14-seal-and-integrity.md +99 -0
- package/assets/strom-doc/cs/README.md +1 -0
- package/assets/strom-doc/de/R14-seal-and-integrity.md +113 -0
- package/assets/strom-doc/de/README.md +1 -0
- package/assets/strom-doc/en/R14-seal-and-integrity.md +104 -0
- package/assets/strom-doc/en/README.md +1 -0
- package/assets/strom-doc/pl/R14-seal-and-integrity.md +106 -0
- package/assets/strom-doc/pl/README.md +1 -0
- package/dist/cli/help.js +3 -3
- package/dist/cli/main.js +1 -1
- package/dist/cli/ui.js +36 -0
- package/dist/commands/checks.js +83 -4
- package/dist/core/accept.js +240 -0
- package/dist/core/git.js +14 -0
- package/dist/core/integrity.js +20 -1
- package/dist/core/tree.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// strom seal accept — the research as it is now taken as the new sealed base, by the person.
|
|
2
|
+
//
|
|
3
|
+
// What it is for: the records are as strom wrote them, but what sealed them is gone — the oldest logs of the history
|
|
4
|
+
// (data/ops) taken away by a cloud drive, the research's git history damaged so that strom repair has nothing to put
|
|
5
|
+
// back (found 2026-11-09: a research once in iCloud Drive, its .git missing objects, no other copy). strom verify then
|
|
6
|
+
// says every record whose last operation was in a lost log "created/edited outside strom", and strom repair would
|
|
7
|
+
// return an older state or nothing at all.
|
|
8
|
+
//
|
|
9
|
+
// What it does, nothing more: one signed operation (seal.accept) naming the hash of every file the full check finds
|
|
10
|
+
// not sealed as it is now — no record's content changed, nothing deleted — and a sealed commit of it. A git history
|
|
11
|
+
// that cannot be read is moved aside whole (.git-damaged-<when>, never deleted) and a new one begins with that commit.
|
|
12
|
+
// iCloud's copies of a file ("P0001 2.json") inside what strom seals are moved aside into .strom/accepted-<when>/,
|
|
13
|
+
// never sealed as records; copies elsewhere are only said.
|
|
14
|
+
//
|
|
15
|
+
// Never what the check finds of another kind (a log rewritten, an operation forged, another key, files only in the
|
|
16
|
+
// cloud, a record deleted): those are refused, said as the check says them. The person's own, in their terminal
|
|
17
|
+
// (cli: the gate as strom seal adopt); an agent never runs it.
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import * as git from "./git.js";
|
|
21
|
+
import { verifyFull } from "./integrity.js";
|
|
22
|
+
import { RECORD_TYPES } from "./model.js";
|
|
23
|
+
import { fileSha } from "./seal.js";
|
|
24
|
+
import { typeOfId } from "./tree.js";
|
|
25
|
+
import { StromError } from "./errors.js";
|
|
26
|
+
/** What the check finds that accepting settles: a file not sealed as it is now, a last commit strom did not seal. */
|
|
27
|
+
const SETTLED = new Set(["unsealed", "manual-edit", "history-edited", "quality-edited", "config-edited", "foreign-commit"]);
|
|
28
|
+
/** The folders of the research strom alone writes (what strom seals): iCloud's copies there are moved aside. */
|
|
29
|
+
const SEALED_DIRS = ["data", "history", "quality"];
|
|
30
|
+
/**
|
|
31
|
+
* The way the check says for a file not sealed as it is, when strom repair has nothing to put back: the research's git
|
|
32
|
+
* history cannot be read (or there is none). Never otherwise — a readable history puts the lost logs back (strom repair).
|
|
33
|
+
*/
|
|
34
|
+
export const ACCEPT_HINT = "the history (git) is damaged and strom repair cannot restore it — once the user looked the records over, the user runs in their terminal: strom seal accept (an agent never runs it)";
|
|
35
|
+
/**
|
|
36
|
+
* The check's findings with what the git history says: one that cannot be read (or none) is a finding of its own, and
|
|
37
|
+
* those accepting settles are said with its way — strom repair has nothing to put back. A readable history says nothing
|
|
38
|
+
* here: strom repair puts the lost logs back from it.
|
|
39
|
+
*/
|
|
40
|
+
export function acceptWay(tree, findings) {
|
|
41
|
+
const missing = !fs.existsSync(path.join(tree.root, ".git"));
|
|
42
|
+
if (!missing && !git.damaged(tree.root))
|
|
43
|
+
return findings;
|
|
44
|
+
for (const f of findings)
|
|
45
|
+
if (f.level === "error" && SETTLED.has(f.code))
|
|
46
|
+
f.hint = ACCEPT_HINT;
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
level: "error",
|
|
50
|
+
code: GIT_DAMAGED,
|
|
51
|
+
file: ".git",
|
|
52
|
+
message: missing ? "the research has no history (git)" : "the history (git) cannot be read — objects of it are missing",
|
|
53
|
+
hint: ACCEPT_HINT,
|
|
54
|
+
},
|
|
55
|
+
...findings,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
export const GIT_DAMAGED = "git-damaged";
|
|
59
|
+
/** guard's findings, none when the git history cannot be read (acceptWay says that). */
|
|
60
|
+
export function guardOrDamaged(tree, guard) {
|
|
61
|
+
try {
|
|
62
|
+
return guard();
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (!fs.existsSync(path.join(tree.root, ".git")) || git.damaged(tree.root))
|
|
66
|
+
return [];
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** An iCloud copy's name: "<name> 2.<ext>" (the number iCloud adds), never a name strom gives a file of its own. */
|
|
71
|
+
export function isCloudCopy(name) {
|
|
72
|
+
return /^.+ \d+(\.[^./ ]+)?$/u.test(name);
|
|
73
|
+
}
|
|
74
|
+
export function gitState(root, findings) {
|
|
75
|
+
if (!fs.existsSync(path.join(root, ".git")))
|
|
76
|
+
return "missing";
|
|
77
|
+
if (git.damaged(root))
|
|
78
|
+
return "damaged";
|
|
79
|
+
return findings.some((f) => f.code === "foreign-commit") ? "unsealed" : "ok";
|
|
80
|
+
}
|
|
81
|
+
/** A record file as strom writes one: JSON whose id is its name, in the folder of its type. */
|
|
82
|
+
function recordReadable(root, rel) {
|
|
83
|
+
const id = path.posix.basename(rel, ".json");
|
|
84
|
+
const type = typeOfId(id);
|
|
85
|
+
if (!type || path.posix.dirname(rel) !== `data/${RECORD_TYPES[type].dir}`)
|
|
86
|
+
return false;
|
|
87
|
+
try {
|
|
88
|
+
const record = JSON.parse(fs.readFileSync(path.join(root, ...rel.split("/")), "utf8"));
|
|
89
|
+
return record.id === id;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** iCloud's copies in the research (tree-relative, "/"): inside what strom seals, of its lock, and elsewhere. */
|
|
96
|
+
function cloudCopies(root) {
|
|
97
|
+
const moveAside = [];
|
|
98
|
+
const copies = [];
|
|
99
|
+
const walk = (dir, rel, into, deep) => {
|
|
100
|
+
let entries;
|
|
101
|
+
try {
|
|
102
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
for (const e of entries) {
|
|
108
|
+
if (e.isDirectory()) {
|
|
109
|
+
if (deep)
|
|
110
|
+
walk(path.join(dir, e.name), `${rel}${e.name}/`, into, deep);
|
|
111
|
+
}
|
|
112
|
+
else if (e.isFile() && isCloudCopy(e.name))
|
|
113
|
+
into.push(`${rel}${e.name}`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
for (const d of SEALED_DIRS)
|
|
117
|
+
walk(path.join(root, d), `${d}/`, moveAside, true);
|
|
118
|
+
// the research's own files beside them (strom.json's copy), strom's state and what it writes for the app
|
|
119
|
+
walk(root, "", copies, false);
|
|
120
|
+
walk(path.join(root, ".strom"), ".strom/", copies, false);
|
|
121
|
+
walk(path.join(root, "output"), "output/", copies, false);
|
|
122
|
+
// a copy of a lock stands for a process that is not there: out of the way with the rest
|
|
123
|
+
for (const c of copies.filter((p) => p.startsWith(".strom/") && p.endsWith(".lock")))
|
|
124
|
+
moveAside.push(c);
|
|
125
|
+
return { moveAside: moveAside.sort(), copies: copies.filter((c) => !moveAside.includes(c)).sort() };
|
|
126
|
+
}
|
|
127
|
+
/** What accepting the research as it is would do — read only. */
|
|
128
|
+
export function planAccept(tree) {
|
|
129
|
+
const { findings } = verifyFull(tree);
|
|
130
|
+
const { moveAside, copies } = cloudCopies(tree.root);
|
|
131
|
+
const aside = new Set(moveAside);
|
|
132
|
+
const plan = { files: [], unsealed: [], edited: [], outside: [], other: [], logs: 0, git: gitState(tree.root, findings), moveAside, copies, refused: [] };
|
|
133
|
+
plan.logs = countLogs(tree.root);
|
|
134
|
+
for (const f of findings) {
|
|
135
|
+
if (f.level !== "error")
|
|
136
|
+
continue;
|
|
137
|
+
if (f.file && aside.has(f.file))
|
|
138
|
+
continue;
|
|
139
|
+
if (!SETTLED.has(f.code)) {
|
|
140
|
+
plan.refused.push(f);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (f.code === "foreign-commit")
|
|
144
|
+
continue;
|
|
145
|
+
const rel = f.file;
|
|
146
|
+
const abs = path.join(tree.root, ...rel.split("/"));
|
|
147
|
+
const sha = fileSha(abs);
|
|
148
|
+
const record = rel.startsWith("data/");
|
|
149
|
+
if (sha === undefined || (record && !recordReadable(tree.root, rel))) {
|
|
150
|
+
plan.refused.push({ ...f, message: `${f.message} — not a record strom can read, never sealed as one` });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
plan.files.push({ path: rel, sha });
|
|
154
|
+
if (!record)
|
|
155
|
+
plan.other.push(rel);
|
|
156
|
+
else if (plan.git === "ok" || plan.git === "unsealed")
|
|
157
|
+
plan.outside.push(rel);
|
|
158
|
+
else
|
|
159
|
+
(f.code === "unsealed" ? plan.unsealed : plan.edited).push(rel);
|
|
160
|
+
}
|
|
161
|
+
plan.files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
162
|
+
return plan;
|
|
163
|
+
}
|
|
164
|
+
function countLogs(root) {
|
|
165
|
+
let n = 0;
|
|
166
|
+
const walk = (dir) => {
|
|
167
|
+
let entries;
|
|
168
|
+
try {
|
|
169
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
for (const e of entries) {
|
|
175
|
+
if (e.isDirectory())
|
|
176
|
+
walk(path.join(dir, e.name));
|
|
177
|
+
else if (e.name.endsWith(".jsonl") && !isCloudCopy(e.name))
|
|
178
|
+
n++;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
walk(path.join(root, "data", "ops"));
|
|
182
|
+
return n;
|
|
183
|
+
}
|
|
184
|
+
/** Nothing to accept: every file sealed as it is, the last commit strom's and readable, no copy in the way. */
|
|
185
|
+
export function nothingToAccept(plan) {
|
|
186
|
+
return plan.files.length === 0 && plan.moveAside.length === 0 && plan.git === "ok";
|
|
187
|
+
}
|
|
188
|
+
/** The plan as it decides what is done — the same files and hashes, the same state of git. */
|
|
189
|
+
function samePlan(a, b) {
|
|
190
|
+
const key = (p) => JSON.stringify([p.files, p.git, p.moveAside, p.refused.length]);
|
|
191
|
+
return key(a) === key(b);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Accept the research as it is (the plan the person said yes to). Under the tree's lock: the plan made again first —
|
|
195
|
+
* anything changed since, nothing done. Throws when anything is refused.
|
|
196
|
+
*/
|
|
197
|
+
export function applyAccept(tree, agreed, at = new Date()) {
|
|
198
|
+
return tree.withTreeLock(() => {
|
|
199
|
+
const plan = planAccept(tree);
|
|
200
|
+
if (!samePlan(plan, agreed))
|
|
201
|
+
throw new StromError("the research changed since it was looked over — nothing accepted", { hint: "strom seal accept (looks it over again)", code: "accept.changed" });
|
|
202
|
+
if (plan.refused.length)
|
|
203
|
+
throw new StromError("the check finds what accepting never settles — nothing accepted", { hint: "strom verify", code: "accept.refused" });
|
|
204
|
+
if (nothingToAccept(plan))
|
|
205
|
+
return { sealed: 0, commit: undefined };
|
|
206
|
+
const stamp = at.toISOString().replace(/\.\d+Z$/u, "Z").replace(/[:]/gu, "-");
|
|
207
|
+
const out = { sealed: plan.files.length, commit: undefined };
|
|
208
|
+
if (plan.moveAside.length) {
|
|
209
|
+
const into = `.strom/accepted-${stamp}`;
|
|
210
|
+
for (const rel of plan.moveAside) {
|
|
211
|
+
const dest = path.join(tree.root, ...into.split("/"), ...rel.split("/"));
|
|
212
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
213
|
+
fs.renameSync(path.join(tree.root, ...rel.split("/")), dest);
|
|
214
|
+
}
|
|
215
|
+
out.copiesMoved = into;
|
|
216
|
+
}
|
|
217
|
+
if (plan.git === "damaged" || plan.git === "missing") {
|
|
218
|
+
if (plan.git === "damaged") {
|
|
219
|
+
const moved = `.git-damaged-${stamp}`;
|
|
220
|
+
fs.renameSync(path.join(tree.root, ".git"), path.join(tree.root, moved));
|
|
221
|
+
out.gitMoved = moved;
|
|
222
|
+
}
|
|
223
|
+
git.initRepo(tree.root);
|
|
224
|
+
// the history moved aside stays beside the research, never in the new one
|
|
225
|
+
fs.mkdirSync(path.join(tree.root, ".git", "info"), { recursive: true });
|
|
226
|
+
fs.appendFileSync(path.join(tree.root, ".git", "info", "exclude"), "/.git-damaged-*/\n");
|
|
227
|
+
git.resetCache(tree.root);
|
|
228
|
+
}
|
|
229
|
+
const n = plan.files.length;
|
|
230
|
+
tree.appendOp({
|
|
231
|
+
op: "seal.accept",
|
|
232
|
+
targets: [],
|
|
233
|
+
files: plan.files,
|
|
234
|
+
summary: `The research accepted as it is: ${n} ${n === 1 ? "file" : "files"} sealed again (their history missing)`,
|
|
235
|
+
});
|
|
236
|
+
const why = out.gitMoved ? `\n\nThe git history could not be read; it was moved aside to ${out.gitMoved}.` : "";
|
|
237
|
+
out.commit = tree.commit(`Seal: the research accepted as it is (${n} ${n === 1 ? "file" : "files"} sealed again)${why}`, ["."], true);
|
|
238
|
+
return out;
|
|
239
|
+
});
|
|
240
|
+
}
|
package/dist/core/git.js
CHANGED
|
@@ -249,6 +249,20 @@ function identityLines(dir) {
|
|
|
249
249
|
const lines = [...(has("user.name") ? [] : ["\tname = Strom"]), ...(has("user.email") ? [] : ["\temail = strom@localhost"])];
|
|
250
250
|
return lines.length ? ["[user]", ...lines] : [];
|
|
251
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Is the research's git history unusable as strom uses it: no last commit to read, its tree (or one inside it)
|
|
254
|
+
* missing, git status failing. Cheap enough for every check (no fsck: a research's history may be long). A research
|
|
255
|
+
* with no .git is "missing", not damaged.
|
|
256
|
+
*/
|
|
257
|
+
export function damaged(root) {
|
|
258
|
+
if (!fs.existsSync(path.join(root, ".git")))
|
|
259
|
+
return false;
|
|
260
|
+
if (runGit(root, ["rev-parse", "--verify", "-q", "HEAD^{commit}"]).status !== 0)
|
|
261
|
+
return true;
|
|
262
|
+
if (runGit(root, ["ls-tree", "-r", "-z", "--name-only", "HEAD"]).status !== 0)
|
|
263
|
+
return true;
|
|
264
|
+
return runGit(root, ["status", "--porcelain", "-z", "--", "strom.json"]).status !== 0;
|
|
265
|
+
}
|
|
252
266
|
// HEAD only changes when strom commits, so it is read once per command.
|
|
253
267
|
const headCache = new Map();
|
|
254
268
|
/**
|
package/dist/core/integrity.js
CHANGED
|
@@ -545,7 +545,16 @@ export function lastSealed(tree, key) {
|
|
|
545
545
|
export const REPAIR_IN_TERMINAL_HINT = "the user runs in their terminal: strom repair, then strom seal adopt (it sees both keys and undoes only what was done outside strom)";
|
|
546
546
|
/** Refuse to write on top of data that was changed outside strom. */
|
|
547
547
|
export function assertIntact(tree) {
|
|
548
|
-
|
|
548
|
+
let snap;
|
|
549
|
+
try {
|
|
550
|
+
snap = snapshot(tree);
|
|
551
|
+
}
|
|
552
|
+
catch (e) {
|
|
553
|
+
// git cannot read its own history (objects missing — a cloud drive took them): said so, with the person's way
|
|
554
|
+
if (git.damaged(tree.root))
|
|
555
|
+
throw gitDamagedError();
|
|
556
|
+
throw e;
|
|
557
|
+
}
|
|
549
558
|
const { findings } = verifyFast(tree, snap);
|
|
550
559
|
const errors = findings.filter((f) => f.level === "error");
|
|
551
560
|
if (errors.length === 0) {
|
|
@@ -579,6 +588,16 @@ export function assertIntact(tree) {
|
|
|
579
588
|
...(way ? { hintCode: inTerminal ? "tree.changed-outside.terminal" : "tree.changed-outside.keys" } : {}),
|
|
580
589
|
});
|
|
581
590
|
}
|
|
591
|
+
/**
|
|
592
|
+
* Writing refused while the research's git history cannot be read (git.damaged): strom repair has nothing to put back;
|
|
593
|
+
* the person, having looked the records over, accepts the research as it is (strom seal accept), in their terminal.
|
|
594
|
+
*/
|
|
595
|
+
export function gitDamagedError() {
|
|
596
|
+
return new StromError("the history (git) of the research is damaged — nothing written", {
|
|
597
|
+
hint: "strom verify (details)\nonce the user looked the records over, the user runs in their terminal: strom seal accept (an agent never runs it)",
|
|
598
|
+
code: "tree.git-damaged",
|
|
599
|
+
});
|
|
600
|
+
}
|
|
582
601
|
/**
|
|
583
602
|
* Writing refused while files of the research are only in iCloud (a write would commit them as deleted): how many, the
|
|
584
603
|
* first, and the way — never strom repair. Its code for a program (tree.not-downloaded), the person's words in their
|
package/dist/core/tree.js
CHANGED
|
@@ -32,7 +32,7 @@ export const TREE_FILE = "strom.json";
|
|
|
32
32
|
export const SEAL_FOREIGN = "seal.foreign";
|
|
33
33
|
// between releases the candidate being made (a bridge run from the sources says what it is: the Strom app goes by it);
|
|
34
34
|
// at a release the release's own (package.json)
|
|
35
|
-
export const VERSION = "1.30.
|
|
35
|
+
export const VERSION = "1.30.1";
|
|
36
36
|
/** What a new research is settled with from the start: nothing an older strom counted otherwise to set right in it. */
|
|
37
37
|
export const NEW_TREE_SETTLED = ["readers-1", "proven-originals-1", "origins-1", "verify-originals-1", "origins-tree-1"];
|
|
38
38
|
const GITIGNORE = `# Strom Research — local state and large files are not versioned
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strom-research",
|
|
3
|
-
"version": "1.30.
|
|
4
|
-
"stromDoc": "
|
|
3
|
+
"version": "1.30.1",
|
|
4
|
+
"stromDoc": "f9ad9cd5851455e5bdf7b93b7d80907bedc20e79",
|
|
5
5
|
"description": "Genealogical research toolkit for AI coding agents",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"stromLayout": 2,
|