mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-16 05:17:24 +01:00
W1b: template and resolver prose resolve state through guarded gstack-paths; ratchet (a)
Every gstack-paths eval in templates and resolvers carries the fail-stop guard; executable ~/.gstack paths in bash blocks (context recovery preamble, eureka log, analytics, project artifacts, upgrade snooze, setup-gbrain lock, retro snapshots, ship consent marker) use $GSTACK_STATE_ROOT, and the writer prose that pairs with them points at the printed PROJECT_DIR / RETRO_FILE. ship drops export GSTACK_STATE_ROOT. SKILL.md regenerated (claude + codex), ship goldens re-pinned, parity and context-budget caps raised to the measured sizes with notes. test/state-root-ratchet.test.ts enforces the rule with a reasoned allowlist; W1 touchfile entries plus a superset golden.
This commit is contained in:
1 parent
65fe39b8e4
commit
d807ef24a3
118 files changed
+894
-378
No files matched your search
@@ -23,6 +23,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync, renameSync, statSyn
|
||||
import { join, dirname } from 'path';
|
||||
import { homedir, hostname } from 'os';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { resolveStateRoot } from '../lib/state-root';
|
||||
import { execGbrainJson, spawnGbrain } from '../lib/gbrain-exec';
|
||||
import {
|
||||
BRAIN_CACHE_ENTITIES,
|
||||
@@ -37,7 +38,7 @@ import {
|
||||
// Paths + meta
|
||||
// ──────────────────────────────────────────────────────────────────────────
|
||||
|
||||
const GSTACK_HOME = process.env.GSTACK_HOME || join(homedir(), '.gstack');
|
||||
const GSTACK_HOME = resolveStateRoot();
|
||||
|
||||
interface CacheMeta {
|
||||
/** Version of the schema pack the cache was built against. Mismatch → full rebuild. */
|
||||
|
||||
+5
-4
@@ -39,6 +39,7 @@ import { mkdirpSync } from "../lib/fs-utils";
|
||||
import { join, dirname } from "path";
|
||||
import { spawnSync } from "child_process";
|
||||
import { appendJsonl, readJsonl } from "../lib/jsonl-store";
|
||||
import { resolveStateRoot } from "../lib/state-root";
|
||||
import { scan, applyRedactions } from "../lib/redact-engine";
|
||||
|
||||
const BIN_DIR = dirname(Bun.fileURLToPath(import.meta.url));
|
||||
@@ -93,10 +94,10 @@ function currentWtree(): string | undefined {
|
||||
}
|
||||
|
||||
function ledgerPath(): { dir: string; file: string; logsDir: string } {
|
||||
const home = process.env.GSTACK_HOME || (process.env.HOME ? join(process.env.HOME, ".gstack") : undefined);
|
||||
// No resolvable home: skip bookkeeping (a literal "~" dir in cwd would land
|
||||
// inside the repo and perturb the fingerprint it exists to compute).
|
||||
if (!home) throw new Error("no GSTACK_HOME/HOME — bookkeeping skipped");
|
||||
const home = resolveStateRoot();
|
||||
// No resolvable home: skip bookkeeping (the relative ".gstack" fallback would
|
||||
// land inside the repo and perturb the fingerprint it exists to compute).
|
||||
if (home === ".gstack") throw new Error("no GSTACK_HOME/HOME — bookkeeping skipped");
|
||||
// ONE gstack-slug spawn: its output carries both SLUG= and BRANCH= lines
|
||||
// (same branch→filename sanitization as reviews.jsonl).
|
||||
const slugOut = spawnSync(join(BIN_DIR, "gstack-slug"), { encoding: "utf-8" });
|
||||
|
||||
@@ -44,8 +44,9 @@ import {
|
||||
readGbrainVersion,
|
||||
} from "../lib/gbrain-local-status";
|
||||
import { gbrainConfigDir, isTransactionModePooler } from "../lib/gbrain-exec";
|
||||
import { resolveStateRoot } from "../lib/state-root";
|
||||
|
||||
const STATE_DIR = process.env.GSTACK_HOME || join(userHome(), ".gstack");
|
||||
const STATE_DIR = resolveStateRoot();
|
||||
const SCRIPT_DIR = __dirname;
|
||||
const CONFIG_BIN = join(SCRIPT_DIR, "gstack-config");
|
||||
// Honors GBRAIN_HOME with gbrain's own configDir() semantics (#2521:
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
*/
|
||||
import { spawnSync } from "child_process";
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { normalizeWithMap, scan, type Finding } from "../lib/redact-engine";
|
||||
import { mkdirpSync } from "../lib/fs-utils";
|
||||
import { resolveStateRoot } from "../lib/state-root";
|
||||
|
||||
const ZERO = /^0+$/;
|
||||
let emptyTree: string | undefined;
|
||||
@@ -416,7 +416,7 @@ function scanAddedLines(added: string, opts: Parameters<typeof scan>[1]): Findin
|
||||
|
||||
function logSkip(reason: string): void {
|
||||
try {
|
||||
const home = process.env.GSTACK_HOME || path.join(os.homedir(), ".gstack");
|
||||
const home = resolveStateRoot();
|
||||
const dir = path.join(home, "security");
|
||||
// mkdirpSync, not bare mkdirSync: bun-on-Windows EEXIST (#2635). This site
|
||||
// is try-wrapped by the caller, so the old failure was a silent skip-log
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import { resolveStateRoot } from '../lib/state-root';
|
||||
|
||||
const STATE_DIR = process.env.GSTACK_STATE_DIR || path.join(process.env.HOME || '/', '.gstack');
|
||||
const STATE_DIR = resolveStateRoot();
|
||||
const SCHEMA_VERSION = 1;
|
||||
const SESSION_CAP = 50;
|
||||
const DECAY_PER_WEEK = 0.05;
|
||||
|
||||
Reference in new issue
Block a user