@open-tomato/rafa 0.52.1 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,9 +4,9 @@ import {
4
4
  CONFIG_TEMPLATES,
5
5
  SETTINGS,
6
6
  SETTING_NAMES
7
- } from "../index-nqaqh4zz.js";
7
+ } from "../index-78zcdjf5.js";
8
8
  import"../index-jjxnyqvy.js";
9
- import"../index-m672ptpg.js";
9
+ import"../index-dj8en7fg.js";
10
10
  import"../index-fpgmdmww.js";
11
11
 
12
12
  // src/config/entry.ts
@@ -57,7 +57,7 @@ export interface RafaConfig {
57
57
  learningBlessMinConfidence: number;
58
58
  /** The distinct sources a lesson needs to be promotable. `learning.promote.after`. */
59
59
  learningPromoteAfter: number;
60
- /** The least confidence of a promotable lesson. `learning.promote.minConfidence`. */
60
+ /** The least pooled confidence of a promotable same-action group, 0.6 by default. `learning.promote.minConfidence`. */
61
61
  learningPromoteMinConfidence: number;
62
62
  /** How commands write their output. `output.mode`. */
63
63
  outputMode: OutputMode;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The form a session row stores a log's path in.
3
+ *
4
+ * @param absolutePath - The log's absolute path, as the collector read it.
5
+ * @param home - The home directory whose projects root the path is cut against.
6
+ * @returns `<folder>/<file>` for a path under `<home>/.claude/projects/`,
7
+ * and the path unchanged for any other, a `logDir` override's included.
8
+ */
9
+ export declare function storedLogPath(absolutePath: string, home: string): string;
10
+ /**
11
+ * The stored form of a value a row already holds, whatever machine wrote it.
12
+ *
13
+ * An absolute value is cut after its last `/.claude/projects/`, so the
14
+ * home before it, on whatever machine, is dropped. The last rather than
15
+ * the first, because a folder name never holds a `/` and so never the
16
+ * marker, while a home could.
17
+ *
18
+ * @param value - A row's `filePath`, or whatever the row holds there.
19
+ * @returns The relative form for an absolute value under a projects root,
20
+ * and the value unchanged otherwise: a relative one, one outside the
21
+ * root, one whose rest is refused, and one that is not a string.
22
+ */
23
+ export declare function storedLogPathOf<T>(value: T): T | string;
24
+ /**
25
+ * The file a stored value names on this machine.
26
+ *
27
+ * @param stored - A row's stored `filePath`.
28
+ * @param home - The reading machine's home directory.
29
+ * @returns The absolute path under `<home>/.claude/projects/` for a
30
+ * relative value, the value itself for an absolute one, and `null` for a
31
+ * value refused as a relative path: empty, holding `\`, or climbing out
32
+ * of the root.
33
+ */
34
+ export declare function resolveSessionLogPath(stored: string, home: string): string | null;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The rows a backend's `read` answers, as against the rows it stores.
3
+ *
4
+ * Both backends store a row's bytes as the collector wrote them and
5
+ * never rewrite them: the store is append-only, and its bytes are what
6
+ * `keys`, the merge and the wire read. What `read` hands a caller is
7
+ * those rows passed through {@link answeredRows}, one function both
8
+ * `sqlite.ts` and `ndjson.ts` call, so the two backends' answers cannot
9
+ * drift apart.
10
+ *
11
+ * One rewrite lives here today. A session row written before the stored
12
+ * form (#1489) holds its log's absolute path in `filePath`, the writing
13
+ * machine's home directory included. Its `filePath` is answered through
14
+ * `storedLogPathOf` (`session-log-path.ts`), so an absolute value under
15
+ * a `/.claude/projects/` root, on a Linux or a macOS home alike, reads
16
+ * as the `<folder>/<file>` form a fresh collect stores. Any other value
17
+ * reads unchanged, and a row with no `filePath` at all, such as the hub
18
+ * contract's template row, is answered as it is, with no key added.
19
+ *
20
+ * A row the rewrite leaves alone is answered as the same object the
21
+ * backend parsed, and a rewritten one as a fresh copy, so no stored row
22
+ * is mutated on its way out. Commit rows hold no path and pass through.
23
+ *
24
+ * `keys` reads the key column or the key projection, never this, so
25
+ * the rewrite cannot change what a collector skips. The NDJSON
26
+ * backend's `readRows`, the raw reading `move.ts` copies a store with,
27
+ * does not pass through here either: a move carries the bytes it found.
28
+ */
29
+ import type { EffortRow, EffortRowKind } from './types.js';
30
+ /**
31
+ * The rows one kind answers from `read`, given the rows it stores.
32
+ *
33
+ * @param kind - The kind the rows were read under.
34
+ * @param rows - The rows as parsed from the store, in append order.
35
+ * @returns A fresh array in the same order, each session row's old
36
+ * absolute `filePath` answered in its stored form.
37
+ */
38
+ export declare function answeredRows<K extends EffortRowKind>(kind: K, rows: readonly EffortRow<K>[]): EffortRow<K>[];
@@ -13,12 +13,12 @@ import {
13
13
  openNdjsonStore,
14
14
  openSqliteStore,
15
15
  selectEffortStore
16
- } from "../../index-1tdzcheq.js";
16
+ } from "../../index-anvmm83x.js";
17
17
  import {
18
18
  TRUSTED_PERMISSIONS
19
- } from "../../index-4dwaxd5r.js";
19
+ } from "../../index-rkrsdes6.js";
20
20
  import"../../index-2a7nb3an.js";
21
- import"../../index-m672ptpg.js";
21
+ import"../../index-dj8en7fg.js";
22
22
  import {
23
23
  STORE_BACKENDS
24
24
  } from "../../index-fpgmdmww.js";
@@ -21,10 +21,14 @@
21
21
  * `field` naming the column. Under {@link RECOMPUTED} the two values
22
22
  * are compared without the part the merge recomputes, through the
23
23
  * field's entry in {@link RECOMPUTED_COMPARISONS}: `commits.row_json`
24
- * without its `minutesSincePrevious` (`merge-commit-gaps.ts`). Equal
25
- * so, the pair is skipped and the row here kept; the gap of a commit
26
- * brought in is the merge's to rewrite, not a matched one's. Unequal,
27
- * the rows differ outside every edited field, below.
24
+ * without its `minutesSincePrevious` (`merge-commit-gaps.ts`), and
25
+ * `sessions.row_json` with its `filePath` passed through
26
+ * `storedLogPathOf` (`session-log-path.ts`), so an old row's absolute
27
+ * path and a fresh row's `<folder>/<file>` compare alike. Equal so, the
28
+ * pair is skipped and the row here kept: the gap of a commit brought in
29
+ * is the merge's to rewrite, not a matched one's, and a session's path
30
+ * is answered in its stored form by `read` whichever form the row here
31
+ * holds. Unequal, the rows differ outside every edited field, below.
28
32
  * - **Any other difference**: the incoming row is recorded with `field`
29
33
  * NULL, and the row here is left as it is, edited fields included. The
30
34
  * same `(origin_store, origin_seq)` holding different content can only
@@ -28,7 +28,9 @@
28
28
  *
29
29
  * The store is almost append-only. A column a production statement
30
30
  * changes after the insert is an edited field, and the merge has to know
31
- * which of two stores' values to keep. There are two today.
31
+ * which of two stores' values to keep, or, for a column no statement
32
+ * changes, a value two stores may hold in two forms that read alike.
33
+ * There are three today.
32
34
  * `findings.tracker_ref`, written by `writeTrackerRef`
33
35
  * (`tracker-refs.ts`) once a bug is filed, is {@link SET_ONCE}: a
34
36
  * filled value beats NULL, and two different filled values mean one
@@ -39,6 +41,13 @@
39
41
  * is rewritten by the merge itself (`merge-commit-gaps.ts`) for each
40
42
  * commit brought in and the commit after it in time, so two rows of one
41
43
  * commit that differ only in that key are the same row.
44
+ * `sessions.row_json` is {@link RECOMPUTED} too, though no statement
45
+ * rewrites it: its `filePath` is stored as `<folder>/<file>` by a fresh
46
+ * collect and as an absolute path by a row written before that form
47
+ * (#1489), and `read` answers both alike (`answered-rows.ts`). So two
48
+ * rows of one session whose `row_json` differ only in that form, with
49
+ * `filePath` passed through `storedLogPathOf` (`session-log-path.ts`),
50
+ * are the same row.
42
51
  *
43
52
  * ## What holds the registry to the schema
44
53
  *
@@ -57,9 +66,11 @@ export type MergeScope = 'merged' | 'local';
57
66
  */
58
67
  export declare const SET_ONCE = "set-once";
59
68
  /**
60
- * The merge recomputes the field from the rows it holds, so two stores'
61
- * values of it are never compared: for `commits.row_json`, its
62
- * `minutesSincePrevious` key.
69
+ * Part of the field is the merge's or the reader's to derive, so two
70
+ * stores' values of it are compared without that part: for
71
+ * `commits.row_json`, its `minutesSincePrevious` key, which the merge
72
+ * recomputes; for `sessions.row_json`, the form of its `filePath`, which
73
+ * `read` answers in the stored form either way.
63
74
  */
64
75
  export declare const RECOMPUTED = "recomputed";
65
76
  /** How a merge settles an edited field whose two stores disagree. */
@@ -69,7 +80,7 @@ export interface MergedTableRule {
69
80
  readonly scope: 'merged';
70
81
  /** The columns two rows with a NULL origin are matched by. */
71
82
  readonly identity: readonly string[];
72
- /** Every column a production statement changes after the insert, with its rule. */
83
+ /** Every column a production statement changes after the insert, or two stores may hold in two forms, with its rule. */
73
84
  readonly edited: Readonly<Record<string, EditRule>>;
74
85
  }
75
86
  /** A table that never leaves its machine. */
@@ -34,7 +34,12 @@ export interface SessionUsageTotals {
34
34
  export interface SessionStats {
35
35
  /** Log basename without its extension, which is the session uuid. */
36
36
  sessionId: string;
37
- /** The path the row was accumulated from. */
37
+ /**
38
+ * The stored form of the log's path (#1489): `<folder>/<file>`, with no
39
+ * leading `/`, for a log under `<home>/.claude/projects/`, joined back
40
+ * under the reading machine's home by `resolveSessionLogPath`; the
41
+ * absolute path for a log anywhere else, such as a `logDir` override's.
42
+ */
38
43
  filePath: string;
39
44
  /** Non-empty lines read. */
40
45
  lineCount: number;
@@ -42,7 +42,10 @@
42
42
  * because the uniqueness constraint on it is what deduplicates.
43
43
  * `worktree` is repeated beside it only so a query can read it; `read`
44
44
  * still answers the row from `row_json`, so both backends' rows stay
45
- * byte-identical.
45
+ * byte-identical. Both pass what they parsed through `answeredRows`
46
+ * (`answered-rows.ts`) on its way out of `read`, which answers an old
47
+ * session row's absolute `filePath` in its stored form and leaves
48
+ * `row_json` as it was written.
46
49
  *
47
50
  * `seq` is an `INTEGER PRIMARY KEY`, SQLite's alias for the rowid, so
48
51
  * the append order is a column the schema declares rather than an
@@ -22,7 +22,7 @@ import {
22
22
  registerConfigSections,
23
23
  setConfigLoadHook,
24
24
  setConfigTemplateHook
25
- } from "./index-m672ptpg.js";
25
+ } from "./index-dj8en7fg.js";
26
26
  import {
27
27
  below,
28
28
  describeValue,
@@ -8,7 +8,7 @@ import {
8
8
  createGitRunner,
9
9
  normalizeRemote,
10
10
  runningCommand
11
- } from "./index-4dwaxd5r.js";
11
+ } from "./index-rkrsdes6.js";
12
12
  import {
13
13
  activeOutput,
14
14
  activeOutputMode,
@@ -17,7 +17,7 @@ import {
17
17
  import {
18
18
  SCOPE_DIR,
19
19
  scopeAt
20
- } from "./index-m672ptpg.js";
20
+ } from "./index-dj8en7fg.js";
21
21
  import {
22
22
  TEST_SCOPES,
23
23
  bundledBinDirectory,
@@ -35,12 +35,64 @@ var EFFORT_KEY_PROJECTIONS = {
35
35
 
36
36
  // packages/rafa/src/effort/store/sqlite.ts
37
37
  import { existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
38
- import { dirname as dirname7, join as join5 } from "path";
38
+ import { dirname as dirname7, join as join6 } from "path";
39
39
  import { Database as Database2 } from "bun:sqlite";
40
40
 
41
+ // packages/rafa/src/effort/session-log-path.ts
42
+ import { posix } from "path";
43
+ var { isAbsolute, join, normalize } = posix;
44
+ var PROJECT_LOG_SEGMENTS = [".claude", "projects"];
45
+ var PROJECT_LOG_MARKER = `/${PROJECT_LOG_SEGMENTS.join("/")}/`;
46
+ var WINDOWS_SEPARATOR = "\\";
47
+ var PARENT_SEGMENT = "..";
48
+ function isStoredRelative(value) {
49
+ if (value === "" || value.includes(WINDOWS_SEPARATOR))
50
+ return false;
51
+ if (isAbsolute(value))
52
+ return false;
53
+ const normalized = normalize(value);
54
+ if (normalized === "." || normalized === PARENT_SEGMENT)
55
+ return false;
56
+ return !normalized.startsWith(`${PARENT_SEGMENT}/`);
57
+ }
58
+ function projectLogRoot(home) {
59
+ return join(home, ...PROJECT_LOG_SEGMENTS);
60
+ }
61
+ function storedLogPath(absolutePath, home) {
62
+ if (!isAbsolute(absolutePath) || !isAbsolute(home))
63
+ return absolutePath;
64
+ const prefix = `${projectLogRoot(home)}/`;
65
+ if (!absolutePath.startsWith(prefix))
66
+ return absolutePath;
67
+ const rest = absolutePath.slice(prefix.length);
68
+ return isStoredRelative(rest) ? rest : absolutePath;
69
+ }
70
+ function storedLogPathOf(value) {
71
+ if (typeof value !== "string" || !isAbsolute(value))
72
+ return value;
73
+ const at = value.lastIndexOf(PROJECT_LOG_MARKER);
74
+ if (at === -1)
75
+ return value;
76
+ const rest = value.slice(at + PROJECT_LOG_MARKER.length);
77
+ return isStoredRelative(rest) ? rest : value;
78
+ }
79
+
80
+ // packages/rafa/src/effort/store/answered-rows.ts
81
+ function answeredSession(row) {
82
+ if (!("filePath" in row))
83
+ return row;
84
+ const filePath = storedLogPathOf(row.filePath);
85
+ return filePath === row.filePath ? row : { ...row, filePath };
86
+ }
87
+ function answeredRows(kind, rows) {
88
+ if (kind !== "sessions")
89
+ return [...rows];
90
+ return rows.map(answeredSession);
91
+ }
92
+
41
93
  // packages/rafa/src/effort/store/development-build.ts
42
94
  import { tmpdir as tmpdir2 } from "os";
43
- import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute3 } from "path";
95
+ import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute4 } from "path";
44
96
 
45
97
  // packages/rafa/src/core/loop/sessions.ts
46
98
  import {
@@ -52,10 +104,10 @@ import {
52
104
  rmSync,
53
105
  writeFileSync
54
106
  } from "fs";
55
- import { dirname, join } from "path";
107
+ import { dirname, join as join2 } from "path";
56
108
 
57
109
  // packages/rafa/src/core/loop/session-record-parse.ts
58
- import { basename, isAbsolute } from "path";
110
+ import { basename, isAbsolute as isAbsolute2 } from "path";
59
111
  var SESSION_STATES = Object.freeze(["running", "paused", "stopped", "done"]);
60
112
  var SESSION_PHASES = Object.freeze(["task", "wrap-up", "pull-request", "ci", "repair"]);
61
113
  var RECORD_EXTENSION = ".json";
@@ -111,7 +163,7 @@ function worktreeProblem(fields) {
111
163
  if (!Object.hasOwn(fields, "worktree"))
112
164
  return null;
113
165
  const worktree = field(fields, "worktree");
114
- return isText(worktree) && isAbsolute(worktree) ? null : `worktree is ${describeValue(worktree)}, expected an absolute path`;
166
+ return isText(worktree) && isAbsolute2(worktree) ? null : `worktree is ${describeValue(worktree)}, expected an absolute path`;
115
167
  }
116
168
  function isTextList(value) {
117
169
  return Array.isArray(value) && value.every(isText);
@@ -425,13 +477,13 @@ class SessionStateError extends Error {
425
477
  }
426
478
  }
427
479
  function runsDir(root) {
428
- return join(scopeAt(root).dir, RUNS_DIR);
480
+ return join2(scopeAt(root).dir, RUNS_DIR);
429
481
  }
430
482
  function sessionFilePath(root, sessionId) {
431
483
  if (!isSessionId(sessionId)) {
432
484
  throw new Error(`session record: unusable session id ${JSON.stringify(sessionId)}`);
433
485
  }
434
- return join(runsDir(root), `${sessionId}${RECORD_EXTENSION}`);
486
+ return join2(runsDir(root), `${sessionId}${RECORD_EXTENSION}`);
435
487
  }
436
488
  function errorCode(error) {
437
489
  return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : null;
@@ -475,7 +527,7 @@ function byStart(a, b) {
475
527
  function readSessions(root, seams = {}) {
476
528
  const dir = runsDir(root);
477
529
  const isAlive = seams.isAlive ?? isPidAlive;
478
- const records = recordNames(dir).filter((name) => name.endsWith(RECORD_EXTENSION)).map((name) => readRecordFile(join(dir, name))).map((record) => Object.freeze({ ...record, state: readState(record, isAlive) }));
530
+ const records = recordNames(dir).filter((name) => name.endsWith(RECORD_EXTENSION)).map((name) => readRecordFile(join2(dir, name))).map((record) => Object.freeze({ ...record, state: readState(record, isAlive) }));
479
531
  return Object.freeze(records.sort(byStart));
480
532
  }
481
533
  function readSession(root, sessionId, seams = {}) {
@@ -688,11 +740,11 @@ function runClaudeCaptured(prompt, settingSources, flags = [], spawn = spawnClau
688
740
  }
689
741
  // packages/rafa/src/core/runtime/identity.ts
690
742
  import { existsSync, readFileSync as readFileSync2, realpathSync } from "fs";
691
- import { dirname as dirname2, join as join2, resolve } from "path";
743
+ import { dirname as dirname2, join as join3, resolve } from "path";
692
744
  var RAFA_PACKAGE_NAME = "@open-tomato/rafa";
693
- var RUNTIME_SUBDIR = join2(".rafa", "runtime");
745
+ var RUNTIME_SUBDIR = join3(".rafa", "runtime");
694
746
  var MANIFEST = "package.json";
695
- var CHECKOUT_ENTRY = join2("src", "rafa.ts");
747
+ var CHECKOUT_ENTRY = join3("src", "rafa.ts");
696
748
  function realOrResolved(path) {
697
749
  const resolved = resolve(path);
698
750
  return existsSync(resolved) ? realpathSync(resolved) : resolved;
@@ -712,7 +764,7 @@ function manifestName(file) {
712
764
  function nearestRafaPackage(start) {
713
765
  let dir = start;
714
766
  for (;; ) {
715
- const manifest = join2(dir, MANIFEST);
767
+ const manifest = join3(dir, MANIFEST);
716
768
  if (existsSync(manifest) && manifestName(manifest) === RAFA_PACKAGE_NAME)
717
769
  return dir;
718
770
  const parent = dirname2(dir);
@@ -724,7 +776,7 @@ function nearestRafaPackage(start) {
724
776
  function readRuntimeIdentity(entry = Bun.main) {
725
777
  const real = realOrResolved(entry);
726
778
  const packageDir = nearestRafaPackage(dirname2(real));
727
- if (packageDir !== null && existsSync(join2(packageDir, CHECKOUT_ENTRY))) {
779
+ if (packageDir !== null && existsSync(join3(packageDir, CHECKOUT_ENTRY))) {
728
780
  return { kind: "development", entry: real, checkout: packageDir };
729
781
  }
730
782
  return { kind: "installed", entry: real };
@@ -732,7 +784,7 @@ function readRuntimeIdentity(entry = Bun.main) {
732
784
  // packages/rafa/src/effort/store/location.ts
733
785
  import { existsSync as existsSync3, realpathSync as realpathSync2 } from "fs";
734
786
  import { tmpdir } from "os";
735
- import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve2, sep } from "path";
787
+ import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute3, join as join5, relative, resolve as resolve2, sep } from "path";
736
788
 
737
789
  // packages/rafa/src/effort/store/ndjson-files.ts
738
790
  import {
@@ -741,8 +793,8 @@ import {
741
793
  mkdirSync as mkdirSync2,
742
794
  readFileSync as readFileSync3
743
795
  } from "fs";
744
- import { dirname as dirname3, join as join3 } from "path";
745
- var EFFORT_STORE_DIR = join3(".rafa", "effort");
796
+ import { dirname as dirname3, join as join4 } from "path";
797
+ var EFFORT_STORE_DIR = join4(".rafa", "effort");
746
798
  var STORE_FILE_NAMES = {
747
799
  sessions: "sessions.ndjson",
748
800
  commits: "commits.ndjson"
@@ -854,27 +906,27 @@ function realPathOf(path) {
854
906
  if (existsSync3(resolved))
855
907
  return realpathSync2(resolved);
856
908
  const parent = dirname4(resolved);
857
- return parent === resolved ? resolved : join4(realPathOf(parent), basename2(resolved));
909
+ return parent === resolved ? resolved : join5(realPathOf(parent), basename2(resolved));
858
910
  }
859
911
  function isWithin(path, dir) {
860
912
  const between = relative(resolve2(dir), resolve2(path));
861
913
  const climbsOut = between === ".." || between.startsWith(`..${sep}`);
862
- return !climbsOut && !isAbsolute2(between);
914
+ return !climbsOut && !isAbsolute3(between);
863
915
  }
864
916
  function readEffortDirOverride(repoRoot, env = process.env) {
865
917
  const value = env[EFFORT_DIR_VARIABLE];
866
918
  if (value === undefined || value === "")
867
919
  return null;
868
- if (!isAbsolute2(value)) {
920
+ if (!isAbsolute3(value)) {
869
921
  throw new Error(`effort store: ${EFFORT_DIR_VARIABLE} is not an absolute path (${value}); run this command again` + ` with ${EFFORT_DIR_VARIABLE} set to the absolute path 'rafa effort copy' printed.`);
870
922
  }
871
- if (canonical(value) === canonical(join4(repoRoot, EFFORT_STORE_DIR))) {
923
+ if (canonical(value) === canonical(join5(repoRoot, EFFORT_STORE_DIR))) {
872
924
  throw new Error(`effort store: ${EFFORT_DIR_VARIABLE} names this project's own store (${value}); it points a command` + " at a copy only. Copy the store with 'rafa effort copy' and run this command with" + ` ${EFFORT_DIR_VARIABLE}=<the copy>.`);
873
925
  }
874
926
  return value;
875
927
  }
876
928
  function effortStoreDir(repoRoot, env = process.env) {
877
- return readEffortDirOverride(repoRoot, env) ?? join4(repoRoot, EFFORT_STORE_DIR);
929
+ return readEffortDirOverride(repoRoot, env) ?? join5(repoRoot, EFFORT_STORE_DIR);
878
930
  }
879
931
  function isTestProcess(main = Bun.main, env = process.env) {
880
932
  return main.endsWith(TEST_ENTRY_SUFFIX) || env[TEST_PROCESS_VARIABLE] === "1";
@@ -923,7 +975,7 @@ function isOwnedStore(path, env, tempDir) {
923
975
  if (isUnderTempDir(path, tempDir))
924
976
  return true;
925
977
  const override = env[EFFORT_DIR_VARIABLE];
926
- if (override === undefined || override === "" || !isAbsolute3(override))
978
+ if (override === undefined || override === "" || !isAbsolute4(override))
927
979
  return false;
928
980
  return storeProjectRoot(path) === null && isUnderTempDir(path, override);
929
981
  }
@@ -1918,7 +1970,7 @@ function carryStoreIdentity(livePath, parallelPath, seams = {}) {
1918
1970
  // packages/rafa/src/effort/store/sqlite.ts
1919
1971
  var SQLITE_STORE_FILE_NAME = "effort.sqlite";
1920
1972
  function sqliteStorePath(repoRoot) {
1921
- return join5(effortStoreDir(repoRoot), SQLITE_STORE_FILE_NAME);
1973
+ return join6(effortStoreDir(repoRoot), SQLITE_STORE_FILE_NAME);
1922
1974
  }
1923
1975
  var KIND_TABLES = {
1924
1976
  sessions: {
@@ -2020,7 +2072,7 @@ function readKind(path, kind) {
2020
2072
  return [];
2021
2073
  const { name } = KIND_TABLES[kind];
2022
2074
  const stored = withSqliteStore(path, "read", false, (db) => db.query(`SELECT seq, row_json AS body FROM ${name} ORDER BY seq`).all());
2023
- return stored.map(({ seq, body }) => rowOf(body, `${path}: ${name} row ${seq}`));
2075
+ return answeredRows(kind, stored.map(({ seq, body }) => rowOf(body, `${path}: ${name} row ${seq}`)));
2024
2076
  }
2025
2077
  function openSqliteStore(repoRoot) {
2026
2078
  const path = sqliteStorePath(repoRoot);
@@ -2035,7 +2087,7 @@ function openSqliteStore(repoRoot) {
2035
2087
  // packages/rafa/src/effort/store/wire.ts
2036
2088
  import { existsSync as existsSync7, mkdtempSync, rmSync as rmSync5 } from "fs";
2037
2089
  import { tmpdir as tmpdir3 } from "os";
2038
- import { join as join7 } from "path";
2090
+ import { join as join8 } from "path";
2039
2091
  import { Database as Database4, SQLiteError } from "bun:sqlite";
2040
2092
 
2041
2093
  // packages/rafa/src/effort/store/merge-rules.ts
@@ -2046,7 +2098,7 @@ function appendOnly(...identity) {
2046
2098
  return { scope: "merged", identity, edited: APPEND_ONLY };
2047
2099
  }
2048
2100
  var MERGE_RULES = {
2049
- sessions: appendOnly("session_id"),
2101
+ sessions: { scope: "merged", identity: ["session_id"], edited: { row_json: RECOMPUTED } },
2050
2102
  commits: { scope: "merged", identity: ["sha"], edited: { row_json: RECOMPUTED } },
2051
2103
  findings: { scope: "merged", identity: ["id"], edited: { tracker_ref: SET_ONCE } },
2052
2104
  blockers: appendOnly("id"),
@@ -2072,7 +2124,7 @@ import { closeSync, existsSync as existsSync6, fsyncSync, openSync, renameSync a
2072
2124
 
2073
2125
  // packages/rafa/src/effort/store/copy.ts
2074
2126
  import { copyFileSync, constants, existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync2, rmSync as rmSync3, statSync as statSync2 } from "fs";
2075
- import { join as join6, resolve as resolve3 } from "path";
2127
+ import { join as join7, resolve as resolve3 } from "path";
2076
2128
  import { Database as Database3 } from "bun:sqlite";
2077
2129
  var NDJSON_KINDS = { sessions: true, commits: true };
2078
2130
  var EFFORT_COPY_FILE_NAMES = [
@@ -2116,16 +2168,16 @@ function vacuumInto(source, target) {
2116
2168
  }
2117
2169
  function copyOne(name, source, target) {
2118
2170
  if (name === SQLITE_STORE_FILE_NAME) {
2119
- vacuumInto(join6(source, name), join6(target, name));
2171
+ vacuumInto(join7(source, name), join7(target, name));
2120
2172
  return;
2121
2173
  }
2122
- copyFileSync(join6(source, name), join6(target, name), constants.COPYFILE_EXCL);
2174
+ copyFileSync(join7(source, name), join7(target, name), constants.COPYFILE_EXCL);
2123
2175
  }
2124
2176
  function undo(target, written, madeDir) {
2125
2177
  try {
2126
2178
  if (madeDir === undefined) {
2127
2179
  for (const name of written)
2128
- rmSync3(join6(target, name), { force: true });
2180
+ rmSync3(join7(target, name), { force: true });
2129
2181
  } else {
2130
2182
  rmSync3(madeDir, { recursive: true, force: true });
2131
2183
  }
@@ -2139,7 +2191,7 @@ function copyEffortStore(request) {
2139
2191
  const target = resolve3(request.target);
2140
2192
  guardTestProcess(source);
2141
2193
  guardTestProcess(target);
2142
- const files = EFFORT_COPY_FILE_NAMES.filter((name) => existsSync5(join6(source, name)));
2194
+ const files = EFFORT_COPY_FILE_NAMES.filter((name) => existsSync5(join7(source, name)));
2143
2195
  if (files.length === 0) {
2144
2196
  throw new EffortCopyRefusal(`no effort store at ${source}: it holds none of ${EFFORT_COPY_FILE_NAMES.join(", ")}. Nothing to copy.`);
2145
2197
  }
@@ -2510,9 +2562,9 @@ function buildStore(path, payload, options) {
2510
2562
  }
2511
2563
  function materialiseWirePayload(payload, options = {}) {
2512
2564
  const checked = checkPayload(payload);
2513
- const directory = mkdtempSync(join7(options.tempDir ?? tmpdir3(), "rafa-wire-"));
2565
+ const directory = mkdtempSync(join8(options.tempDir ?? tmpdir3(), "rafa-wire-"));
2514
2566
  const release = () => rmSync5(directory, { recursive: true, force: true });
2515
- const path = join7(directory, SQLITE_STORE_FILE_NAME);
2567
+ const path = join8(directory, SQLITE_STORE_FILE_NAME);
2516
2568
  try {
2517
2569
  guardTestProcess(path);
2518
2570
  buildStore(path, checked, options);
@@ -2527,7 +2579,7 @@ function materialiseWirePayload(payload, options = {}) {
2527
2579
  import { randomUUID as randomUUID3 } from "crypto";
2528
2580
  import { existsSync as existsSync8, mkdtempSync as mkdtempSync2, rmSync as rmSync6 } from "fs";
2529
2581
  import { tmpdir as tmpdir4 } from "os";
2530
- import { dirname as dirname8, join as join8 } from "path";
2582
+ import { dirname as dirname8, join as join9 } from "path";
2531
2583
  import { Database as Database6, SQLiteError as SQLiteError3 } from "bun:sqlite";
2532
2584
 
2533
2585
  // packages/rafa/src/effort/store/fix-schema.ts
@@ -2726,7 +2778,21 @@ function unionStores(local, other) {
2726
2778
  var SET_ONCE_FILLS = {
2727
2779
  "findings.tracker_ref": "UPDATE findings SET tracker_ref = ? WHERE seq = ? AND tracker_ref IS NULL"
2728
2780
  };
2781
+ var LOG_PATH_FIELD = "filePath";
2782
+ function withStoredLogPath(rowJson) {
2783
+ let row;
2784
+ try {
2785
+ row = JSON.parse(rowJson);
2786
+ } catch {
2787
+ return rowJson;
2788
+ }
2789
+ if (typeof row !== "object" || row === null || Array.isArray(row) || !Object.hasOwn(row, LOG_PATH_FIELD))
2790
+ return rowJson;
2791
+ const entries = Object.entries(row).map(([key, value]) => key === LOG_PATH_FIELD ? [key, storedLogPathOf(value)] : [key, value]);
2792
+ return JSON.stringify(Object.fromEntries(entries));
2793
+ }
2729
2794
  var RECOMPUTED_COMPARISONS = {
2795
+ "sessions.row_json": withStoredLogPath,
2730
2796
  "commits.row_json": withoutGap
2731
2797
  };
2732
2798
  var NOT_CONTENT = new Set(["seq", "origin_store", "origin_seq"]);
@@ -2907,13 +2973,13 @@ function openOther(otherPath, plan, stamp, tempRoot) {
2907
2973
  const db = new Database6(otherPath, { readonly: true });
2908
2974
  return { db, broughtForward: [], release: () => db.close() };
2909
2975
  }
2910
- const dir = mkdtempSync2(join8(tempRoot, "rafa-merge-other-"));
2976
+ const dir = mkdtempSync2(join9(tempRoot, "rafa-merge-other-"));
2911
2977
  const release = (db) => {
2912
2978
  db?.close();
2913
2979
  rmSync6(dir, { recursive: true, force: true });
2914
2980
  };
2915
2981
  try {
2916
- const copyPath = join8(dir, "other.sqlite");
2982
+ const copyPath = join9(dir, "other.sqlite");
2917
2983
  vacuumInto(otherPath, copyPath);
2918
2984
  const db = new Database6(copyPath, { readwrite: true });
2919
2985
  try {
@@ -3020,9 +3086,9 @@ function mergeStore(options) {
3020
3086
  }
3021
3087
 
3022
3088
  // packages/rafa/src/effort/store/ndjson.ts
3023
- import { join as join9 } from "path";
3089
+ import { join as join10 } from "path";
3024
3090
  function kindPath(repoRoot, kind) {
3025
- return join9(effortStoreDir(repoRoot), effortStoreFileName(kind));
3091
+ return join10(effortStoreDir(repoRoot), effortStoreFileName(kind));
3026
3092
  }
3027
3093
  function openedKindPath(repoRoot, kind) {
3028
3094
  const path = kindPath(repoRoot, kind);
@@ -3044,7 +3110,7 @@ function openNdjsonStore(repoRoot) {
3044
3110
  return {
3045
3111
  append: (kind, rows) => appendKind2(repoRoot, kind, rows),
3046
3112
  keys: (kind) => keysOfKind2(repoRoot, kind),
3047
- read: (kind) => readKind2(repoRoot, kind).rows,
3113
+ read: (kind) => answeredRows(kind, readKind2(repoRoot, kind).rows),
3048
3114
  path: (kind) => kindPath(repoRoot, kind),
3049
3115
  readRows: (kind) => readKind2(repoRoot, kind)
3050
3116
  };
@@ -3067,4 +3133,4 @@ function selectEffortStore(repoRoot, config) {
3067
3133
  return adapter.create({ repoRoot });
3068
3134
  }
3069
3135
 
3070
- export { RUNTIME_SUBDIR, SessionRecordError, isSessionId, sessionSteps, sessionDecisions, SessionConflictError, runsDir, sessionFilePath, errorCode, isPidAlive, readSessions, readSession, samePlan, beginSession, updateSession, SESSION_ID_FLAG, claudeArgs, interruptClaudeSessions, spawnClaude, runClaude, spawnClaudeCaptured, runClaudeCaptured, EFFORT_DIR_VARIABLE, effortStoreDir, guardTestProcess, DEVELOPMENT_NEXT_STEP, DevelopmentBuildRefusedError, refuseUnownedDevelopmentWrite, SQLITE_MIGRATIONS, sqliteCatalogue, planSchema, readStoreSchema, writeNames, ACROSS_STORES_ORDER, STAMPED_COLUMNS, stampedValues, readReplacedStoreIds, readStoreMeta, EFFORT_KEY_PROJECTIONS, SQLITE_STORE_FILE_NAME, sqliteStorePath, LONE_SURROGATE, withSqliteStore, writeSqliteStore, openSqliteStore, copyEffortStore, WIRE_FORMAT, WIRE_VERSION, WireFormatError, WireExportRefusal, encodeWirePayload, decodeWirePayload, exportWirePayload, materialiseWirePayload, minutesBetween, MOVE_TO_SQLITE, mergeStore, openNdjsonStore, selectEffortStore };
3136
+ export { storedLogPath, ACROSS_STORES_ORDER, STAMPED_COLUMNS, stampedValues, SessionRecordError, isSessionId, sessionSteps, sessionDecisions, SessionConflictError, runsDir, sessionFilePath, errorCode, isPidAlive, readSessions, readSession, samePlan, beginSession, updateSession, SESSION_ID_FLAG, claudeArgs, interruptClaudeSessions, spawnClaude, runClaude, spawnClaudeCaptured, runClaudeCaptured, RUNTIME_SUBDIR, EFFORT_DIR_VARIABLE, effortStoreDir, guardTestProcess, DEVELOPMENT_NEXT_STEP, DevelopmentBuildRefusedError, refuseUnownedDevelopmentWrite, SQLITE_MIGRATIONS, sqliteCatalogue, planSchema, readStoreSchema, writeNames, readReplacedStoreIds, readStoreMeta, EFFORT_KEY_PROJECTIONS, SQLITE_STORE_FILE_NAME, sqliteStorePath, LONE_SURROGATE, withSqliteStore, writeSqliteStore, openSqliteStore, copyEffortStore, WIRE_FORMAT, WIRE_VERSION, WireFormatError, WireExportRefusal, encodeWirePayload, decodeWirePayload, exportWirePayload, materialiseWirePayload, minutesBetween, MOVE_TO_SQLITE, mergeStore, openNdjsonStore, selectEffortStore };
@@ -251,7 +251,7 @@ var CORE_DEFAULTS = Object.freeze({
251
251
  learningAdapter: "local",
252
252
  learningBlessMinConfidence: 0.5,
253
253
  learningPromoteAfter: 3,
254
- learningPromoteMinConfidence: 0.7,
254
+ learningPromoteMinConfidence: 0.6,
255
255
  outputMode: "text",
256
256
  prerequisitesRequired: Object.freeze([]),
257
257
  prerequisitesOptional: Object.freeze([]),
@@ -20,7 +20,7 @@ import {
20
20
  isRecord,
21
21
  normalizeRemote,
22
22
  setActiveStoreSettings
23
- } from "./index-4dwaxd5r.js";
23
+ } from "./index-rkrsdes6.js";
24
24
  import {
25
25
  activeOutput,
26
26
  activeOutputMode
@@ -51,7 +51,7 @@ import {
51
51
  resolveConfig,
52
52
  scopeAt,
53
53
  writeDangerousPassLines
54
- } from "./index-m672ptpg.js";
54
+ } from "./index-dj8en7fg.js";
55
55
  import {
56
56
  BRANCH_STUB,
57
57
  CLAIMS_STALE_DISABLED,
@@ -11064,4 +11064,4 @@ var FACADE = Object.freeze({
11064
11064
  function activeServices() {
11065
11065
  return FACADE;
11066
11066
  }
11067
- export { ISSUE_TYPES, ISSUE_PRIORITIES, ISSUE_STATES, GITHUB_LABELS, GITHUB_LABEL_MAX_LENGTH, createGhRunner, typeOfLabels, moduleOfLabels, createGithubTracker, createConsoleLogger, resolveTracker, SPEC_BLOCKED_LABEL, SPEC_READY_LABEL, READINESS_REFUSAL_EXIT, findPinnedMigrations, hasSpecReadyLabel, requireCompleteSpec, ID_PREFIX, SPEC_EXTENSION, pullRequestTitle, REMOTE, detachedHeadRefusal, branchNameFor, localRef, remoteTrackingRef, standsOn, anyBranchStandsAside, readBranchOffer, answeredYes, trackedChanges, treeRefusal, branchSteps, parseBaseStanding, hasDiverged, readStepOutcome, CLAIM_SUBJECT, parseClaimMessage, claimBranchGlob, claimBranchIssue, makeOwnershipCommit, fetchClaimBranches, readClaimBranch, readLocalClaimBranch, pushNewClaimBranch, pushOwnershipCommit, CLAIMED_LABEL, IN_DEVELOPMENT_LABEL, claimBranchOfRef, weighBranchClaim, scanClaimBranches, ROADMAP_TITLE, parseRoadmapBody, createGhRoadmapSearch, createGhOpenPullRequests, createRoadmapReadings, pickNextRoadmapLine, bodyLines, findField, EPIC_LABEL_PREFIX, epicSlugsOf, readEpics, BOARD_LISTING_LIMIT, parseBoardListing, createGhBoardListing, epicContextArgs, readEpicContext, readEpicProblems, epicProblemMessage, isEpicIssue, epicLines, descendRoadmap, nextNowEpic, SKIP_REVIEW_FLAG, ACCEPT_REFS_FLAG, ghBoardTrust, requireTrustedBoardAuthor, issueFieldLine, stampPlanIssue, REVIEW_SKIPPED_LINE, REVIEW_MISSING_LINE, stampReviewSkipped, stampReviewMissing, ASSUMPTIONS_HEADING, SPEC_NEEDS_WORK_LABEL, readGateFlags, enforceSpecReview, PRESENT, ABSENT, NEW, UNREADABLE, RefsBlockError, ISSUE_KINDS, issueFingerprint, blobFingerprint, fingerprintText, compareToStamp, findStamp, writeRefsBlock, readRefsBlock, createGhSpecIssueReader, ROADMAP_LABEL, createGhIssueBoard, labelsLineBlockersOf, LABELS_READS, blockedLineOf, blockedLineSentence, blockingOf, notReadySentence, alternativeQuestion, NOT_A_REPOSITORY, mainCheckoutOf, INIT_COMMAND, DISK_FILE_SYSTEM, ScopeError, initHint, selfAndAncestors, resolveScope, createGhBoardLister, resolveDefaultBoard, selectBoardRelations, readBoardRepository, readConfiguredRelations, cancelledEpicNoticeLines, firstNowEpic, positionFilePath, readPositionFile, writePositionFile, positionAt, rehome, hop, goHome, samePlace, resolvePlace, openProjectRunner, isMissingProjectScope, scopeWarning, notFoundWarning, addedNotFilledWarning, FRAGMENT_EXTENSION, FRAGMENT_PLAN_ID_PATTERN, parseFragment, serializeFragment, allocateFragmentName, directoryPrefix, fragmentIdOf, readCurrentPlace, horizonOf, readListedEpics, createGhProjectPort, knownItem, refreshProjectItems, refreshIssueItems, refreshFailedWarning, createRefreshingGhIssueBoard, aheadEnabled, aheadNotClaimed, resolveAheadTarget, pushClaimsAtomic, aheadClaimedLine, aheadNotClaimedWarning, refreshQuestion, hopFilePath, readHopRecord, writeHopRecord, staleAgainst, SOURCE_REFUSAL_EXIT, noSourceMessage, readSpecSourceFlags, issueSource, boardRepoLabel, resolvePlanSpec, READY_YES_FLAG, READY_DRY_RUN_FLAG, ISSUE_READY_DECLARATION, readConfigFile, readProjectScope, loadConfig, lineRefusal, issueProject, issueSubjectConfig, SERVICE_REASONS, registerServices, restoreServices, activeServices };
11067
+ export { ISSUE_TYPES, ISSUE_PRIORITIES, ISSUE_STATES, GITHUB_LABELS, GITHUB_LABEL_MAX_LENGTH, createGhRunner, typeOfLabels, moduleOfLabels, createGithubTracker, createConsoleLogger, activeLogger, resolveTracker, SPEC_BLOCKED_LABEL, SPEC_READY_LABEL, READINESS_REFUSAL_EXIT, findPinnedMigrations, hasSpecReadyLabel, requireCompleteSpec, ID_PREFIX, SPEC_EXTENSION, pullRequestTitle, REMOTE, detachedHeadRefusal, branchNameFor, localRef, remoteTrackingRef, standsOn, anyBranchStandsAside, readBranchOffer, answeredYes, trackedChanges, treeRefusal, branchSteps, parseBaseStanding, hasDiverged, readStepOutcome, CLAIM_SUBJECT, parseClaimMessage, claimBranchGlob, claimBranchIssue, makeOwnershipCommit, fetchClaimBranches, readClaimBranch, readLocalClaimBranch, pushNewClaimBranch, pushOwnershipCommit, CLAIMED_LABEL, IN_DEVELOPMENT_LABEL, claimBranchOfRef, weighBranchClaim, scanClaimBranches, ROADMAP_TITLE, parseRoadmapBody, createGhRoadmapSearch, createGhOpenPullRequests, createRoadmapReadings, pickNextRoadmapLine, bodyLines, findField, EPIC_LABEL_PREFIX, epicSlugsOf, readEpics, BOARD_LISTING_LIMIT, parseBoardListing, createGhBoardListing, epicContextArgs, readEpicContext, readEpicProblems, epicProblemMessage, isEpicIssue, epicLines, descendRoadmap, nextNowEpic, SKIP_REVIEW_FLAG, ACCEPT_REFS_FLAG, ghBoardTrust, requireTrustedBoardAuthor, issueFieldLine, stampPlanIssue, REVIEW_SKIPPED_LINE, REVIEW_MISSING_LINE, stampReviewSkipped, stampReviewMissing, ASSUMPTIONS_HEADING, SPEC_NEEDS_WORK_LABEL, readGateFlags, enforceSpecReview, PRESENT, ABSENT, NEW, UNREADABLE, RefsBlockError, ISSUE_KINDS, issueFingerprint, blobFingerprint, fingerprintText, compareToStamp, findStamp, writeRefsBlock, readRefsBlock, createGhSpecIssueReader, ROADMAP_LABEL, createGhIssueBoard, labelsLineBlockersOf, LABELS_READS, blockedLineOf, blockedLineSentence, blockingOf, notReadySentence, alternativeQuestion, NOT_A_REPOSITORY, mainCheckoutOf, INIT_COMMAND, DISK_FILE_SYSTEM, ScopeError, initHint, selfAndAncestors, resolveScope, createGhBoardLister, resolveDefaultBoard, selectBoardRelations, readBoardRepository, readConfiguredRelations, cancelledEpicNoticeLines, firstNowEpic, positionFilePath, readPositionFile, writePositionFile, positionAt, rehome, hop, goHome, samePlace, resolvePlace, openProjectRunner, isMissingProjectScope, scopeWarning, notFoundWarning, addedNotFilledWarning, FRAGMENT_EXTENSION, FRAGMENT_PLAN_ID_PATTERN, parseFragment, serializeFragment, allocateFragmentName, directoryPrefix, fragmentIdOf, readCurrentPlace, horizonOf, readListedEpics, createGhProjectPort, knownItem, refreshProjectItems, refreshIssueItems, refreshFailedWarning, createRefreshingGhIssueBoard, aheadEnabled, aheadNotClaimed, resolveAheadTarget, pushClaimsAtomic, aheadClaimedLine, aheadNotClaimedWarning, refreshQuestion, hopFilePath, readHopRecord, writeHopRecord, staleAgainst, SOURCE_REFUSAL_EXIT, noSourceMessage, readSpecSourceFlags, issueSource, boardRepoLabel, resolvePlanSpec, READY_YES_FLAG, READY_DRY_RUN_FLAG, ISSUE_READY_DECLARATION, readConfigFile, readProjectScope, loadConfig, lineRefusal, issueProject, issueSubjectConfig, SERVICE_REASONS, registerServices, restoreServices, activeServices };