In this section
- Triage render · claude / familiars/triage.py lines 1079–1174
- Live Log automation · claude / logs/live-log.ps1 lines 1–93
- Classify Sensitivity render · claude / logs/tools/classify_sensitivity.py lines 1–254
Triage
A Python command-line tool in the familiars folder of Claude that reads red board and triage estate. It builds prompt (`build_prompt`), parses answer (`parse_answer`) and fits excerpt (`fit_excerpt`).
renderclaude / familiars/triage.py · lines 1079–1174 of 1174 (continued from section 1601) · Entry point · pattern excerpt (shared by 3 files)
- What it does
- It loads red board and triage estate. Defines 36 functions or classes, including strip_noise, flatten, reds_from_estate, _row, cached_log. Uses libraries argparse, json, os, queue, re. Side effects: changes the web page (DOM); reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'claude'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file red-board.json; JSON file triage-estate.json; command-line arguments. Out: JSON file.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- Read every red run in the estate with the local models, and ground every answer. It accepts `--gpu`, `--igpu` and `--lines`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- claude · familiars · Python CLI
- Uses
- Localai (import), Claude Audit Estate (script call), argparse, json, os, queue, re, statistics, subprocess, sys
- Used by
- none found
- Produces
- strip_noise, flatten, reds_from_estate, cached_log, excerpt, first_error_line, build_prompt, parse_answer, ground, device_context, fit_excerpt, generate_retrying
- Defines here
- one, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- claude@df9da02425fdf0c65d11a84f32cd9b3ef927b309 familiars/triage.py:1079-1174 · blob f95d67fc3b920447c19f6c0c1b985ae713919577 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""How much log does the model actually need? Grounding rate and class stability against
excerpt size, on real logs. The answer is not 'all of it': a bigger excerpt costs prefill
on every request and gives the model more places to find a plausible-looking line."""
estate, _ = load_estate(args.estate)
rows = [r for r in reds_from_estate(estate) if r['job_id']][:args.samples]
logs = [(r, cached_log(r)) for r in rows]
print('%d logs, median %d chars raw\n' % (len(logs),
statistics.median([len(l) for _, l in logs])))
print('%-6s %10s %10s %8s %9s %s' % ('lines', 'med chars', 'med tokens', 'grounded',
'wall', 'classes'))
for keep in [int(x) for x in args.steps.split(',')]:
chars, ptoks, ok, classes = [], [], 0, {}
t0 = time.time()
q = queue.Queue()
for row, log in logs:
q.put((row, log))
lock = threading.Lock()
def one(device):
nonlocal ok
while True:
try:
row, log = q.get_nowait()
except queue.Empty:
return
try:
body = fit_excerpt(log, device, keep, 200)[0]
a = classify(row, body, device)
with lock:
chars.append(len(body))
ptoks.append(a['prompt_tokens'])
classes[a['class']] = classes.get(a['class'], 0) + 1
if a['grounded']:
ok += 1
except Exception as e: # noqa: BLE001
with lock:
print(' ! %s' % str(e)[:140])
slots = build_slots(args.gpu, args.igpu)
ts = [threading.Thread(target=one, args=(d,), daemon=True) for d in slots]
for t in ts:
t.start()
for t in ts:
t.join()
print('%-6d %10d %10d %5d/%-3d %8.1fs %s'
% (keep, statistics.median(chars) if chars else 0,
statistics.median(ptoks) if ptoks else 0, ok, len(logs), time.time() - t0,
' '.join('%s=%d' % kv for kv in sorted(classes.items()))))
return 0
# --------------------------------------------------------------------------- cli
def main():
p = argparse.ArgumentParser(description=__doc__.split('\n')[0])
p.add_argument('--gpu', type=int, default=DEFAULT_GPU_SLOTS,
help='requests in flight on the dGPU (11434)')
p.add_argument('--igpu', type=int, default=DEFAULT_IGPU_SLOTS,
help='requests in flight on the iGPU (11435); 0 while the governor is '
'installed - it refuses the iGPU outright')
p.add_argument('--lines', type=int, default=DEFAULT_LINES, help='log lines in the excerpt')
p.add_argument('--limit', type=int, default=0, help='only the newest N failing jobs')
p.add_argument('--estate', help='reuse an existing audit_estate.py --json file')
p.add_argument('--refresh', action='store_true', help='refetch cached job logs')
p.add_argument('--loop', type=int, default=0, help='sweep every N seconds, forever')
p.add_argument('--calibrate-conc', action='store_true')
p.add_argument('--calibrate-lines', action='store_true')
p.add_argument('--samples', type=int, default=6, help='logs used by a calibration')
p.add_argument('--steps', default='1,2,3,4,6', help='calibration ladder')
p.add_argument('--devices', default='gpu,igpu', help='devices for --calibrate-conc')
p.add_argument('--margin', type=int, default=250, help='MiB of VRAM headroom to keep free')
p.add_argument('--work', type=int, default=12,
help='requests per calibration rung; the same at every rung, min 8')
p.add_argument('--per-floor', type=float, default=0.40, dest='per_floor',
help='stop when per-request tok/s falls below this fraction of the '
'single-request baseline')
p.add_argument('--gain', type=float, default=0.10,
help='stop when a rung fails to raise aggregate tok/s by this fraction')
args = p.parse_args()
if args.calibrate_conc:
return calibrate_conc(args)
if args.calibrate_lines:
return calibrate_lines(args)
if args.loop:
while True:
try:
sweep(args)
except Exception as e: # noqa: BLE001 - a pump keeps pumping
print('sweep failed: %s' % str(e)[:400], file=sys.stderr)
time.sleep(args.loop)
return sweep(args)
if __name__ == '__main__':
sys.exit(main())Live Log
A PowerShell script in the logs folder of Claude using data from the GridAtlas and ventus-grid-engine repositories.
automationclaude / logs/live-log.ps1 · lines 1–93 of 93 · Not reached from any entry point (candidate for review)
- What it does
- Side effects: starts processes.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'claude'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file current.json.
- What it achieves
- Append-only plain-text record of what is actually happening.
- Why it matters
- No other file in the estate was found to import it.
- Application
- claude · logs · PowerShell script
- Uses
- GlobalGrid2050 Status (estate URL), UK Renewables Pipeline — V9 7 Page (estate URL), GridAtlas — Atlas Page (estate URL)
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- claude@df9da02425fdf0c65d11a84f32cd9b3ef927b309 logs/live-log.ps1:1-93 · blob 556d27565d329500a6d36d25db59d917ec11f907 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
# live-log.ps1 - append-only plain-text record of what is actually happening.
#
# Written 2026-09-05 after a session in which context was lost twice: once to a
# usage limit, once to a log that existed only in a hidden path. This writes a
# simple .txt that any human, or ChatGPT, Gemini or Claude, can read cold.
#
# It records FACTS, not narrative: commit heads, dirty files, live HTTP codes,
# and long-lived processes. It never guesses and it never grades.
#
# powershell -ExecutionPolicy Bypass -File logs\live-log.ps1
#
# Ctrl-C stops it. It appends, so stopping and restarting loses nothing.
$ErrorActionPreference = 'SilentlyContinue'
$LogPath = Join-Path $PSScriptRoot 'SESSION-LIVE-LOG.txt'
$GitHub = 'C:\Users\vikra\OneDrive\Documents\GitHub'
$Repos = @(
'globalgrid2050','gridatlas','gridatlas-main-202609050200',
'pipelinenews','ventus-grid-engine','testcode','spiders','claude'
)
$Urls = @(
'https://globalgrid2050.com/',
'https://globalgrid2050.com/status.html',
'https://globalgrid2050.com/uk_renewables_pipeline/v9.7/',
'https://ventusltd.github.io/gridatlas/atlas/',
'https://ventusltd.github.io/gridatlas/atlas/current.json',
'https://ventusltd.github.io/ventus-grid-engine/'
)
function Write-Log([string]$Text) { Add-Content -Path $LogPath -Value $Text -Encoding utf8 }
if (-not (Test-Path $LogPath)) {
Write-Log "GLOBALGRID2050 LIVE LOG"
Write-Log "Plain text on purpose. Append-only. All times UTC; the architect's clock is BST, UTC+1."
Write-Log "Started $((Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ'))"
Write-Log ("=" * 78)
}
while ($true) {
$stamp = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
Write-Log ""
Write-Log ("-" * 78)
Write-Log "TICK $stamp"
Write-Log "REPOS (branch | head | subject | dirty files)"
foreach ($r in $Repos) {
$p = Join-Path $GitHub $r
if (-not (Test-Path $p)) { Write-Log (" {0,-32} ABSENT" -f $r); continue }
Push-Location $p
$branch = (git branch --show-current) 2>$null
$head = (git log -1 --format='%h %s') 2>$null
$dirty = @(git status --porcelain) 2>$null
Pop-Location
if ($head.Length -gt 62) { $head = $head.Substring(0,62) }
Write-Log (" {0,-32} {1,-28} {2}" -f $r, $branch, $head)
if ($dirty.Count -gt 0) {
Write-Log (" {0,-32} DIRTY: {1} file(s)" -f '', $dirty.Count)
foreach ($d in ($dirty | Select-Object -First 8)) { Write-Log (" {0,-32} {1}" -f '', $d) }
}
}
Write-Log "LIVE (http status | bytes | url)"
foreach ($u in $Urls) {
try {
$sw = [Diagnostics.Stopwatch]::StartNew()
$resp = Invoke-WebRequest -Uri $u -Method Get -TimeoutSec 20 -UseBasicParsing
$sw.Stop()
Write-Log (" {0,-5} {1,9} bytes {2,6} ms {3}" -f $resp.StatusCode, $resp.RawContentLength, $sw.ElapsedMilliseconds, $u)
} catch {
Write-Log (" ERR {0} {1}" -f $u, $_.Exception.Message)
}
}
# Long-lived processes matter: ten orphaned servers were found running for
# eight hours on this machine, which is why this section exists at all.
$procs = Get-CimInstance Win32_Process -Filter "Name='node.exe' or Name='python.exe'" |
Where-Object { $_.CommandLine -match 'serve|http.server|proof|emulator|adb' }
if ($procs) {
Write-Log "PROCESSES (pid | minutes | command)"
foreach ($pr in $procs) {
$mins = [math]::Round(((Get-Date) - $pr.CreationDate).TotalMinutes, 1)
$cmd = $pr.CommandLine
if ($cmd.Length -gt 90) { $cmd = $cmd.Substring(0,90) }
Write-Log (" {0,-7} {1,7} min {2}" -f $pr.ProcessId, $mins, $cmd)
}
} else {
Write-Log "PROCESSES none of interest"
}
Start-Sleep -Seconds 120
}Classify Sensitivity
A Python command-line tool in the tools folder of Claude that classifies opinion (`classify_opinion`). It is built from the classify step (`classify`).
renderclaude / logs/tools/classify_sensitivity.py · lines 1–254 of 254 · Entry point · pattern _sentences (shared by 2 files)
- What it does
- It lists and searches its content. Defines _sentences, classify_opinion, classify, _selftest. Uses libraries __future__, re, sys. Side effects: changes the web page (DOM); starts processes.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'claude'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). README: "The architect's words: "Anything controversial like opinions about people, but keep all data that is publicly verifiable or neutral." `logs/tools/classify_sensitivity.py` implements exactly that and nothing wider."
- Downstream impact
- Used directly by 1 file: Jsonl to Parquet (claude). Reached from 1 other entry point, including Render Session Markdown (claude).
- What it achieves
- Sensitivity classifier for the cross-session memory store.
- Why it matters
- Imported by Jsonl to Parquet.
- Application
- claude · logs/tools · Python CLI
- Uses
- __future__, re, sys
- Used by
- imported by Jsonl to Parquet (import)
- Produces
- classify_opinion, classify
- Defines here
- _sentences, classify_opinion, classify, _selftest
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- claude@df9da02425fdf0c65d11a84f32cd9b3ef927b309 logs/tools/classify_sensitivity.py:1-254 · blob d98a3086c17554cb2cdd0a2a5341f5695907ded3 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, process · domain stage: agent_infra · users: ai_agent · canonical: unknown
#!/usr/bin/env python
"""Sensitivity classifier for the cross-session memory store.
The rule, in the architect's words:
"Anything controversial like opinions about people, but keep all data that is
publicly verifiable or neutral."
Three labels, written into the `sensitivity` column:
ok the default. Publicly verifiable or neutral.
opinion_about_person a subjective judgement about an identifiable HUMAN --
their competence, character, motives, or the quality of
their work *as a person*.
credential a credential value was found and replaced in `content`.
**FLAG, NEVER DELETE.** Every row is written to the Parquet whatever its label. The
`memory` view in logs/README.md filters to `sensitivity = 'ok'`, so the safe set is
what a query sees by default, while the raw union stays reachable for audit. A store
that silently drops rows cannot be audited and a misclassification cannot be undone.
DESIGN BIAS: precision over recall, deliberately. Over-flagging destroys the memory's
usefulness -- technical findings, measurements, defect analysis and CI results ARE the
value of this store, and every one of them mentions people, tools and failures. The
classifier therefore demands a conjunction (a human reference AND a judgement term
aimed at that human) and then applies hard vetoes for the four ways that conjunction
turns out to be innocent in this corpus:
1. technical senses of judgement words ("lazy until the user acts", "hostile reviewer")
2. self-correction by the assistant ("my diagnosis was wrong", "I was careless")
3. an agent, not a human ("Codex's fix was sloppy" -- an artefact assessment)
4. a judgement of an artefact ("the number is nonsense", "the claim is misleading")
Patterns are held as bare strings and compiled with re.I, never with an inline
`(?i)`: the composed patterns below concatenate them, and an inline global flag is
illegal anywhere but the start of an expression.
Run the self-test -- a check built only from cases the code already passes cannot fail:
python logs/tools/classify_sensitivity.py --selftest
"""
from __future__ import annotations
import re
import sys
OK = "ok"
OPINION = "opinion_about_person"
CREDENTIAL = "credential"
# ---------------------------------------------------------------------------
# Who counts as an identifiable human.
#
# Gazetteer, not a guess: these are the human references that actually occur in
# this estate's transcripts (probed across all 11 sources before the rule was
# written). Agent names are deliberately absent -- see AGENT_P.
# ---------------------------------------------------------------------------
NAME = r"Vikram(?:\s+Kumar)?"
ROLE = (r"the\s+(?:architect|user|owner|client|customer|colleague|manager|boss|"
r"employee|staff\s+member|recruiter|investor|founder|director|"
r"engineer\s+who|person\s+who|guy\s+who)")
PERSON_P = r"\b(" + NAME + r"|" + ROLE + r")(?:'s|s')?"
PERSON_RX = re.compile(PERSON_P, re.I)
# Pronouns are a person reference ONLY when the same sentence already names a human.
# On their own they match "her" inside quoted prose, "his" inside a read file, and so on.
PRONOUN_RX = re.compile(r"\b(he|she|him|her|his|hers)\b", re.I)
# Not humans. An agent assessing another agent's artefact is explicitly neutral.
AGENT_P = (r"\b(?:claude|codex|gemini|copilot|chatgpt|opus|sonnet|haiku|"
r"the\s+(?:agent|model|assistant|lane|subagent|session|bot|reviewer))\b")
AGENT_RX = re.compile(AGENT_P, re.I)
SELF_RX = re.compile(r"\b(I|I'm|I've|my|myself|we|we're|our|us)\b", re.I)
# ---------------------------------------------------------------------------
# What counts as a judgement OF a person. Character, competence, motive.
# Positive judgements are opinions too and are flagged the same way.
# ---------------------------------------------------------------------------
JUDGE_P = (r"\b("
# competence / care
r"sloppy|lazy|careless|negligent|reckless|incompetent|incompetence|unqualified|"
r"stupid|idiot|idiotic|moronic|dumb|clueless|ignorant|out\s+of\s+(?:his|her|their)\s+depth|"
r"amateurish|shoddy|half-?baked|"
# character
r"arrogant|egotistical|unprofessional|untrustworthy|dishonest|deceitful|liar|"
r"rude|obnoxious|abrasive|toxic|difficult\s+to\s+work\s+with|unreliable|flaky|"
# motive attribution
r"acting\s+in\s+bad\s+faith|in\s+bad\s+faith|malicious|sabotag\w*|"
r"deliberately\s+(?:misled|mislead|hid|hiding|lied|lying|concealed)|"
r"covering\s+(?:it\s+)?up|"
# explicit incapacity claims about a person
r"does\s*n[o']?t\s+(?:understand|know\s+what|care|listen)|"
r"can(?:no|')?t\s+be\s+trusted|"
# positive opinions -- still opinions about a person
r"brilliant|genius|talented|meticulous|diligent|conscientious"
r")\b")
JUDGE_RX = re.compile(JUDGE_P, re.I)
# ---------------------------------------------------------------------------
# Vetoes. Every one of these fired on a real sentence in this corpus during
# calibration; none is hypothetical.
# ---------------------------------------------------------------------------
TECH_VETO_RX = re.compile(r"("
r"lazy[- ]?(?:load\w*|evaluat\w*|init\w*|until|import)|lazily|"
r"hostile\s+(?:review\w*|amnesia|source|fork|prompt)|"
r"dumb\s+(?:pipe|terminal|component)|"
r"difficult\s+to\s+(?:calculate|estimate|measure|read|parse|reproduce|debug|test|say)|"
r"stupid\s+(?:info\w*|data|number|answer|question)|"
r"flaky\s+(?:test|check|gate|runner|network)|"
r"unreliable\s+(?:test|check|gate|runner|network|measurement|signal)|"
r"dont\s+be\s+lazy|don't\s+be\s+lazy"
r")", re.I)
# A judgement predicated of a thing, not a person.
ARTEFACT_RX = re.compile(r"\b(?:the\s+)?(?:number|numbers|figure|ratio|value|data|dataset|"
r"claim|statement|sentence|label|banner|column|row|table|json|file|script|test|check|gate|"
r"workflow|commit|branch|diff|patch|build|run|log|output|result|answer|code|module|function|"
r"query|schema|manifest|receipt|digest|report|readme|doc|docs)\b\s+(?:is|was|are|were|looks|"
r"seems|reads)\b", re.I)
# Self-correction: a judgement word owned by the speaker, within 30 characters.
SELF_JUDGE_RX = re.compile(r"\b(?:I|my|we|our|myself)\b[^.!?]{0,30}?" + JUDGE_P, re.I)
# An agent owning the judgement: "Codex's fix was sloppy", "the model is unreliable".
AGENT_JUDGE_RX = re.compile(AGENT_P + r"(?:'s|s')?[^.!?]{0,40}?" + JUDGE_P, re.I)
_SENT_SPLIT = re.compile(r"(?<=[.!?\n])\s+")
# How close a person reference and a judgement must be to count as predication.
WINDOW = 80
def _sentences(text):
for s in _SENT_SPLIT.split(text):
s = s.strip()
if s:
yield s
def classify_opinion(content):
"""Return (label, reason). Conservative: returns (OK, '') unless a human
reference and a judgement of that human co-occur and survive every veto."""
if not content:
return OK, ""
# Bounded work: the judgement lexicon is rare, so test it once over the whole
# payload before paying for sentence splitting on a 200 KB tool result.
if not JUDGE_RX.search(content):
return OK, ""
for sent in _sentences(content):
if len(sent) > 600: # a wall of log output, not a sentence about anyone
continue
if not JUDGE_RX.search(sent):
continue
if TECH_VETO_RX.search(sent):
continue
if SELF_JUDGE_RX.search(sent): # the assistant judging itself
continue
if AGENT_JUDGE_RX.search(sent): # an agent's artefact, not a human
continue
if ARTEFACT_RX.search(sent): # a thing, not a person
continue
if not PERSON_RX.search(sent): # pronouns alone are not a person reference
continue
# Predication test: a person reference and a judgement within WINDOW
# characters of each other, in either order.
for p in PERSON_RX.finditer(sent):
for j in JUDGE_RX.finditer(sent):
if abs(j.start() - p.start()) <= WINDOW:
reason = "judgement '%s' applied to person reference '%s'" % (
j.group(1).lower().strip(), p.group(0).lower().strip())
return OPINION, reason[:200]
return OK, ""
def classify(content, redaction_hits):
"""Row-level label. `redaction_hits` is the list of pattern names that fired."""
if redaction_hits:
return CREDENTIAL, "credential value replaced: " + ", ".join(sorted(set(redaction_hits)))
return classify_opinion(content)
# ---------------------------------------------------------------------------
# Self-test. Positive controls prove the classifier can fire at all; the negative
# controls are real sentences taken from these transcripts.
# ---------------------------------------------------------------------------
MUST_FLAG = [
"Vikram's fix was sloppy and he plainly does not understand the schema.",
"Honestly the architect is incompetent at anything touching CI.",
"The client is a liar; he deliberately hid the outage from us.",
"Vikram is brilliant at this, far sharper than the last owner.",
"the user is lazy and never reads the findings before replying",
"The manager cannot be trusted with a release window.",
"the colleague who wrote this is unprofessional and rude in review",
]
MUST_NOT_FLAG = [
# real sentences from the corpus
"the loader asserts payloadRequests === 0 at mount - lazy until the user acts.",
"He is right and my diagnosis was wrong in its conclusion, though not in its evidence.",
"You are a hostile reviewer.",
"the architect is asleep until 10:00 BST and wants roughly ten GridAtlas generations by then.",
"A ratio below 1.0 is physically nonsense for solar.",
"Contributor username, UID and changeset are deliberately excluded from published tables.",
"work hard dont be lazy and good night",
"However, as curtailment times are an unknown, it would be difficult to calculate the reduction.",
"This is the key find - the app already has an additive pattern: lazy-loaded cartridge sections.",
"Vikram found it from his phone and he is right: none of the pipelinenews are on globalgrid2050.com.",
"Weights to be set by the architect, not assumed.",
"Vikram tested the link working before the recent versions.",
# agent-on-agent artefact assessment, explicitly neutral
"Codex's fix was sloppy and the digest did not match.",
"The model is unreliable on long tool results.",
# artefact judgements
"The number is nonsense and the manifest is misleading.",
"the test is flaky on the Windows runner",
# self-correction
"I was careless with the denominator and the summary changed meaning.",
# neutral technical prose
"the pin held and the digest matched",
"gridatlas 239, globalgrid2050 3,597 files carry w/crlf in the working copy.",
]
def _selftest():
fails = []
for s in MUST_FLAG:
lab, why = classify_opinion(s)
if lab != OPINION:
fails.append(("FALSE NEGATIVE", s, lab, why))
for s in MUST_NOT_FLAG:
lab, why = classify_opinion(s)
if lab != OK:
fails.append(("FALSE POSITIVE", s, lab, why))
print("positive controls (must flag) : %d" % len(MUST_FLAG))
print("negative controls (must not flag) : %d" % len(MUST_NOT_FLAG))
for kind, s, lab, why in fails:
print(" %-15s %-22s %s [%s]" % (kind, lab, s[:80], why))
print("failures: %d" % len(fails))
return 1 if fails else 0
if __name__ == "__main__":
sys.exit(_selftest())