From 6fc9d9b616d566c4979084ed152c3c198c287b57 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 18:39:04 -0600 Subject: [PATCH 1/2] fix(agents): put the no-owner-waits and finish-your-work rules in the rulebook The fleet's main queue held 0 queued and 595 blocked tasks on 2026-11-22. Two causes were not written anywhere an agent reads on every run: - AGENTS.md never mentioned FDR-0013, so 130 tasks sat parked on the owner. It now says: decide, record, continue; only a hands item waits. - Merged work was not closed. 108 open issues carried status:in-review with every pull request merged, and tasks waited on them as open blockers. AGENTS.md now says a completing PR says "Closes #N" and the issue is closed, or its remainder noted, after the merge. The testing doctrine moves to doc/agents/testing-doctrine.md to make room; AGENTS.md is 7,870 of 8,000 bytes. Also fixes the #10219 done check: the formatter re-padded the committed bake-off table, so the validator's exact-text comparison failed on main. It now compares cells, with tests, and the nightly scripts workflow runs it. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF --- .github/workflows/scripts-test.yml | 5 + AGENTS.md | 25 +++-- .../test_validate_real_encoding_bakeoff.py | 97 +++++++++++++++++++ .../validate_real_encoding_bakeoff.py | 33 ++++++- doc/agents/testing-doctrine.md | 11 +++ 5 files changed, 162 insertions(+), 9 deletions(-) create mode 100755 doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py mode change 100644 => 100755 doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/validate_real_encoding_bakeoff.py create mode 100644 doc/agents/testing-doctrine.md diff --git a/.github/workflows/scripts-test.yml b/.github/workflows/scripts-test.yml index dbdeef8c47..8e7cb8af3d 100644 --- a/.github/workflows/scripts-test.yml +++ b/.github/workflows/scripts-test.yml @@ -58,6 +58,11 @@ jobs: run: | test -f scripts/fleet/flow-report/test_flow_report.py python3 -I -m unittest discover -s scripts/fleet/flow-report -p 'test_flow_report.py' -v + - name: Run graph encoding bake-off report check (#10219) + run: | + test -f doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py + python3 -I -m unittest discover -s doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph -p 'test_validate_real_encoding_bakeoff.py' -v + python3 -I doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/validate_real_encoding_bakeoff.py --check-committed - name: Run queue transport alert contract tests (#6369) run: | test -f scripts/fleet/queue-transport-alert/test_check_transport.py diff --git a/AGENTS.md b/AGENTS.md index 86dc553e7a..2e20b3571b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,13 +33,10 @@ discipline (target broker, narrowest Rust verification). ## Testing doctrine -Three tools, used where they fit: - -- **PBT (property-based testing):** state invariants that must always hold, then let a generator hammer the code with thousands of random inputs to find counterexamples. Where code has meaningful invariants — parsers, serializers, state machines, replication, ID/crypto formats — state the invariants and cover them with property tests. In Rust here that is `proptest` (already a dev-dependency of `pkgs/id`). -- **MBT (model-based testing):** where a system's behavior has a spec or design model, build the model and generate tests — and their expected results — from it, instead of hand-writing cases only. -- **Oracles:** the decision procedure that tells you whether actual output matches expected — the hard part of automated testing. Every automated test names its oracle: a reference implementation, the model, an invariant check, or a golden corpus. A test with no decidable oracle is a smell to fix, not ship. - -Example-based tests remain fine for smoke and acceptance coverage; they do not replace PBT/MBT where those fit. +Full text: [`doc/agents/testing-doctrine.md`](doc/agents/testing-doctrine.md). +In short: property tests (PBT, `proptest`) where code has invariants; +model-based tests (MBT) where a spec or model exists; every automated +test names its oracle. Example tests stay fine for smoke and acceptance. ## Operator script argument contract (#3352) @@ -93,6 +90,20 @@ for ownership; check notes before posting a park/pickup note. Always post progress notes. Land or checkpoint a reviewable slice before parking for size. There is no ownership handoff: never park awaiting one. +## Nothing waits on the owner + +Full text: [FDR-0013](doc/decisions/FDR-0013-no-owner-decision-gates.md); how: `.agents/skills/decide-and-proceed`. +Never park, block or label work as waiting on the owner for a choice, +review or approval: decide, record it on the issue, continue. Only a +hands item (one action only a person's hands can do) may wait. + +## Finishing work + +A PR that completes an issue says `Closes #N`. After a merge, run the +issue's done check and close it, or note what is left and clear +`status:in-review`: open issues with merged work block their waiters. +Out of work: `fleet agent next` ([onboarding](doc/agents/onboarding-an-agent.md)). + ## Research, design and delivery workflow Use it when a request, from one sentence to pages of voice-transcribed notes, should become researched documents, designs, plans or parallel PRs. Contracts: [`planning/workflow/`](planning/workflow/README.md). Where documents go: [`planning/DOCUMENTATION_ARCHITECTURE.md`](planning/DOCUMENTATION_ARCHITECTURE.md). Tool: `python3 -I scripts/research_workflow.py` (`check`, `status`, `ready`). diff --git a/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py b/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py new file mode 100755 index 0000000000..d1c82faefb --- /dev/null +++ b/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +"""Tests for the layout-independent report comparison (stdlib only). + +Oracle: a Markdown table says the same thing however its cells are +padded, and something different as soon as one cell's text changes. The +repository formatter re-pads tables on main, so the report check must +pass on a re-padded table and still fail on a changed number. +""" + +from __future__ import annotations + +import importlib.util +import unittest +from pathlib import Path + +HERE = Path(__file__).resolve().parent +SPEC = importlib.util.spec_from_file_location( + "bakeoff", HERE / "validate_real_encoding_bakeoff.py" +) +bakeoff = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(bakeoff) + +TIGHT = "| engine | load µs | bytes |\n|---|---:|---:|\n| `a` | 7982 | 312475 |\n| `b` | 199808 | 1118208 |" +PADDED = ( + "\n" + "| engine | load µs | bytes |\n" + "| ------ | ------: | ------: |\n" + "| `a` | 7982 | 312475 |\n" + "| `b` | 199808 | 1118208 |\n" +) + + +class TableCells(unittest.TestCase): + def test_padding_rule_width_and_blank_lines_do_not_change_the_cells(self) -> None: + self.assertEqual(bakeoff.table_cells(TIGHT), bakeoff.table_cells(PADDED)) + self.assertEqual( + bakeoff.table_cells(PADDED), + [ + ["engine", "load µs", "bytes"], + ["`a`", "7982", "312475"], + ["`b`", "199808", "1118208"], + ], + ) + + def test_a_changed_number_a_missing_row_or_stray_text_is_a_difference(self) -> None: + base = bakeoff.table_cells(TIGHT) + self.assertNotEqual( + bakeoff.table_cells(PADDED.replace("312475", "312476")), base + ) + self.assertNotEqual( + bakeoff.table_cells("\n".join(PADDED.splitlines()[:-1])), base + ) + self.assertNotEqual(bakeoff.table_cells(PADDED + "edited by hand\n"), base) + # A reordered pair of rows is a different table too. + lines = TIGHT.splitlines() + self.assertNotEqual( + bakeoff.table_cells("\n".join(lines[:2] + [lines[3], lines[2]])), base + ) + + def test_list_items_ignore_blank_lines_and_indentation_only(self) -> None: + self.assertEqual( + bakeoff.list_items("\n- load µs: `a`\n\n - bytes: `a`\n"), + ["- load µs: `a`", "- bytes: `a`"], + ) + self.assertNotEqual( + bakeoff.list_items("- load µs: `b`"), bakeoff.list_items("- load µs: `a`") + ) + + +class CommittedReport(unittest.TestCase): + def test_the_committed_report_matches_the_committed_results(self) -> None: + results = bakeoff.load_json(bakeoff.RESULTS) + bakeoff.check_report(results) + + def test_a_report_with_one_changed_cell_is_refused(self) -> None: + results = bakeoff.load_json(bakeoff.RESULTS) + engine = bakeoff.ENGINES[0] + rows = bakeoff.table_values(results) + original = bakeoff.REPORT + text = original.read_text(encoding="utf-8") + needle = f" {rows[engine][0]} " + self.assertIn(needle, text) + changed = HERE / "real-encoding-bakeoff.changed-for-test.md" + changed.write_text( + text.replace(needle, f" {rows[engine][0] + 1} ", 1), encoding="utf-8" + ) + try: + bakeoff.REPORT = changed + with self.assertRaisesRegex(bakeoff.Invalid, "table differs"): + bakeoff.check_report(results) + finally: + bakeoff.REPORT = original + changed.unlink() + + +if __name__ == "__main__": + unittest.main() diff --git a/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/validate_real_encoding_bakeoff.py b/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/validate_real_encoding_bakeoff.py old mode 100644 new mode 100755 index c665ec5a58..8f4936202a --- a/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/validate_real_encoding_bakeoff.py +++ b/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/validate_real_encoding_bakeoff.py @@ -612,14 +612,43 @@ def block(text: str, name: str) -> str: return match.group(1) +def table_cells(markdown: str) -> list[list[str]]: + """The cells of a Markdown table, row by row, without its layout. + + The repository's formatter pads cells, widens the rule row and adds + blank lines around a block. None of that changes what the table says, + so the comparison is on cell text: the rule row is dropped and each + cell is stripped. A row that is not a table row is kept as one cell, + so stray text in the block still makes the comparison fail. + """ + rows: list[list[str]] = [] + for line in markdown.splitlines(): + line = line.strip() + if not line: + continue + if not (line.startswith("|") and line.endswith("|") and len(line) > 1): + rows.append([line]) + continue + cells = [cell.strip() for cell in line[1:-1].split("|")] + if all(re.fullmatch(r":?-+:?", cell) for cell in cells): + continue + rows.append(cells) + return rows + + +def list_items(markdown: str) -> list[str]: + """The non-blank lines of a block, each stripped.""" + return [line.strip() for line in markdown.splitlines() if line.strip()] + + def check_report(results: dict) -> None: text = REPORT.read_text(encoding="utf-8") need( - block(text, "table") == render_table(results), + table_cells(block(text, "table")) == table_cells(render_table(results)), "report: table differs from the committed results", ) need( - block(text, "leaders") == render_leaders(results), + list_items(block(text, "leaders")) == list_items(render_leaders(results)), "report: leaders differ from the committed results", ) need(results["fixture"]["sha256"] in text, "report: must name the fixture SHA-256") diff --git a/doc/agents/testing-doctrine.md b/doc/agents/testing-doctrine.md new file mode 100644 index 0000000000..87850b24f0 --- /dev/null +++ b/doc/agents/testing-doctrine.md @@ -0,0 +1,11 @@ +# Testing doctrine + +Indexed from [`AGENTS.md`](../../AGENTS.md). + +Three tools, used where they fit: + +- **PBT (property-based testing):** state invariants that must always hold, then let a generator hammer the code with thousands of random inputs to find counterexamples. Where code has meaningful invariants — parsers, serializers, state machines, replication, ID/crypto formats — state the invariants and cover them with property tests. In Rust here that is `proptest` (already a dev-dependency of `pkgs/id`). +- **MBT (model-based testing):** where a system's behavior has a spec or design model, build the model and generate tests — and their expected results — from it, instead of hand-writing cases only. +- **Oracles:** the decision procedure that tells you whether actual output matches expected — the hard part of automated testing. Every automated test names its oracle: a reference implementation, the model, an invariant check, or a golden corpus. A test with no decidable oracle is a smell to fix, not ship. + +Example-based tests remain fine for smoke and acceptance coverage; they do not replace PBT/MBT where those fit. From b38d430161619a795656243fc6902e5ea6dfb707 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 18:49:25 -0600 Subject: [PATCH 2/2] test(id-atlas): property tests for the layout-independent report check Seeded generator tests (stdlib only): any layout of a cell matrix parses back to the matrix, two layouts of one table compare equal, and changing any one cell is always a difference. Adds a refusal test for a changed leader line. Review finding on #12265. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF --- .../test_validate_real_encoding_bakeoff.py | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py b/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py index d1c82faefb..4f442c9670 100755 --- a/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py +++ b/doc/2026-11-13T03-40-00Z_design_id-atlas-summit/part-a-graph/test_validate_real_encoding_bakeoff.py @@ -10,6 +10,7 @@ from __future__ import annotations import importlib.util +import random import unittest from pathlib import Path @@ -67,6 +68,94 @@ def test_list_items_ignore_blank_lines_and_indentation_only(self) -> None: ) +CELL_ALPHABET = "abcxyzABC0123456789µ`_. /" +SEED = 10219 +CASES = 2000 + + +def random_matrix(rng: random.Random) -> list[list[str]]: + """A header row and zero to five body rows, one to six cells each.""" + columns = rng.randint(1, 6) + + def cell() -> str: + return "".join( + rng.choice(CELL_ALPHABET) for _ in range(rng.randint(0, 9)) + ).strip() + + return [[cell() for _ in range(columns)] for _ in range(rng.randint(1, 6))] + + +def random_layout(rng: random.Random, matrix: list[list[str]]) -> str: + """The matrix as a Markdown table under a random layout. + + Everything the formatter may vary is drawn at random: the padding on + each side of every cell, the width and alignment colons of the rule + row, and blank lines and indentation around the table. + """ + + def row(cells: list[str]) -> str: + return ( + "|" + + "|".join( + " " * rng.randint(0, 4) + c + " " * rng.randint(0, 4) for c in cells + ) + + "|" + ) + + def rule_cell() -> str: + return rng.choice(["", ":"]) + "-" * rng.randint(1, 12) + rng.choice(["", ":"]) + + lines = [row(matrix[0]), row([rule_cell() for _ in matrix[0]])] + [ + row(r) for r in matrix[1:] + ] + lines = [" " * rng.randint(0, 3) + line for line in lines] + return "\n" * rng.randint(0, 3) + "\n".join(lines) + "\n" * rng.randint(0, 3) + + +class LayoutProperty(unittest.TestCase): + """Property tests with a seeded generator (stdlib only). + + Oracle: the generating model. A table is rendered from a cell matrix, + so the matrix is the expected answer for every layout of it. + """ + + def test_any_layout_of_a_table_parses_back_to_its_cells(self) -> None: + rng = random.Random(SEED) + for case in range(CASES): + matrix = random_matrix(rng) + rendered = random_layout(rng, matrix) + self.assertEqual( + bakeoff.table_cells(rendered), + matrix, + f"seed {SEED} case {case}: {rendered!r}", + ) + + def test_two_layouts_of_one_table_always_compare_equal(self) -> None: + rng = random.Random(SEED + 1) + for case in range(CASES): + matrix = random_matrix(rng) + first, second = random_layout(rng, matrix), random_layout(rng, matrix) + self.assertEqual( + bakeoff.table_cells(first), + bakeoff.table_cells(second), + f"seed {SEED + 1} case {case}", + ) + + def test_changing_any_one_cell_is_always_a_difference(self) -> None: + rng = random.Random(SEED + 2) + for case in range(CASES): + matrix = random_matrix(rng) + changed = [list(r) for r in matrix] + r = rng.randrange(len(changed)) + c = rng.randrange(len(changed[r])) + changed[r][c] = changed[r][c] + "7" + self.assertNotEqual( + bakeoff.table_cells(random_layout(rng, changed)), + bakeoff.table_cells(random_layout(rng, matrix)), + f"seed {SEED + 2} case {case}", + ) + + class CommittedReport(unittest.TestCase): def test_the_committed_report_matches_the_committed_results(self) -> None: results = bakeoff.load_json(bakeoff.RESULTS) @@ -92,6 +181,26 @@ def test_a_report_with_one_changed_cell_is_refused(self) -> None: bakeoff.REPORT = original changed.unlink() + def test_a_report_with_one_changed_leader_is_refused(self) -> None: + results = bakeoff.load_json(bakeoff.RESULTS) + original = bakeoff.REPORT + text = original.read_text(encoding="utf-8") + leaders = bakeoff.block(text, "leaders") + first = bakeoff.list_items(leaders)[0] + name = first.split("`")[1] + other = next(e for e in bakeoff.ENGINES if e != name) + changed = HERE / "real-encoding-bakeoff.changed-for-test.md" + changed.write_text( + text.replace(first, first.replace(name, other), 1), encoding="utf-8" + ) + try: + bakeoff.REPORT = changed + with self.assertRaisesRegex(bakeoff.Invalid, "leaders differ"): + bakeoff.check_report(results) + finally: + bakeoff.REPORT = original + changed.unlink() + if __name__ == "__main__": unittest.main()