From 971a388d6abcdd4e2fca29a7fa17c1115fac76a8 Mon Sep 17 00:00:00 2001 From: BitmapAsset Date: Thu, 19 Nov 2026 00:43:06 -0800 Subject: [PATCH 1/2] bench(individuality): the P0 check accepts the missing-src message 0.15.1 rewords The P0 corpus records the earlier words of the error for a reward without `src` on a persona with `reward_from` (the corpus's `adaptive` and `guarded`); #100 reworded that message. `p0.py check` now compares an output of `replay` or `live` that differs from its record once more with every such message put back into the recorded words (the two forms the engine writes: a learning flag, a goal win; plain or JSON-escaped quotes) and reports the outputs that then equal their records apart as `src_message_reworded`. Any other byte still counts as a difference. The README logs the change under "Changes after freezing"; MANIFEST's p0.py line is updated. With a 0.15.1 build: {"outputs": 653, "differ": 0, "identical": 539, "stderr_warnings_only": 18, "src_message_reworded": 96, "strands_verified": 8, "verify_failed": []}, exit 0. With the released 0.15.0 binary: {"outputs": 653, "differ": 0, "identical": 629, "stderr_warnings_only": 24, "src_message_reworded": 0, "strands_verified": 8, "verify_failed": []}, exit 0. The corpus is unchanged (EXPECTED, the scripts and the strands). --- bench/individuality/README.md | 15 +++++++- bench/individuality/fixtures/MANIFEST | 2 +- bench/individuality/p0.py | 53 +++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/bench/individuality/README.md b/bench/individuality/README.md index 97c2188..869b450 100644 --- a/bench/individuality/README.md +++ b/bench/individuality/README.md @@ -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 @@ -223,3 +226,13 @@ 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). An output of `replay` or + `live` that differs from its record is compared once more with every such message put back into the recorded words (the + two forms the engine writes: a learning flag, a goal win) 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. diff --git a/bench/individuality/fixtures/MANIFEST b/bench/individuality/fixtures/MANIFEST index e1d89c4..60212cc 100644 --- a/bench/individuality/fixtures/MANIFEST +++ b/bench/individuality/fixtures/MANIFEST @@ -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 +8dfee6d532c07384c81f791d5109bd355853e422339a42909131dbd7e9b1301a 16068 ../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). diff --git a/bench/individuality/p0.py b/bench/individuality/p0.py index 85e08d4..32e0e74 100644 --- a/bench/individuality/p0.py +++ b/bench/individuality/p0.py @@ -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 @@ -61,6 +62,22 @@ 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 pattern matches the two forms the engine writes (a learning flag, a goal win), with plain quotes +# (stderr) or JSON-escaped ones (stdout), the allowed kinds joined by ` or `; SRC_MESSAGE_RECORDED is the recorded form. +_Q = rb'\\?"' +_NAME = rb'[A-Za-z0-9_.-]+' +_KIND = rb'[a-z]+' +_FLAG = rb'\{' + _Q + _NAME + _Q + rb':true,' + _Q + rb'src' + _Q + rb':' + _Q + _KIND + _Q + rb'\}' +_GOAL = (rb'\{' + _Q + rb'goals' + _Q + rb':\{' + _Q + _NAME + _Q + rb':\{' + _Q + rb'win' + _Q + rb':[0-9.]+\}\},' + _Q + + rb'src' + _Q + rb':' + _Q + _KIND + _Q + rb'\}') +SRC_MESSAGE = re.compile(rb'the event is missing the field `src` \(reward_from allows (' + _KIND + rb'(?: or ' + _KIND + + rb')*)\); one line that is accepted: (?:' + _FLAG + rb'|' + _GOAL + rb')') +SRC_MESSAGE_RECORDED = rb'the event needs a src (\1 allowed by reward_from)' + def first_event_with(key, k, names): events = common.read_jsonl(os.path.join(P0, "scripts", "%s-%d.jsonl" % (key, k))) @@ -85,6 +102,15 @@ 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, n = SRC_MESSAGE.subn(SRC_MESSAGE_RECORDED, data) + return rest if n 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 @@ -209,8 +235,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: @@ -221,6 +248,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(): @@ -233,6 +261,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)) @@ -253,17 +290,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__) From f8c4221514241aea142363b2f4389a2d3574d003 Mon Sep 17 00:00:00 2001 From: BitmapAsset Date: Thu, 19 Nov 2026 01:19:09 -0800 Subject: [PATCH 2/2] bench(individuality): the P0 rule accepts exactly the one message the corpus produces The corpus's scripts produce one missing-src message: a `praise` without `src` on `adaptive` and `guarded`, whose `reward_from` is `["env"]`. The rule now replaces exactly its bytes, in two writings (as the stderr line has them and as the error object on stdout has them, each quote escaped), with the recorded words (`bytes.replace`, no pattern), so any other change inside or outside the message is reported as a difference. The README entry says so; MANIFEST's p0.py line is updated. With a 0.15.1 build: {"outputs": 653, "differ": 0, "identical": 539, "stderr_warnings_only": 18, "src_message_reworded": 96, "strands_verified": 8, "verify_failed": []}, exit 0. With the released 0.15.0 binary: {"outputs": 653, "differ": 0, "identical": 629, "stderr_warnings_only": 24, "src_message_reworded": 0, "strands_verified": 8, "verify_failed": []}, exit 0. The corpus is unchanged (EXPECTED, the scripts and the strands). --- bench/individuality/README.md | 17 +++++++++-------- bench/individuality/fixtures/MANIFEST | 2 +- bench/individuality/p0.py | 23 ++++++++++------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/bench/individuality/README.md b/bench/individuality/README.md index 869b450..1e9ac84 100644 --- a/bench/individuality/README.md +++ b/bench/individuality/README.md @@ -228,11 +228,12 @@ relabelled. 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). An output of `replay` or - `live` that differs from its record is compared once more with every such message put back into the recorded words (the - two forms the engine writes: a learning flag, a goal win) 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. + 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. diff --git a/bench/individuality/fixtures/MANIFEST b/bench/individuality/fixtures/MANIFEST index 60212cc..1b3d8f7 100644 --- a/bench/individuality/fixtures/MANIFEST +++ b/bench/individuality/fixtures/MANIFEST @@ -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 -8dfee6d532c07384c81f791d5109bd355853e422339a42909131dbd7e9b1301a 16068 ../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). diff --git a/bench/individuality/p0.py b/bench/individuality/p0.py index 32e0e74..4ea64b0 100644 --- a/bench/individuality/p0.py +++ b/bench/individuality/p0.py @@ -66,17 +66,12 @@ def masked_err(err): # 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 pattern matches the two forms the engine writes (a learning flag, a goal win), with plain quotes -# (stderr) or JSON-escaped ones (stdout), the allowed kinds joined by ` or `; SRC_MESSAGE_RECORDED is the recorded form. -_Q = rb'\\?"' -_NAME = rb'[A-Za-z0-9_.-]+' -_KIND = rb'[a-z]+' -_FLAG = rb'\{' + _Q + _NAME + _Q + rb':true,' + _Q + rb'src' + _Q + rb':' + _Q + _KIND + _Q + rb'\}' -_GOAL = (rb'\{' + _Q + rb'goals' + _Q + rb':\{' + _Q + _NAME + _Q + rb':\{' + _Q + rb'win' + _Q + rb':[0-9.]+\}\},' + _Q - + rb'src' + _Q + rb':' + _Q + _KIND + _Q + rb'\}') -SRC_MESSAGE = re.compile(rb'the event is missing the field `src` \(reward_from allows (' + _KIND + rb'(?: or ' + _KIND - + rb')*)\); one line that is accepted: (?:' + _FLAG + rb'|' + _GOAL + rb')') -SRC_MESSAGE_RECORDED = rb'the event needs a src (\1 allowed by reward_from)' +# 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): @@ -107,8 +102,10 @@ def with_recorded_src_message(name, data): such message in the recorded words, else None.""" if not re.match(r"(replay|live)/[^/]+/s\d+/\d+/(stdout|stderr)$", name): return None - rest, n = SRC_MESSAGE.subn(SRC_MESSAGE_RECORDED, data) - return rest if n else 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):