SatisfactionCapture: a reply that picks a numbered point ("1", "1 and 2 agreed") is stored as a rating when the menu sits past 2000 characters or the reply has words after the number
Version
LifeOS 8.761.0 · attestation: 30 system file(s) differ from danielmiessler/[email protected]:
- hooks/SatisfactionCapture.hook.ts
- hooks/README.md
- skills/CreateCLI/SKILL.md
- skills/CreateCLI/Intents/CreateCli.md
- skills/Prompting/SKILL.md
- skills/LifeOSHooks/hooks/lib/build.ts
- skills/Herdr/Intents/Configure.md
- skills/LifeOS/SKILL.md
- skills/LifeOS/Intents/Setup.md
- skills/Fabric/SKILL.md
- LIFEOS/TOOLS/VideoMeaning/README.md
- LIFEOS/TOOLS/models.ts
- LIFEOS/TOOLS/model-pricing.json
- LIFEOS/DOCUMENTATION/Tools/Tools.md
- LIFEOS/DOCUMENTATION/Memory/MemorySystem.md
- LIFEOS/DOCUMENTATION/Location/LocationSystem.md
- LIFEOS/DOCUMENTATION/Pulse/TerminalTabs.md
- LIFEOS/DOCUMENTATION/Pulse/PulseSystem.md
- LIFEOS/DOCUMENTATION/Workflows/WorkflowsSystem.md
- LIFEOS/DOCUMENTATION/LifeosSystemArchitecture.md
- LIFEOS/DOCUMENTATION/ARCHITECTURE_SUMMARY.md
- LIFEOS/DOCUMENTATION/Algorithm/AscentStates.md
- LIFEOS/DOCUMENTATION/Testing/TestingDoctrine.md
- LIFEOS/DOCUMENTATION/Hooks/HookSystem.md
- LIFEOS/DOCUMENTATION/Work/WorkSystem.md
- LIFEOS/DOCUMENTATION/Assay/AssaySystem.md
- LIFEOS/DOCUMENTATION/Services/BackgroundServices.md
- LIFEOS/DOCUMENTATION/Router/RouterSystem.md
- LIFEOS/ALGORITHM/AlgorithmReference.md
- LIFEOS/ERRATA/fixtures/LabelBrief.md
What is broken
When the assistant ends a reply with numbered points and the user answers by picking one, the explicit-rating leg can store the pick as a rating. Two separate causes.
First, the menu guard in run() is fed getLastResponse(), the global MEMORY/STATE/last-response.txt. hooks/lib/response-cache.ts writes the first 2000 characters of whichever session finished last into that file. A menu at the end of a longer reply is cut off, so the guard sees no menu and a bare "1" is stored as rating 1.
Second, the guard if (!rest && menuOffered) return null covers only a bare number. "1 and 2 agreed" has a tail, so it parses as rating 1 with the comment "and 2 agreed", even when the guard sees the whole reply.
A rating of 3 or below writes an Errata row tagged rating, a LEARNING low-rating note and a FAILURES capture. The user never complained about anything.
This happened in real use. A 2,300-character reply ended in two numbered open decisions. The user answered with the two numbers and "agreed". The hook stored rating 1 and opened a FAILURES capture.
The negative control below is the repro block, saved as /tmp/rating-menu-repro.sh and run in a fresh temp directory.
Where (file:line)
hooks/SatisfactionCapture.hook.ts:515, hooks/SatisfactionCapture.hook.ts:329, hooks/lib/response-cache.ts:57-58
Repro on a clean tree
gh api repos/danielmiessler/LifeOS/tarball/f6ab5e02 > main.tar.gz
mkdir clean && tar xzf main.tar.gz -C clean --strip-components=1
# hook-repro.ts runs the shipped hook against a throwaway config root with the
# model CLI stubbed: no inference call, nothing touched in a real install.
cat > hook-repro.ts <<'TS'
// Runs the shipped hook against a throwaway config root and reports what it wrote.
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync, existsSync, chmodSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
const hook = `${process.env.LIFEOS_ROOT}/hooks/SatisfactionCapture.hook.ts`;
const reply = "x".repeat(2100) + "\n\nOpen decisions:\n\n1. Ship the fix? I'd say yes.\n\n2. Delete the old file? I'd say yes.\n";
for (const [prompt, last] of [["1", reply], ["1 and 2 agreed", reply], ["3", "Done. The test passes."]] as const) {
const home = mkdtempSync(join(tmpdir(), "rating-repro-"));
const root = join(home, ".claude");
mkdirSync(join(root, "LIFEOS/MEMORY/STATE"), { recursive: true });
writeFileSync(join(root, "LIFEOS/MEMORY/STATE/last-response.txt"), last.slice(0, 2000)); // what cacheResponse() stores
const transcript = join(home, "t.jsonl");
writeFileSync(transcript, [
{ type: "user", message: { role: "user", content: "check it" } },
{ type: "assistant", message: { role: "assistant", content: [{ type: "text", text: last }] } },
].map((l) => JSON.stringify(l)).join("\n") + "\n");
mkdirSync(join(home, "bin")); // stub the model CLI: no inference call
writeFileSync(join(home, "bin/claude"), "#!/bin/sh\nexit 1\n"); chmodSync(join(home, "bin/claude"), 0o755);
Bun.spawnSync(["bun", hook], {
cwd: home,
env: { HOME: home, CLAUDE_CONFIG_DIR: root, PATH: `${join(home, "bin")}:${process.env.PATH}` },
stdin: Buffer.from(JSON.stringify({ session_id: "repro", prompt, transcript_path: transcript, hook_event_name: "UserPromptSubmit" })),
stderr: "ignore",
});
const errata = join(root, "LIFEOS/USER/ERRATA");
const rows = existsSync(errata) ? readdirSync(errata).filter((f) => f.endsWith(".jsonl"))
.flatMap((f) => readFileSync(join(errata, f), "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)))
.filter((r) => r.tags?.includes("rating")).map((r) => `rating ${r.rating} "${r.complaint}"`) : [];
const failures = join(root, "LIFEOS/MEMORY/LEARNING/FAILURES");
const dirs = existsSync(failures) ? readdirSync(failures).flatMap((m) => readdirSync(join(failures, m))).length : 0;
console.log(JSON.stringify(prompt).padEnd(18), `reply ${last.length} chars`.padEnd(17), "→", rows.length ? rows.join("; ") : "no rating row", `· FAILURES dirs: ${dirs}`);
}
TS
LIFEOS_ROOT="$PWD/clean/LifeOS/install" bun hook-repro.ts
Negative control
Probe: cd "$(mktemp -d)" && sh /tmp/rating-menu-repro.sh · exit 0 · captured 2026-11-13T10:10:43.176Z
Red looks like: rating 1 "and 2 agreed"
"1" reply 2187 chars → rating 1 "Explicit rating: 1/10" · FAILURES dirs: 1
"1 and 2 agreed" reply 2187 chars → rating 1 "and 2 agreed" · FAILURES dirs: 1
"3" reply 22 chars → rating 3 "Explicit rating: 3/10" · FAILURES dirs: 1
Suggested fix
With the fix applied to the same clean tree, the same script prints:
"1" reply 2187 chars → no rating row · FAILURES dirs: 0
"1 and 2 agreed" reply 2187 chars → no rating row · FAILURES dirs: 0
"3" reply 22 chars → rating 3 "Explicit rating: 3/10" · FAILURES dirs: 1
parseExplicitRating("8 nice", reply) still returns rating 8 and "8/10" still returns 8, because 8 is not an offered point and the fraction form is untouched.
The fix has two changes.
- A new exported
offeredOptionNumbers(lastResponse)collects the numbers the reply offered as enumerated points at the start of a line (1.,2),**3.). InparseExplicitRating, a leading number (digit or word form) that is in that set returns null, with or without text after it. This is one extra line in the word-form loop (if (offered.has(num)) return null;) and one after the existing!rest && menuOfferedguard (if (offered.has(rating)) return null;). TheN/10form is untouched and the function signature is unchanged. run()first callsparseExplicitRating(prompt)with no reply. Only if that returns a rating does it read the session's own full last response withgetSessionLastResponse(data.transcript_path)and parse again. The guards only reject, so the transcript is read only for rating candidates.
// The numbers the previous response offered as enumerated points ("1. ", "2) ",
// "**3. " at line start). A prompt that opens with one of them answers that
// point, with or without words after it ("1", "2 yes", "1 and 2 agreed"); it is
// a selection, never a score.
const OFFERED_NUMBER = /^\s*(?:\*\*)?\(?(10|[1-9])[.)]\s/gm;
export function offeredOptionNumbers(lastResponse: string): Set<number> {
const offered = new Set<number>();
if (!lastResponse) return offered;
for (const m of lastResponse.matchAll(OFFERED_NUMBER)) offered.add(parseInt(m[1], 10));
return offered;
}
// The menu guard reads THIS session's full last response. The global cache holds
// the first 2000 characters of whichever session spoke last, so a menu at the end
// of a longer reply was invisible to it. The guards only ever reject, so the
// transcript is read only for a prompt that parses as a rating without them.
let explicitResult = parseExplicitRating(prompt);
let sessionLastResponse = '';
if (explicitResult) {
sessionLastResponse = getSessionLastResponse(data.transcript_path);
explicitResult = parseExplicitRating(prompt, sessionLastResponse);
}
Further down in run(), const lastResponse = getSessionLastResponse(data.transcript_path); becomes const lastResponse = sessionLastResponse;.
This is narrower than the half of #2029 that was declined. It rejects only a number the previous reply actually offered as a point, so "9 nice work" after a two-point menu, or after any reply without numbered points, is still a rating. It also follows the function's own stated rule of preferring a missed rating to a false positive.
The known cost: a real low rating that happens to equal an offered point number ("2 that was bad" after a two-point menu) is now missed.
Happy to open a PR with the test cases if that is useful.
Related: #2029 (added the bare-number guard this builds on), #2289 (same global file, fixed for FailureCapture content), #2635 (different residual: count plus noun), #1091.
Environment
- OS: macOS 27.2 (arm64)
- Harness: claude-code
- bun: 1.4.4 · git: 2.54.0
- Doctor broken: none
[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler
Both causes are fixed. The menu guard now reads this session's whole last reply from the transcript, and only for a prompt that already parses as a rating. A leading number the reply offered as a point ('1', 'two', '1 and 2 agreed') is now treated as a selection. '8 nice' after a two-point menu and any N/10 form still score, and so does '3' after a reply with no points. The cost you named stays: a low rating that equals an offered point number is missed.
This fix lands in the next LifeOS release, so I'm closing this now.