strom-research 1.22.0 → 1.22.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/dist/core/tree.js CHANGED
@@ -21,7 +21,7 @@ import { settledRecord, validateRecord } from "./validate.js";
21
21
  import { NeedsConsentError, StromError, UsageError } from "./errors.js";
22
22
  import * as git from "./git.js";
23
23
  import { opsLogs } from "./opslog.js";
24
- import { commitSeal, createKey, fingerprint, loadKey, sha256, signOp } from "./seal.js";
24
+ import { commitSeal, createKey, fingerprint, loadKey, settleKey, sha256, signOp, verifyCommitSeal } from "./seal.js";
25
25
  import { stringifyCanonical } from "./json.js";
26
26
  import { lastBackup } from "./backup.js";
27
27
  export const TREE_FILE = "strom.json";
@@ -29,7 +29,7 @@ export const TREE_FILE = "strom.json";
29
29
  export const SEAL_FOREIGN = "seal.foreign";
30
30
  // between releases the candidate being made (a bridge run from the sources says what it is: the Strom app goes by it);
31
31
  // at a release the release's own (package.json)
32
- export const VERSION = "1.22.0";
32
+ export const VERSION = "1.22.2";
33
33
  const GITIGNORE = `# Strom Research — local state and large files are not versioned
34
34
  .strom/
35
35
  /media/
@@ -569,7 +569,7 @@ export class Tree {
569
569
  /** The tree's seal key on this computer, or undefined (tree moved here). */
570
570
  get key() {
571
571
  if (this.keyCache === undefined)
572
- this.keyCache = loadKey(this.env, this.config.id) ?? null;
572
+ this.keyCache = settleKey(this.env, this.config.id, (key) => this.headSealedWith(key)) ?? null;
573
573
  return this.keyCache ?? undefined;
574
574
  }
575
575
  lastStamp = 0;
@@ -582,6 +582,11 @@ export class Tree {
582
582
  opsFilesTouched() {
583
583
  return [...this.touchedOps].map((f) => this.relative(f));
584
584
  }
585
+ /** Whether the last commit carries the seal of this key. */
586
+ headSealedWith(key) {
587
+ const head = git.headInfo(this.root);
588
+ return !!head && verifyCommitSeal(key, head.tree, head.message);
589
+ }
585
590
  /** Forget the cached key (after one was created on this computer). */
586
591
  reloadKey() {
587
592
  this.keyCache = undefined;
@@ -605,7 +610,8 @@ export class Tree {
605
610
  ], undefined, undefined, { code: SEAL_FOREIGN, params: { name: this.config.name, set: "strom seal adopt" } });
606
611
  }
607
612
  /** Sealed commit of everything under pathspec. */
608
- commit(message, pathspec = ["."]) {
613
+ /** `always`: a commit even when nothing changed (strom repair sealing again what was committed outside strom). */
614
+ commit(message, pathspec = ["."], always = false) {
609
615
  const key = this.requireKey();
610
616
  // its IDs on disk before it commits (written once here, not after every record: a sync of 2 200 people wrote the
611
617
  // counters thousands of times)
@@ -613,7 +619,7 @@ export class Tree {
613
619
  // another process may have committed since this one last looked — under the lock it read HEAD afresh already
614
620
  if (this.lockDepth === 0)
615
621
  git.resetCache(this.root);
616
- const hash = git.commitAll(this.root, message, pathspec, (treeHash) => commitSeal(key, treeHash));
622
+ const hash = git.commitAll(this.root, message, pathspec, (treeHash) => commitSeal(key, treeHash), always);
617
623
  // the logs this commit holds are closed: what comes next goes into new ones
618
624
  this.opsNow.clear();
619
625
  if (hash) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strom-research",
3
- "version": "1.22.0",
3
+ "version": "1.22.2",
4
4
  "description": "Genealogical research toolkit for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {