One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.6 KiB
Scoped group ledger contract (version 1)
C01 — domain and ownership
A ledger is an initially empty forest of at most 32 live groups, numbered 0..31. A group stores a parent (-1 for a root) and a signed weight in -1000..1000. Children are traversed in ascending group number. Logical owners are integers 1..8. The service is a deterministic C++17 model: it never blocks and needs no threads. All integer API arguments have type int; arithmetic totals use signed 64 bits.
C02 — gate
The gate initially has owner=depth=0 and all counters zero.
acquire(owner) rejects invalid owners, incrementing denied once.
When free, a valid acquisition sets owner and depth=1.
Acquisition by its current owner increments depth; a different owner is denied.
Every accepted acquisition increments acquisitions and updates maximum depth.
release(owner) succeeds only for a valid current owner with nonzero depth.
A successful release decrements depth once and increments releases once; only
when depth reaches zero does owner become zero. A rejected release increments
invalid_releases once and changes nothing else. There is no arbitrary depth cap.
reset clears the gate and its counters. Snapshot field order is owner, depth,
acquisitions, releases, denied, invalid_releases, maximum_depth.
C03 — topology edits
add(id,parent,weight) requires a free id, valid weight, and either parent=-1
or a live parent. move(id,parent) requires a live id and valid parent, and
rejects placing a node under itself or any descendant. Moving to its existing
parent succeeds. set_weight(id,weight) requires a live id and valid weight.
erase(id) deletes that group and its entire subtree. Invalid edits return -1
and preserve the forest and gate. Accepted edits return 0, do not use the gate,
and leave all result totals and counts zero. Reset also empties the forest.
C04 — recursive report
report(owner,id) validates a live group and valid owner before touching the gate.
Each visited group acquires the same ledger gate with that owner, keeps its
acquisition while recursively visiting its children, and releases exactly one
acquisition on exit. One call's acquisitions preserve any preexisting acquisitions.
The selected group has level 0; a group's contribution is weight*(level+1).
Result total is the sum of contributions and visited is the number of visited
groups. A denied acquisition returns code -2 with zero observations for that
frame; already completed observations propagate to the caller, and all accepted
acquisitions still release. Invalid initial arguments return -1 without gate
changes. Valid complete reports return 0. Reports never change group weights.
C05 — maintenance branch
adjust(owner,id,delta,other) accepts valid distinct owners and a live id, with
delta in -1000..1000. It preflights all resulting subtree weights; if any would
leave -1000..1000 it returns -1 without any mutation or gate operation.
It then recursively acquires and releases exactly as C04, but adds delta to each
visited weight before visiting children. After children, while its own frame's
acquisition is still held, each visited frame tries acquire(other) once. It
increments probes, and if accepted increments stolen then releases other once.
These observations are aggregated along with updated weighted total and visited.
A correct gate keeps these other-owner probes denied even in leaf frames.
Invalid initial arguments preserve all state. A gate denial returns -2 and
propagates completed observations as in C04. Existing outer acquisitions survive.
C06 — API results and snapshots
Result order is code,total,visited,probes,stolen. Initial zero observations are
used on invalid calls and direct gate commands. Ledger::snapshot() returns
live group records in ascending id, with exactly id,parent,weight for each.
No unused storage bytes, allocator details, or internal representation are part
of the contract. Snapshot and gate accessors do not change any state.
C07 — public line driver
scope-demo with no arguments runs a small report demonstration. With --wire
it reads LF-delimited command lines and emits exactly one observation per line.
Commands: R; A id parent weight; M id parent; W id weight; D id;
F owner id; U owner id delta other; L owner; X owner; Q.
L/X expose C02 acquire/release and return code 0 on acceptance, -2 otherwise.
R resets all state; Q only observes. Every other syntax or invalid edit is -1.
Numbers are ASCII signed decimal tokens, optional + or -, any leading zeros;
range is C++ int. Fields are separated only by space, TAB, or CR. Leading and
trailing such whitespace is permitted; empty lines are invalid. No VT or FF is
whitespace here. Overflow, missing/extra tokens and unknown commands are invalid
and leave state untouched. Every result line is Result's five fields, then C02's
seven gate fields, then live count and that many C06 triples. All output tokens
are signed ASCII decimal, allowing + and arbitrary leading zeros, separated by
space/TAB/CR; LF terminates each record. No extra stdout records are permitted.
Arbitrary stderr diagnostics including arbitrary bytes are permitted without a
size cap. A functioning driver finishes with exit code 0, including invalid lines.
C08 — build and delivery
Build with make; run ./scope-demo and ./scope-demo --wire. The environment
supplies g++, make and Python 3; no CMake or downloaded package is required.
Only scope_lock.cpp and ledger.cpp are submitted. The published header and wire
observer are fixed support, compiled afresh with those submitted sources. Public
interfaces, C01-C07 behavior and preserved observations are the acceptance contract.