Skip to content

3.x.x: re-anchor the capacity-readiness runbook to native telemetry and guard lab/prism doc references - #318

Merged
Anatolie merged 89 commits into
3.x.xfrom
capacity-readiness-reanchor
Sep 15, 2026
Merged

Anatolie merged 89 commits into
3.x.xfrom
capacity-readiness-reanchor

Conversation

@Anatolie

@Anatolie Anatolie commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Closes #303.

docs/prism-capacity-readiness.md still documented lab/prism/metrics.py and lab/prism/process_telemetry.py as the source of its qualification evidence and told the operator to run python3 -m lab.prism.process_telemetry, a module #244 deleted. This decides each affected section separately: it retires the CPython-specific material, re-anchors the runtime-independent parts to the #308 native registry, marks the evidence gate as deferred and names its owner, and adds a guard so the problem cannot come back.

Per-section decisions

Section Decision
Validate Qualification Evidence Deferred. The validator is native (qbit-prism-server capacity-evidence) and the command parses against its CLI. Nothing on this branch produces an artifact it accepts: its strict key set still requires three settings the native server never reads. #288 (P1) re-keys it; #291 produces and consumes the first native artifact.
Heap and Component-Cardinality Telemetry → interpreter/allocator families Retired, with a short past-tense note. allocated_blocks, gc_*, threads, malloc_* and PRISM_MALLOC_TELEMETRY read CPython and glibc mallinfo2 state that has no Rust analogue.
→ component-cardinality families Retired, with a short note. PRISM_COMPONENT_*_KINDS and the component_* gauges counted Python in-process structures. #279 decides which component gauges the native server carries.
→ new "Process telemetry on the native server" Re-anchored to the registry: process_resident_memory_bytes, collector_{available,success,age_seconds}{collector="process"}, runtime_workers, runtime_{lag,poll_lag,progress_age}_seconds, runtime_task_stalled, and the metrics_snapshot_* freshness block. It also lists what the native registry lacks and which issue owns it.
→ What to look at first when RSS climbs Rewritten against native series. It states plainly that the retention-versus-fragmentation split is not measurable on this branch.
Heap Census, Allocator Control, and the Resident-Set Bound (census, malloc_trim, storm/arena experiment) Retired, with past-tense notes. It also warns that the native server handles only SIGTERM/SIGINT, so neither the census signal nor the trim signal does anything useful.
The resident-set bound Re-anchored. The bound itself (2.0× the warm-up peak over 24 h) is unchanged. The deleted rss-bound tool is replaced by one awk pass with the same 0/1/2 exit contract.
Testnet 24 h soak runbook Re-anchored to commands that exist on this branch: docker compose … build prism-coordinator, docker exec … curl …/metrics (the image ships curl; the audit port stays loopback-only), and VmRSS read from /proc/1/status. The census and trim steps are replaced by full /metrics snapshots, and evidence is recorded on #291.

Every metric name the doc presents as live exists in crates/qbit-prism-server/src/metrics/registry.rs. The cadences it quotes (10 s process collector, 30 s COLLECTOR_STALE_AFTER, 100 ms runtime sampler, 2 s poll budget, 60 s lag retention) match metrics.rs, collectors.rs and runtime.rs.

Guard: tests/test_docs_lab_prism_references.py

  • (a) No runnable python[3] -m lab.* or python[3] lab/….py command in any tracked docs/ file may invoke a module that is missing from the tree. There is no allowlist.
  • (b) Every lab/prism/… path and lab.prism.… module named in docs/ must resolve against git ls-files. GitHub URLs pinned to a 40-hex SHA are exempt.
  • The out-of-scope Replace Prism Python runtime with a multi-instance Rust server #244 residue that 3.x.x: docs/prism-capacity-readiness.md is a runbook that cannot run — retire or re-anchor its Python instrumentation #303 leaves for its own change (prism-overload-alerts.md 32, prism-coordinator-refactor/* 1/1/3/1, prism-rust-migration.md 1) is held by a two-way ratchet. A file that gains a dangling reference fails ("repair rather than raise"), and so does a file that improves ("lower the ceiling to N"). A test pins prism-capacity-readiness.md as non-allowlisted.
  • CI picks it up automatically: scripts/run_python_test_shard.py discovers tests/test_*.py, and there is no workflow change.

Verification

  • The branch sits on 3.x.x at aa18472 (3.x.x: Set one 3.0.0 release identity across VERSION and every crate #315), which touches none of these files. Both commits are SSH-signed and authored by Anatolie. The second commit corrects two claims in the first after checking them against the code: in the container the server is PID 1 with no init and handles SIGTERM/SIGINT only, so the kernel drops SIGUSR1 rather than acting on it; and 3.x.x: Native metrics registry with the cutover-minimum series #278's cutover-minimum scope keeps RSS alone from the process block.
  • python3 -m unittest -v tests.test_docs_lab_prism_references passes all 10 tests, run both on the worker host and locally.
  • The full python3 -m unittest discover -s tests -p 'test_*.py' passes on the worker host: 318 tests, 4 Docker-gated skips.
  • python -m compileall -q docker lab tests examples scripts passes, and so does git diff --check.
  • Mutation check: the guard was run with a bare lab/prism/metrics.py mention and a python3 -m lab.prism.process_telemetry rss-bound fence added back into the doc. Both rules failed and named the offending line; the doc was then restored.
  • git grep -nE "lab/prism|lab\.prism" -- docs/prism-capacity-readiness.md returns nothing.
  • The awk bound program was checked against synthetic pass, fail, short and empty CSVs (exit codes 0/1/2/2). The grep/tr pipelines were checked against a synthetic CRLF /metrics response. bash -n passes on every sh fence.

Not verified: nothing was run against a live container. The in-container curl and /proc/1/status reads were checked against the Dockerfile (Debian bookworm-slim, curl installed, exec-form CMD, so the server is PID 1) and against a synthetic response. The soak itself stays out of scope (#291).

Out of scope

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T17:15:16.902655Z 09011ce New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf5f0932ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
…view)

`dead_commands` matched each physical line on its own, so a documented
`python3 -m \` + `lab.prism.deleted` (or `python3 \` + `-m lab.x`,
`python3 -u \` + `-m lab.x`, `python3 \` + `lab/x.py`) slipped past the
guard even though the fence runs the deleted module. Join backslash
continuations into logical shell lines first and report the command at
its first physical line. `dangling_references` and the RATCHET ceilings
are untouched; no wrapped `python ... lab` command exists in docs/ today.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YH4dPMQC6xqq9dreB1puTb
Anatolie added a commit that referenced this pull request Sep 11, 2026
… review)

The Python evaluator this awk pass replaced put a sample taken exactly
warmup seconds after the first one into the warm-up (`t <= warmup_seconds`)
and judged only later samples against the bound (`t > warmup_seconds`).
The awk used a strict `<`, so with the runbook's regular 300 s cadence a
transient peak landing exactly at hour one fell out of the baseline and
could turn a pass into a fail. Use `<=` so the verdict is the Python
tool's, and say so in the prose.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016PioJBmGucLpZZ9HhQgUj1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91b30e8656

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
… review)

The resident-set bound prose said the awk command "refuses a series
shorter than the soak". It does not: `last - t0 < 82800` refuses a series
spanning less than 23 hours from its first sample to its last, exactly as
the retired Python evaluator's RSS_BOUND_DEFAULT_MIN_SPAN_SECONDS did
(23 * 3600, measured from the first sample after re-basing). The
threshold and the expression are unchanged; a 23 h floor is parity with
the tool this runbook qualified under, and 86,400 s from t0 would reject
an honest 24 h soak whose last 5-minute sample lands just short.

The one-hour slack is the reason the Python source recorded on the
constant ("a 24 h soak with an hour of tolerance for a late first
sample", #234); the prose now says so and keeps step 2's 24 h run.

Verified with the unchanged awk program on synthetic 300 s-cadence
series: 82,800 s exits 0, 82,500 s exits 2.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_013yFEcAtVPzfzMiwYmFskLD
Anatolie added a commit that referenced this pull request Sep 11, 2026
…review)

The command regexes accepted only single-letter switches between the
interpreter and `-m` or a script path, so `python3 -OO -m lab.prism.deleted`
or `python3 -X dev -m lab.prism.deleted` ran deleted code while passing
contract (a). Share one interpreter-plus-options sub-pattern that follows
`python3 --help`: clustered flag letters, `-W`/`-X` with an attached or
following argument, and `--check-hash-based-pycs <mode>`. `-c cmd` stays
excluded because it runs its argument and ends the option list; CPython
rejects the `=` spelling of the long option, so none is accepted. Also scan
version-suffixed interpreters (`python3.12`), as the CI images name them.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FcDKnhKaUD45rfBYeYTGH4

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 220ed030b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_docs_lab_prism_references.py Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
…review)

Step 1 of the testnet soak runbook built the coordinator image through
Compose with the deployment's env files, then inspected
`${PRISM_COORDINATOR_IMAGE:-qbit-lab-prism-coordinator:local}` as a
standalone shell expansion. An operator who sets
`PRISM_COORDINATOR_IMAGE` only in an env file, without exporting it,
would build the configured image and inspect the default one instead.

Substitute the env files once, in a `compose` function, and let the same
invocation build the image and resolve its name through
`config --format json`, reading the `prism-coordinator` service record
with `python3`. `config --images prism-coordinator` is not used because
it prints the images of the services the coordinator depends on as well
(`postgres:16-alpine` and the qbitd image), one per line and in varying
order, so `docker image inspect` would receive one multi-line argument
and fail; `docker compose config` has no `--no-deps`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JWTB41CrR7dJ353fGub6HL

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fa1f38a0e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread docs/prism-capacity-readiness.md Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
…318 review)

A ratcheted doc could swap one dangling `lab/prism/...` mention for a
runnable `python3 -m 'lab.prism.deleted'` or `python3 ./lab/prism/deleted.py`
command: rule (b) still counted the path, so the ceiling held, and rule (a)
required an unquoted module or `lab/` straight after whitespace, so it saw no
command. Both command rules now share one `quoted` sub-pattern that accepts a
target in matching single or double quotes, the script rule accepts `./`
prefixes, and the reported missing path is the normalised one.

`-m` may also close a flag cluster and take its module attached. On CPython
3.12 `-mjson.tool`, `-Im json.tool`, `-OOm json.tool`, `-Imjson.tool` and
`-m'json.tool'` all run the module, so those spellings are matched; `-Wm`
and `-Xm` hand `m` to `-W`/`-X` and stay unmatched, as does `-c`. A
mismatched quote is a shell syntax error, runs nothing and matches nothing;
the prose rule still sees the reference.

The module docstring now states the contract's limit: rule (a) is a lexical
check of direct python invocations and does not follow `cd`, `PYTHONPATH`,
aliases or shell variables.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YL7EVncHtFRE74z559dGFf

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13f9e315bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
The `awk` port of the resident-set bound skipped every row with fewer
than two fields under the same rule that skipped `#` comments, so a
sample lost during an RSS excursion (a truncated line in the CSV)
disappeared silently and a valid late sample could still pass the soak.
The deleted `read_rss_samples` raised on any non-blank, non-comment line
that was not `seconds,rss_bytes`, and the `rss-bound` CLI turned that
into exit 2. A non-numeric RSS field was worse than skipped: `abc > n`
compared as strings and reported a breach.

Skip only comment and blank lines, require a numeric first and second
field on every other row (extra trailing fields stay tolerated, as they
were in the Python tool) and report the offending row as unusable input
with exit 2. `exit` inside a main rule still runs `END` in every awk,
so the failure is recorded in a variable that `END` checks before any
verdict logic; verified on the macOS awk (20200816). `-1` samples are
still ignored, after validation.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
The deleted `evaluate_rss_bound` sorted the series by time before it
re-based on the first sample; the `awk` port took the origin from the
first physical row. A nonmonotonic file, such as two partial soak logs
concatenated with the later one first, put a late sample at the origin,
so the warm-up window swallowed every earlier sample (including a
post-warm-up excursion), the baseline rose to the excursion and the
verdict flipped or the span check refused the file.

Sort the file numerically on the first field with `sort -t, -k1,1n`
before the `awk` pass, so the origin is the earliest sample as it was in
the Python tool. Comment and blank lines sort as zero and are skipped
wherever they land, a malformed row is still caught after sorting, and
the pipeline exits with awk's status. Verified with the macOS sort
(2.3-Apple) and awk (20200816) against the deleted evaluator: a
breaching series with its hour-5 sample moved before the hour-0 rows now
fails as the Python tool failed it, where the previous command refused a
24 h file for its span and passed a 28 h one.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
#318 review)

Item 3 of "What to look at first when RSS climbs" names
`qbit_prism_runtime_task_stalled{task}`,
`qbit_prism_runtime_poll_lag_seconds{task}` and
`qbit_prism_database_pool_acquire_seconds` as the evidence that a climb is a
blocked worker holding buffers rather than a leak. The five-minute capture
loop kept only the stall gauge, so the poll lag and pool wait at a breach
could not be read back: the full snapshots are taken at hour 1, hour 24 and
the breach itself, and cannot recover what those series showed at an earlier
sample.

Add both families to the `grep -E` filter. The poll-lag gauge renders with
its `task` label and matches the existing `[ {]` anchor as it is. The pool
histogram never renders under its bare family name: the registry emits
`..._bucket{result=...,le=...}`, `..._sum{result=...}` and
`..._count{result=...}`, as the observability tests assert, so the pattern
names those three suffixes explicitly and keeps the anchor after them. The
sentence after the loop now says the log carries the reading order's
runtime and pool series, so a breach is read at its own sample rather than
the nearest hourly snapshot.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
…review)

A ratcheted doc could swap one dangling `lab/prism/...` mention for a
runnable `"python3" -m lab.prism.deleted` command: the shell strips the
matching quotes and runs Python, rule (b) still counted the module so the
ceiling held, and rule (a) required whitespace straight after a bare
interpreter name, so it saw no command. The interpreter now goes through
the same `quoted` sub-pattern as the target, bare or in matching single or
double quotes, with the quote in its own named group because `re` rejects
one group name used twice in a pattern.

The word boundary before `python` is kept, so `/usr/bin/python3` and
`env python3` still match. Inside `sh -c "python3 -m lab.x"` no quote
closes right after the name, so the interpreter quote backtracks to empty
and the inner command is read as before; a mismatched quote around the
name is a shell syntax error, runs nothing and matches nothing, and the
prose rule still sees the reference. No ratchet ceiling changed: the
tracked docs contain no such command today.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
…commit (#318 CI)

`docs/prism-deleted-test-map.md` landed on 3.x.x with #322 after this
branch's merge-base, and it names three `lab/prism/*.py` modules that #244
removed: `candidate_window.py`, `bundle_compiler.py` and
`endpoint_registry.py`. The reference guard this branch adds scans every
tracked doc on the merge ref, so CI's "Python unit tests (shard 1)" failed
on those three lines while the same test passed on the branch alone.

The guard's contract offers two ways to name retired code: describe it in
words or link a commit-pinned GitHub URL, which is stable history and
exempt. The three mentions are now links to the files at `700fae0`, the
last commit before #244 deleted them, with the module basename as the link
text so the visible path no longer claims to exist on the branch. The
table's wording is otherwise unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
… CI)

`lab/prism/candidate_window.py` was removed before #244, so the link 4d6d0c8
added at `700fae0` pointed at a commit without the file. The other two
modules did exist there; this one now links to `^`, the last
commit before its own deletion. Verified with `git cat-file -e` on the
pinned tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
…CI)

bd35536 rewrote the `candidate_window.py` link with a malformed revision
(`blob/^/`), which the reference guard no longer recognised as a
commit-pinned URL. The module never existed on the 3.x.x line; it was
added on the 2.x line by the v2.0.0 consolidation (#246) and is present at
v2.0.2, `504846c`, the same pinned commit the guard's own tests use as
their example. The link now points there, checked with `git cat-file -e`
against that tree before committing. The guard passes on the merged tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2df27eb6a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
The soak pre-check matched any x-prism-metrics-state value, so a stale or
unavailable body whose cached process gauge still read 1 printed two lines,
grep exited 0, and the prose told the operator the RSS series was
trustworthy. Every gauge in the body is a scrape-time render of cached
observations, and the header is what says whether that render is current.

Replace the grep with an awk verdict in the style of the RSS bound check:
it sets a flag on the exact `x-prism-metrics-state: fresh` line and on the
process collector gauge at 1, prints `ready` and exits 0 only when both are
present, and otherwise names the failed condition and exits 1. The sentence
after it now says both lines are required, that a stale or unavailable body
can still carry a cached gauge at 1, and that the run must not start until
the check passes. The step-3 capture loop is unchanged; it records the state
header whatever its value on purpose.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
…nd guard (#318 review)

The doc-command guard accepted a `python -m lab.pkg` command when only
`lab/pkg/__init__.py` was tracked, because it reused the prose contract's
candidate list and took its first two entries. CPython does not run such a
package: on 3.14, `python3 -m lab.pkg` against an `__init__.py`-only package,
or against a bare directory, prints "No module named lab.pkg.__main__;
'lab.pkg' is a package and cannot be directly executed" and exits 1. It runs
the package only when `lab/pkg/__main__.py` exists, and it runs
`lab/auxpow/vardiff.py` even though `lab/auxpow` has no `__init__.py`.

Commands now resolve through a separate `runnable_candidates` helper that
admits only `<relative>.py` or `<relative>/__main__.py`; the prose contract
keeps `module_candidates`, so a `lab.prism.pkg` mention of an
`__init__.py`-only package is still not dangling. A dead `-m` command reports
both paths joined by `or`, so a reader is not told to create `lab/pkg.py`
beside a tracked package that merely lacks `__main__.py`. The docstring
states the new rule, the passing fixtures gain `lab/pkg/__main__.py`, and
tests cover the four package shapes and the prose exemption.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 609c26665d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_docs_lab_prism_references.py Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
…it cites (#318 CI)

`docs/prism-b8-miner-parity.md` landed on 3.x.x with #313 after this
branch's last merge of the base, and its reference line names
`lab/prism/tip_refresh.py` and `lab/prism/job_delivery.py`, which #244
removed. The reference guard this branch adds scans every tracked doc on
the merge ref, so CI's "Python unit tests (shard 1)" failed on that line
while the test passed on the branch alone.

The line already anchors itself to a 2.x.x commit; the two module mentions
are now links to those files at `95ffe06`, checked with `git cat-file -e`
against that tree, with the basenames as link text so the visible path no
longer claims to exist on the branch. The guard treats a commit-pinned
GitHub URL as stable history. The sentence is otherwise unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2badeba30e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_docs_lab_prism_references.py Resolved
Comment thread docs/prism-capacity-readiness.md Resolved
Anatolie added a commit that referenced this pull request Sep 11, 2026
…eview)

The doc-command guard read a `-W`, `-X` or `--check-hash-based-pycs`
argument only as a bare non-whitespace word, so `python3
--check-hash-based-pycs 'always' -m lab.prism.deleted` and `python3 -X 'dev
mode' -m lab.prism.deleted` ran and yet were not reported: the quoted mode
broke the `always|default|never` match, and the space inside the quotes
ended the `-X` argument early. The bare word also swallowed an unterminated
quote, so `python3 -X 'dev" -m lab.prism.x`, which bash rejects before
Python starts, was reported as a dead command. On CPython 3.14, `-X 'dev'`,
`-X "dev mode"`, `-X'dev'`, `-X"dev mode"`, `-W 'error'`, `-W"error"`,
`-W 'error'::DeprecationWarning` and `--check-hash-based-pycs "always"` all
run `json.tool` exactly as their bare spellings, because the shell strips
matching quotes, attached or not, before CPython sees them.

An option argument is now a shell word: runs of unquoted characters
alternating with matching-quoted strings, non-empty, ending at whitespace.
The runs and strings alternate rather than nest, so one word has a single
parse and a long argument cannot backtrack exponentially. `-W` and `-X`
take that word attached or after whitespace; `--check-hash-based-pycs`
reuses `quoted()` around its three modes with its own group name, since the
command patterns already use that group for the interpreter and the target.
An unquoted run holds no quote character, so a mismatched quote matches no
option and the line is left to the prose contract. Tests cover each quoted
form against missing and existing targets, a wrapped form, and the
mismatched forms.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
…review)

`PYTHON_FLAG` listed every single-letter option but `-R`, so `python3 -R -m
lab.prism.deleted` ran and was not reported. On CPython 3.14 the option
lines of `python3 --help` are `-b -B -c -d -E -h -i -I -m -O -OO -P -q -R
-s -S -u -v -V -W -x -X`, with `-h : print this help message and exit (also
-? or --help)`; `-R` was the only letter missing, and `python3 -R -m
json.tool --help` and `python3 -Rm json.tool --help` both run the module,
so `-Rm` joins the adjacent `-m` spellings. Separately, the standard `--`
terminator before a script path evaded `SCRIPT_COMMAND`: `python3 --
s.py`, `python3 -O -- s.py` and `python3 -OO -- ./s.py` run the script.

`R` is in the flag class and `SCRIPT_COMMAND` accepts an optional `--`
followed by whitespace before the script target. `MODULE_COMMAND` does not:
after `--` CPython takes `-m` as a script name, and `python3 -- -m
json.tool` fails with "can't open file '.../-m'", so that line runs nothing
and stays with the prose contract, which a test asserts. Tests cover `-R`
and `-ER -X dev` in the option table, `-Rm`, and `--` before a script with
missing and existing targets, in a wrapped form, and with `./`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 11, 2026
`compose.yaml` gives `prism-coordinator` `restart: on-failure`, so a
coordinator that exits mid-soak is started again by Compose inside the same
container, and the step-3 capture loop, which only read `/proc/1/status`,
would go on sampling the new PID 1 without a word. The CSV would then splice
several short lifetimes into one 23 h span, each restart's low RSS and reset
share counters would hide the growth, and the bound, which assumes one
process, could pass.

The loop now reads `docker inspect` for the container's status, `StartedAt`
and `RestartCount` once before it starts and again before every sample,
appends each reading to `soak-process.log`, and on any change prints both
readings with the time to stderr and stops. The container is the same across
a Compose restart, so `$c` stays the handle and `docker inspect` on it is the
right probe. The prose says the bound is evidence about one process, why the
restart policy would otherwise hide a restart, that the log lets a later
reader show the run was one process, and that a change invalidates the run:
keep the message and the log, attach `docker logs "$c"`, and start over from
step 2. Step 6 gets one sentence saying such a run is not judged. Verified
against a throwaway container with the same restart policy, where two policy
restarts moved `StartedAt` and took `RestartCount` from 0 to 2, and with a
stub `docker` that changes `StartedAt` on the second iteration.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe973c5ada

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/prism-capacity-readiness.md Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d7a05ff25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_docs_lab_prism_references.py Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved
A Markdown blockquote needs no space after its marker, so `>lab/prism/x`
and the nested `>>lab/prism/x` name the repository root exactly as
`> lab/prism/x` does. Neither root prefix listed `>` among the token
openers, so a dangling path or module quoted that way went unreported.
Openers still count only at the start of a line or after whitespace, so
`my>lab/prism` remains another path.
GNU env prints the environment NUL-terminated for `-0`/`--null` and
refuses any command after it ("cannot specify --null (-0) with
command", exit 125), whether the flag stands alone, closes a cluster of
argument-free flags (`-i0`, `-v0`) or arrives through `-S`. The env
option loop skipped it as an ordinary flag and reported the Python
module after it as runnable, so a legitimate doc example failed the
guard. It is now a terminating mode like `--help`; `-u0` still unsets
the variable `0` and runs the command.
`nohup FOO=x python3 -m lab.x` runs nothing: nohup's syntax is `nohup
COMMAND [ARG]...`, so it execs a program named `FOO=x` and exits 127,
as bash's `command` and `exec` and `docker exec CONTAINER COMMAND` do.
The launcher loop skipped every `VAR=value` word wherever it stood, so
Python after such a dead word was reported as runnable. Only env and
sudo take assignments between their options and the command, and sudo
stops taking them at `--`, so the skip now lives with them. A leading
assignment is shell syntax and is read as before.
`sudo -nu nobody python3 -m lab.x` runs Python as nobody: sudo's usage
is `[-u user] ... [command [arg ...]]`, and getopt lets `-u` close a
cluster and take the next word. The wrapper loop knew only the lone
`-u` spelling, skipped the whole `-nu` token, took `nobody` as the
executable and missed the deleted module. Short clusters are now read
letter by letter for every wrapper: the first argument-taking letter
takes the rest of the cluster (`-unobody`, and `-pu nobody` gives p
the prompt "u") or, at the end of the cluster, the next word. env's
`-u`/`-C`, exec's `-a` and docker exec's `-e`/`-u`/`-w` gain the same
reading; `-nv` still validates and `-pv` still runs a command.
`bash -D -c 'python3 -m lab.x'` runs nothing: bash documents -D as
implying -n ("no commands will be executed"), and --dump-strings and
--dump-po-strings behave the same. The command-string reader left
noexec false for them, so a dead command inside the string was
reported as runnable. The dump modes now end the command the way -n
does, except that no later +n or +o noexec restores execution and the
sign of -D/+D is ignored, as bash ignores it. dash rejects the letter
outright, and the reading is scoped to bash and sh as the
option-argument flags already are.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 897dc5c9fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_docs_lab_prism_references.py Resolved
Markdown renders `_lab/prism/x_`, `__lab/prism/x__` and `` _`lab/prism/x`_ ``
with the underscores gone and the path emphasized, so a doc spelled that
way shows a repository-root reference. Both reference patterns anchored
the root with `\b`, and an underscore is a word character, so the
boundary never fell before `lab` and a deleted path or module emphasized
this way went unreported.

The underscore is not one more opener: `_lab/prism/x` with no closing
run renders literally and names a path in `_lab/`, as `my_lab/prism`
names another path, and inside a code span nothing is emphasis. The root
now starts wherever no letter or digit precedes it, the root prefixes
capture an underscore run among the openers, and the token is read only
when a later run on the line closes that emphasis, paired as CommonMark
pairs them: runs inside a word are text, a closer takes the nearest
opener, two delimiters go when both runs have two or more and one
otherwise, and a run an odd number of backticks after the opener sits in
a code span. Emphasis closed on a later line, the rule of three, `*`
delimiters and link boundaries are not followed; the docstring records
the line drawn. The closing run is removed from a bare token by the
delimiters the pair spends rather than as trailing punctuation, so a
file named `tool_` still resolves and `_lab/prism/tool__` names it.
`sudo -nh host python3 -m lab.x` runs nothing: sudo's -h takes an
optional argument, so it reads a host only attached (`-hhost`,
`-nhhost`) or, as the whole word `-h`, from the next word when that is
neither an option nor an assignment, and is the help mode otherwise.
sudo 1.9.15p5 printed its usage for `sudo -nh host id`, `sudo -Hh host
id`, `sudo -nh`, `sudo -h -u nobody id`, `sudo -h -- id` and `sudo -h
FOO=x id`, while `sudo -h host id`, `sudo -hhost id` and `sudo -nhhost
id` went on to the command. The cluster reader gave `-h` the next word
whenever it closed a cluster, as it does for `-u`, so the Python after
`-nh host` was reported as runnable and the Python after `-h --` too.
A cluster ending in `h` with nothing attached, and a lone `-h` with
nothing, an option or an assignment after it, now end the command as
the credential modes do; an attached host still runs the word after it.
`command -pv python3 lab/x.py` runs nothing: bash's command builtin
takes `-v` and `-V` in a cluster with `-p` or each other, and prints
the lookup instead of running the word after it. bash 5.2.21 printed
`echo` and ran nothing for `command -pv echo hi`, `command -vp echo hi`
and `command -vv echo hi`, described the builtin for `command -pV echo
hi`, and ran `echo hi` for `command -p echo hi` and `command -pp echo
hi`. The wrapper loop knew only the lone `-v` and `-V` words and read a
cluster as `-p`, so the Python after `-pv` was reported as runnable.
Any cluster of `p`, `v` and `V` holding a lookup letter now ends the
command as the lone flags do.
`sudo -nV python3 -m lab.x` runs nothing: -V prints sudo's version and
exits, and clustered with other flags it makes sudo print its usage
instead. sudo 1.9.15p5 ran nothing for `sudo -nV id`, `sudo -Vn id`,
`sudo -HV id` and `sudo -Vu nobody id`, as for `sudo -V id`, while
`sudo -uV nobody id` read the user `V`. The wrapper loop knew only the
lone `-V` word, so a cluster carrying the letter was skipped as flags
and the Python after it was reported as runnable. The letter now joins
the edit and credential modes, which are already read in a cluster
behind argument-free flags.
`ksh -D -c 'python3 -m lab.x'` runs nothing: ksh has the dump mode bash
took the letter from. ksh93u+m 1.0.8 printed only the strings for `ksh
-D -c 'echo hi'`, `ksh -Dc 'echo hi'`, `ksh +D -c 'echo hi'` and `ksh
--dump-strings -c 'echo hi'`, and mksh R59 rejects the letter and runs
nothing, so a ksh of either kind runs nothing for the spelling. The
command-string reader scoped the mode to bash and sh, in the belief
that ksh kept another meaning for the letter, so the dead command
inside the string was reported as runnable. ksh differs from bash in
one respect: a `+n` or `+o noexec` standing as the last such setting
restores execution, before or after the `-D` (`ksh -D +n -c 'echo hi'`
and `ksh +n -D -c 'echo hi'` ran, `ksh -D +n -n -c 'echo hi'` did not).
The dump is now read for ksh with that restoration, and stays sticky
for bash. zsh 5.9 keeps its own meaning for the letter and ran `zsh -D
-c 'echo hi'`, so its strings are read as before.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18ce2d14a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_docs_lab_prism_references.py Resolved
Comment thread tests/test_docs_lab_prism_references.py Resolved
`builtin command python3 -m lab.example.deleted` reaches Python, but the
executable-word scan stopped at `builtin`, which it did not know, so a
deleted target behind it went unreported; `builtin python3 -m ...` runs
nothing, which the scan got right only by accident.

`builtin [shell-builtin [arg ...]]` runs its argument as a shell builtin
and nothing else. bash 5.2.21 ran `echo hi` for `builtin command echo hi`,
`builtin exec echo hi`, `builtin builtin command echo hi`, `builtin --
command echo hi`, `builtin 'command' echo hi`, `command builtin command
echo hi`, `command -p builtin command echo hi` and `FOO=x builtin command
echo hi`, and printed `echo` for `builtin command -v echo hi`. It answered
`builtin python3 -c 1`, `builtin env echo hi`, `builtin sudo echo hi`,
`builtin nohup echo hi`, `builtin docker exec c echo hi`, `builtin bash -c
'echo hi'`, `builtin /usr/bin/env echo hi`, `builtin ./command echo hi`,
`builtin FOO=x command echo hi` and `builtin -- -- command echo hi` with
"not a shell builtin", ran nothing for `builtin` and `builtin --` alone,
rejected `-x`, `-p`, `-pv`, `--foo` and `--version` as invalid options
and printed its help for `--help`; the next command on the line ran after
every failure. dash 0.5.12 has no `builtin` and answers "not found".

The scan now takes `builtin` as a launcher whose one option word is a
single `--` and whose argument, quotes removed, must be exactly `command`,
`exec` or `builtin` to continue; any other argument, or none, ends the
command with nothing run, so `builtin python3 ...`, `builtin env python3
...` and `builtin sh -c '...'` report nothing while the command after them
on the line is still read. A `builtin` after env, sudo, nohup, exec or
docker exec is looked up as a program and not found, as `command` and
`exec` already are there; that shared gap is unchanged.

test_builtin_runs_only_the_shell_builtins_the_check_reads covers both
directions with the wrapped, quoted and prefixed spellings.
`bash -c 'set -n; python3 -m lab.example.deleted'` (and `set -o noexec`)
runs `set` and then reads the Python command without executing it, while
the nested scan of the string reported the target as runnable. Only the
invocation-level `bash -n -c` was read before.

bash 5.2.21 and dash 0.5.12 printed nothing for `set -n; echo NO`, `set -o
noexec; echo NO`, `set -n; set +n; echo NO` (the `set +n` is itself never
executed), `set -en; echo NO`, `set -no noexec; echo NO`, `set -on noexec;
echo NO`, `set -n x; echo NO`, `set '-n'; echo NO`, `FOO=x set -n; echo
NO`, `command set -n; echo NO`, `{ set -n; }; echo NO`, `if set -n; then
:; fi; echo NO`, `set -n` on a line of its own before `echo NO`, and bash
for `builtin set -n; echo NO`, `time set -n; echo NO`, `! set -n; echo NO`
and `set -o -n; echo NO`. The options of one `set` apply in order: both
ran `echo YES` for `set -n +n; echo YES`, `set -o noexec +o noexec; echo
YES`, `set -- -n; echo YES`, `set - -n; echo YES` and `set x -n; echo
YES`. bash rejects the whole command at a letter outside its usage line
(`set -nz; echo RAN` and `set -n -z; echo RAN` ran); dash exits there
instead, and bash's reading is followed. After env or nohup, `set` is a
program GNU coreutils 9.4 did not find and the shell ran on (`env set -n;
echo YES`). A subshell keeps its state to itself: `(set -n); echo YES` and
`x=$(set -n); echo YES` ran in both shells, and `sh -c 'set -n; echo NO';
echo YES` ran in the outer shell.

The nested scan now carries one state per literal shell string through
its commands and lines, one entry per open parenthesis: a `set` that is
the shell's own (not behind env, sudo, nohup, exec or docker exec) and
leaves `-n`/`-o noexec` on after its options are read in order turns the
rest of the string, at that parenthesis depth or deeper, into text the
shell reads without executing, nested command strings included. The state
starts fresh for every string and never reaches the document: a document
line is read with none, so its inline code spans stay separate commands.

Not followed, and documented in `sets_noexec`: a `set -n` in a pipeline
element, a background job or a backtick substitution (each a subshell),
behind a condition or `case` arm, or in a function body (which bash and
dash apply to the calling shell when the function is called) is read as
the shell's own where it stands; an option name the shell rejects and a
`\set` escape are outside the check.

test_noexec_set_inside_a_shell_string_ends_what_runs and
test_noexec_set_the_shell_undoes_rejects_or_never_reaches_leaves_the_string_running
cover the spellings above in both directions across the five shells.
The live suite is flaky in the PRISM PostgreSQL CI job. On the
capacity-readiness-reanchor branch it failed six times out of 48 runs,
always in fixture setup or in a wait the same load slows, and every rerun
of the same commit passed:

  head 18ce2d1 (shard 1, attempt 1): timed out waiting for PRISM HTTP
    readiness, real_cpfp_abandoned_child_repair_retains_unremovable_spent_lock,
    33 s after "running 9 tests"; attempt 2 passed unchanged
  c5de2fb, e48ece4, 43609d1: the same readiness timeout in
    real_cpfp_recovers_reserved_funding_after_owner_crash and, twice,
    observability_grace_counter_moves_only_after_real_durable_credit
  3f59c2c, 4c1c2f2: timed out waiting for pool block reconnection in
    real_two_server_mining_failover_audit_and_reorg

Every commit on the branch touches tests/test_docs_lab_prism_references.py
only, and the previous head 897dc5c passed the identical job.

The job runs on blacksmith-2vcpu-ubuntu-2404 and the shard script invokes
plain `cargo test`, so libtest runs two tests at once. Each test opens a
fixture that starts a regtest qbitd and two PRISM servers, and a server
binds its listeners only after coordinator startup: the schema migrations,
which the second server of a fixture waits for under the migrations table
lock, and the node handshake. With two fixtures opening together, two
nodes, four servers, their migrations and the sibling's miners and node
restarts share two cores and one PostgreSQL, and a server that answers
/healthz in a few seconds alone missed the 30-second setup budget. The
same load stretched the failover test's 20-second reconnection wait.

The fixture now holds a static tokio mutex for its whole life, taken right
after the gate and released after cleanup has stopped every process, the
shape the ledger suites (candidate_window_switch, compact_issued_repair,
ledger_wait_metrics) already use. No budget changes: the readiness wait is
still 30 seconds and no product wait, assertion or gate is touched. On a
readiness timeout the fixture now names the server and prints the server
log tails, so a recurrence shows whether the process was still starting or
had exited.

Runtime: the suite took 83 s and 184 s in the two passing runs with two
threads; summing the per-test durations of the same runs gives about 160 s
and 270 s serialised, so shard 1 grows by one to two minutes, against a
30-minute job timeout it reached in about 7 minutes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant