Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bench/individuality/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ personas without the new blocks × seeds 0–2 × 4 committed random scripts of
`describe`, `init`, `compile`, `lint --seeds 0-99`, and `lint`, `prove` and `fuzz` documents of the shipped rules. `p0.py
check` exits 0 when every output equals its record. One line may differ, on stderr only: a script that sends a `senses` key
to a persona without the block gets `live`'s one line naming it (scripts k=1, at their earliest such event); the check accepts
exactly that line there and counts those outputs apart.
exactly that line there and counts those outputs apart. From 0.15.1 one message differs too: the error for a reward without
`src` (the corpus's two personas with `reward_from`, `adaptive` and `guarded`) has new words, in the error object on stdout and
in the stderr line; the check puts each such message back into the recorded words, compares, and counts those outputs apart
(96 of the 653).

## What this benchmark cannot see

Expand Down Expand Up @@ -223,3 +226,14 @@ relabelled.
event is not re-run (without refused events it is the same run, and metric d replays every strand); the reported
eviction and expiry shares are given per run, with the age of the addressed payments. The numbers of the run before the change stay in
the history: c1, c2, c3 and c4 1.0, 50/50 pairs identical.
- `p0.py` (0.15.1): `check` also accepts the message 0.15.1 rewords. A reward without `src` on a persona with `reward_from`
is refused as before (exit 2, the error's `code` and `path` unchanged), and its message, in the error object on stdout and
in the stderr line, now names the missing field and shows one accepted line (CHANGELOG, 0.15.1). The corpus's scripts
produce one such message: a `praise` without `src` on `adaptive` and `guarded`, whose `reward_from` is `["env"]`. An
output of `replay` or `live` that differs from its record is compared once more with exactly that message put back into
the recorded words and, when it then equals its record, is reported apart as `src_message_reworded`: 96 outputs with a
0.15.1 build (the `replay` and `live` stdout and stderr of `adaptive` and `guarded`, 3 seeds and 4 scripts each), none
with 0.15.0. Unlike the two warning lines, this message is part of a document: the error object on stdout (48 of the
96). Reason: the rewording is part of 0.15.1 (the error names the field and shows an accepted event); the engine's
behaviour is unchanged, and every stance, state and strand stays byte-identical. EXPECTED, the scripts and the strands
are unchanged; MANIFEST's p0.py line was updated.
2 changes: 1 addition & 1 deletion bench/individuality/fixtures/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ a88d3b20b41e9843f2b9ac9b117d5b462ec6b1095c762da531cb98481ff48432 43389 p0/strand
615978432a80e6b8be7fdf6e2382438516dc67acae56c562221c89654cae479e 6815 p0/strands/tutor-s0-0.appended
cf9073507dad98bedc4f09ca2e49f34862919240c64c548b7a1dcf58fda4804b 1160 p0/strands/tutor-s0-0.state.json
4db5f3d83a0e6df0ea632c35957cdb0970665422af9054fa50e5468e13a888ab 55008 p0/strands/tutor-s0-0.strand
344a54d4cb6bc9318caf82af6eeb776d774ef7ff1a4548bf9fb67a6061bf00e4 13470 ../p0.py
ccf95096a407aa3df603f2444a68e33b77338d50739b71d68d24adad31e3271e 15829 ../p0.py
#
# Metrics a, b, d and e: frozen 2026-10-14 before their first run (personas, generator, streams, bars).
# Re-generate the streams: python3 lives.py (gives these bytes).
Expand Down
50 changes: 42 additions & 8 deletions bench/individuality/p0.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
python3 p0.py record # with a released binary: writes fixtures/p0/EXPECTED, the strands and fixtures/MANIFEST
python3 p0.py check # with the binary under test: every output equals its recorded sha256 (exit 1 if not); a
# `live` stderr may also carry the senses and credit warning lines (WARNINGS) where its script
# sends those keys, and is reported apart
# sends those keys, and is reported apart; a `replay` or `live` output may carry the
# message 0.15.1 rewords (SRC_MESSAGE) and is then reported apart too

The corpus: every persona of fixtures/gen.py's P0 list x seeds 0-2 x its committed random scripts, through `persona replay`
and `live --clock fixed` (stances, error objects, final state, strand), plus `init`, `check`, `describe`, `compile`, `lint
Expand Down Expand Up @@ -61,6 +62,17 @@ def masked_err(err):
"inputs (listed in ignored), feedback pays the previous stance\n")
WARNINGS = [(SENSES_WARNING, ("senses",)), (CREDIT_WARNING, ("await", "for", "cancel"))]

# The message 0.15.1 rewords in a corpus output: a reward without `src`, sent to a persona with `reward_from` (the scripts
# of `adaptive` and `guarded` carry such events), is refused as before (exit 2, the error's `code` and `path` unchanged);
# its message, in the error object on stdout and in the stderr line, now names the missing field and shows one accepted
# line. Unlike the warning lines, this message is part of a document (the error object); stances, states and strands stay
# byte-identical. The corpus's scripts produce one such message (a `praise` without `src`; `reward_from` is `["env"]`),
# and the rule accepts exactly its bytes, as the stderr line has them and as the error object has them (each quote escaped).
SRC_MESSAGE_RECORDED = b"praise is a reward: the event needs a src (env allowed by reward_from)"
SRC_MESSAGE = (b'praise is a reward: the event is missing the field `src` (reward_from allows env); one line that is '
b'accepted: {"praise":true,"src":"env"}')
SRC_MESSAGES = (SRC_MESSAGE, SRC_MESSAGE.replace(b'"', b'\\"'))


def first_event_with(key, k, names):
events = common.read_jsonl(os.path.join(P0, "scripts", "%s-%d.jsonl" % (key, k)))
Expand All @@ -85,6 +97,17 @@ def without_warnings(name, data):
return rest if removed else None


def with_recorded_src_message(name, data):
"""For a `replay` or `live` stdout or stderr that carries the message 0.15.1 rewords (SRC_MESSAGE): the bytes with every
such message in the recorded words, else None."""
if not re.match(r"(replay|live)/[^/]+/s\d+/\d+/(stdout|stderr)$", name):
return None
rest = data
for message in SRC_MESSAGES:
rest = rest.replace(message, SRC_MESSAGE_RECORDED)
return rest if rest != data else None


def rel(path):
"""A repository path as the corpus passes it: relative to the root, where every command runs (common.run's cwd). A
fuzz counterexample's `explain` and `replay` strings name the persona path as given, so an absolute path would tie the
Expand Down Expand Up @@ -209,8 +232,9 @@ def keep(key, data, st):


def check(verbose=False):
"""Returns (outputs checked, differing names, stderr outputs equal but for the warning lines, strands verified, strand
failures, seconds)."""
"""Returns (outputs checked, differing names, stderr outputs equal but for the warning lines, outputs equal once the
message 0.15.1 rewords is put back into the recorded words (and, in a `live` stderr, without the warning lines),
strands verified, strand failures, seconds)."""
t0 = time.time()
expected = {}
with open(os.path.join(P0, "EXPECTED"), encoding="utf-8") as f:
Expand All @@ -221,6 +245,7 @@ def check(verbose=False):
expected[name] = (sha, int(size), int(code))
diffs = []
warned = []
reworded = []
seen = 0
names = set()
for name, code, data in outputs():
Expand All @@ -233,6 +258,15 @@ def check(verbose=False):
if rest is not None and e == (common.sha256_bytes(rest), len(rest), code):
warned.append(name)
continue
back = with_recorded_src_message(name, data)
if back is not None:
if e == (common.sha256_bytes(back), len(back), code):
reworded.append(name)
continue
rest = without_warnings(name, back)
if rest is not None and e == (common.sha256_bytes(rest), len(rest), code):
reworded.append(name)
continue
diffs.append(name)
if verbose:
print("DIFF %s: expected %s, got %s" % (name, e, got))
Expand All @@ -253,17 +287,17 @@ def check(verbose=False):
if expected.get(name) != (common.sha256_bytes(data), len(data), code):
diffs.append(name)
missing = [n for n in expected if n not in names]
return seen, diffs + missing, warned, nverified, vfail, time.time() - t0
return seen, diffs + missing, warned, reworded, nverified, vfail, time.time() - t0


if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "record":
record()
elif len(sys.argv) > 1 and sys.argv[1] == "check":
n, diffs, warned, nv, vfail, secs = check(verbose=True)
print(json.dumps({"outputs": n, "differ": len(diffs), "identical": n - len(diffs) - len(warned),
"stderr_warnings_only": len(warned), "strands_verified": nv, "verify_failed": vfail,
"seconds": round(secs, 1)}))
n, diffs, warned, reworded, nv, vfail, secs = check(verbose=True)
print(json.dumps({"outputs": n, "differ": len(diffs), "identical": n - len(diffs) - len(warned) - len(reworded),
"stderr_warnings_only": len(warned), "src_message_reworded": len(reworded),
"strands_verified": nv, "verify_failed": vfail, "seconds": round(secs, 1)}))
sys.exit(1 if diffs or vfail else 0)
else:
print(__doc__)
Expand Down
Loading