Files
Drew T 827295e241 tools+docs(phase-33.5): task 13.5 — the tools audit + the two dictionaries: tools/tool_census.py (two agreeing enumerations of 327 tool files; docstring/SETUP row/consumers/class derived from the tree; the authored half in config/tool_dictionary.tsv — phase · portability · the NEED each tool answers · what · adapts · verdict — with coverage asserted both ways) → docs/tool-index.md (need-keyed, KEEP-GEN, Reference-index row, wiki + how-to pointers), the kit's tools/MANIFEST.md regenerated (header states live 293 + superseded 28 = 321 rows), and the two verbatim corpora in-tree (Drew, confirmed S91): decomp-architect/corpus/tools/<phase>/ (302 copies + 28 superseded pointers + INDEX) and corpus/cookbook/ (the cookbook, its symptom index, the codegen map, a front page stating what transfers per compiler) — sha1-equal to their sources by tool_census --check in tools-health, regenerated by make kit-corpus; kit_lint exempts the corpus dirs (verbatim evidence) but syntax-checks them; G66 (consult the tool dictionary first) + G67 (translate an inherited idiom through its pass) + two memory seeds (34 at install); SETUP Step 6 installs docs/knowledge-corpus.md and checks the manifest against its own stated total; the ops-setup dictionary rows; the intake's Phase 7 cites G66/G67 and Phase 10 + Part C name the raw-cast → declared-symbol step; templates/layout-contract.md (the five-tool probe, a draft for the split). The review under Drew's criterion: 93 no-consumer tools (one Opus agent's draft, verified: 0 defects, every successor live, 0 live consumers, 0 collisions; four one-off verdicts overturned to STILL-NEEDED) → 34 retired by git mv to tools/sunset/ (28 superseded, 6 one-offs; README review table; SETUP rows moved; Archive-index group). Run 4 (fresh throwaway, the final kit): stopped on my Step-6 check (321 vs the live 293) → both sides derived → resumed → PASS 10/10, manifest 56 == 56, 4 commits, guardrails held (the one foreign path was the timeline regenerated by the detached tools-health). tools-health OK; doc_links --strict rc 0; audit_public OK over 6,842 paths; the purge probe PASSED (Phase 34's gate open). decision-log "P33.5 S91" + accelerators "P33.5 S91" banked; log + checkpoint (NEXT = task 14, xHigh, fresh session)
2026-09-07 22:09:15 -06:00

58 lines
2.5 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# glm_parallel.sh — parallel cloud-drafting for the GLM (OpenRouter) matching tier.
#
# Splits a targets JSON into K contiguous slices and runs K concurrent api_draft.py
# workers against the same OpenRouter endpoint (GLM is latency-bound, so N concurrent
# HTTP calls ~= N× throughput; OpenRouter fans out over ~6 providers, no hard cap).
# All workers write <fn>.c + <fn>.reasoning.txt into ONE shared out dir (distinct fn
# names => no collision). The whole-binary byte-gate (gate_stage) is the sole arbiter
# afterward (G3/P9) — this script only DRAFTS.
#
# The OpenRouter key is read from .env (key `open_router_key=`) at runtime and passed
# via env to the workers only — never echoed, never written to a file.
#
# Usage: tools/glm_parallel.sh <targets.json> <out_dir> [K=6] [iters=2] [model=z-ai/glm-5.2] [maxtok=8000]
set -euo pipefail
cd "$(dirname "$0")/.." # repo root
T="${1:?usage: glm_parallel.sh <targets.json> <out_dir> [K] [iters] [model] [maxtok]}"
OUT="${2:?out_dir required}"
K="${3:-6}"
ITERS="${4:-2}"
MODEL_ID="${5:-z-ai/glm-5.2}"
MAXTOK_V="${6:-8000}"
KEY="$(sed -n 's/^open_router_key=//p' .env | tr -d '"'\''\r ')"
[ -n "$KEY" ] || { echo "glm_parallel: no open_router_key in .env" >&2; exit 1; }
mkdir -p "$OUT"
SLICEDIR="$OUT/.slices"; rm -rf "$SLICEDIR"; mkdir -p "$SLICEDIR"
NSLICES=$(python3 - "$T" "$K" "$SLICEDIR" <<'PY'
import json, sys, math
targets = json.load(open(sys.argv[1])); K = int(sys.argv[2]); sd = sys.argv[3]
n = len(targets); per = max(1, math.ceil(n / K)); w = 0
for i in range(0, n, per):
json.dump(targets[i:i+per], open('%s/slice_%d.json' % (sd, w), 'w')); w += 1
print(w)
PY
)
echo "glm_parallel: $T -> $NSLICES workers (iters=$ITERS, model=$MODEL_ID) -> $OUT"
pids=()
for f in "$SLICEDIR"/slice_*.json; do
API_BASE=https://openrouter.ai/api/v1 MODEL="$MODEL_ID" API_KEY="$KEY" \
LEAN=1 MAXTOK="$MAXTOK_V" REASON=1 TEMP=0.3 \
.venv/bin/python tools/api_draft.py --targets "$f" --out "$OUT" --iters "$ITERS" \
> "$OUT/$(basename "$f" .json).log" 2>&1 &
pids+=($!)
done
echo "glm_parallel: launched ${#pids[@]} workers (pids ${pids[*]})"
fail=0
for p in "${pids[@]}"; do wait "$p" || fail=$((fail+1)); done
echo "glm_parallel: all workers done ($fail failed)"
DRAFTS=$(ls "$OUT"/*.c 2>/dev/null | wc -l)
COST=$(grep -ohE 'cost \$[0-9.]+' "$OUT"/slice_*.log 2>/dev/null | grep -oE '[0-9.]+' | paste -sd+ | bc -l 2>/dev/null || echo 0)
echo "glm_parallel: $DRAFTS drafts written; summed reported cost \$${COST:-0}"