◐ Shell
clean mode source ↗

Add Pycharm's .idea directory to gitignore by rajathagasthya · Pull Request #6 · python/cpython

native-api pushed a commit to native-api/cpython that referenced this pull request

Jun 5, 2018

paulmon added a commit to paulmon/cpython that referenced this pull request

Jan 10, 2019
fix _decimal.pyd build for windows arm32

emmatyping referenced this pull request in emmatyping/cpython

Jan 31, 2020

nanjekyejoannah added a commit to nanjekyejoannah/cpython that referenced this pull request

Apr 14, 2022
6: Add warnings for the print statement r=ltratt a=nanjekyejoannah

A Py3k syntax warning has been added for the print statement.

This PR should replace python#2 

Co-authored-by: Joannah Nanjekye <jnanjekye@python.org>

oraluben referenced this pull request in oraluben/cpython

Jun 25, 2023
We can perform type_set if we can guarantee dst is the same type as src.

barneygale added a commit to barneygale/cpython that referenced this pull request

Oct 29, 2024

This was referenced

Feb 11, 2025

@Qanux Qanux mentioned this pull request

Feb 11, 2026

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 22, 2026
…ation)

Push 39's e808676 + 0a5f096 added BINARY_MATCH on both arches.
The grep is bare-hash: 'grep "$COMMIT_HASH" "$LONG_VERSION"'. That
matches both clean ':<hash>,' AND '-dirty:<hash>' suffix — the
exact contamination class that bit catch python#4 (binary built from a
dirty working tree masquerades as a clean build).

Pre-push-39, 'cp || true' accidentally protected against this by
falling back to a stale-clean python_gate when local build was
dirty. Push 39 removed the fallback. Without -dirty rejection,
the next contaminated build IS the binary the gate tests, while
BINARY_MATCH still passes.

Fix: tighten the check to reject any version string containing
'-dirty'. Mirror on ARM64 path (mirrors 0a5f096 symmetry).
Output now distinguishes BINARY_MISMATCH (wrong hash) from
BINARY_DIRTY (right hash, dirty build).

Adds catches python#5 (push-39 in-flight commit race) and python#6 (this
fix) to docs/wiring_catches.md.

Per supervisor 2026-04-22 01:08:18Z + theologian 01:08:00Z
(defense-in-depth: when a single incident exposes N adjacent
gaps, fixing 1 leaves N-1 unprotected).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 22, 2026
Push 44 W3 (R4 oracle resurrection) — bundled commit covering Steps 1-4
of theologian's 5-step plan. Original supervisor 02:46:34Z sequence
called for 3 separate commits (Step 3.5 / Step 1+4 / Step 5). Bundled
here due to git staging accident (generalist 02:50:38Z self-report);
supervisor 02:51:14Z accepted (option a) since content is correct +
reviewable as one batch and (b) reset would be destructive.

Component breakdown:
  Step 1 (testkeeper): scripts/rc_diff_oracle.sh — driver
  Step 2 (generalist, 02:34Z): cc4a18e source extraction →
    docs/oracle_scratch/{rc_oracle.cpp,rc_oracle.h,analysis_at_d81e5806c3.h}
  Step 3 (generalist, 02:34Z + testkeeper operator<< addition 02:43Z):
    docs/oracle_scratch/_rc_oracle_adapter.{h,cpp} — LivenessAnalysis
    adapter wrapping HirLivenessState C API
  Step 3.5 (generalist, 02:48Z): Python/jit/compiler.cpp:128 —
    #ifdef RC_ORACLE dispatcher
  Step 4 (testkeeper): docs/oracle_scratch/CMakeLists.txt + rc_oracle_entry.cpp
    + scripts/build_oracle.sh

Step 5 (generalist, synthetic refcount-bug injection test + nm
production check) follows in a separate push 44 commit.

================================================================
PRIOR DECISIONS (BRIDGE SPEC TEMPLATE)
================================================================

D-1776823892 (W3 hybrid design accepted, supervisor 02:37:10Z):
  Build-time #ifdef + env-var dispatch chosen over (a) two-binary linker
  tricks, (3) standalone driver, (4) full d81e580 binary rebuild.

D-1776820568 (W3 MEDIUM priority, oracle-pinned to push 35 HEAD d81e580):
  W3 acceptance, theologian 23:34Z. Pinned via cc4a18e source snapshot,
  not git-checkout in build step (clearer pin semantics).

D-1776553345 (R4 kept Run() entry with C wiring, prior session):
  Original RC_DIFF dispatch was IN-PASS (inside RefcountInsertion::Run,
  RC_USE_CPP env var). NOT in compiler.cpp. cabb100 was the original
  dispatcher commit. W3 dispatch is in compiler.cpp because the
  cc4a18e C++ class no longer exists at HEAD (R4 deleted it) —
  in-pass dispatch isn't structurally available.

scribe 02:40:24Z (clarification):
  cc4a18e RefcountInsertion::Run() used C++ versions of pre/post
  passes (PhiElimination, bindGuards, splitCriticalEdges,
  removeTrampolineBlocks, optimizeLongDecrefRuns). HEAD's C version
  uses C versions. See INVARIANT python#6 below.

================================================================
INVARIANTS PRESERVED
================================================================

1. PRODUCTION BINARY UNAFFECTED — RC_ORACLE undefined in default build,
   so the entire dispatcher block (extern decl + getenv check + branch)
   is absent. Falsifier: `nm python | grep rc_oracle` = empty. VERIFIED
   PRE-COMMIT: 0 matches in cmake/make-built ./python at HEAD f0891d7.

2. ZERO RUNTIME COST IN PRODUCTION — no getenv call, no branch, no
   function pointer load. The compiler removes the entire #ifdef block.

3. SYMBOL NAME CONTRACT — extern "C" int rc_oracle_run(void *func)
   matches libphoenix_rc_oracle.a entry-point declaration (testkeeper
   02:39:45Z). C linkage avoids C++ name mangling.

4. SAFE FALLBACK — when RC_ORACLE_USE_CXX env var is unset OR set to '0',
   the C path runs (runPass(jit::hir::RefcountInsertion{}, ...)).
   Default behaviour of python_rc_cpp matches default behaviour of
   production python.

5. NO CALL-SITE PROLIFERATION — single dispatcher at line 128 (verified:
   only call site of refcount_insertion at HEAD via grep).

6. ORACLE SCOPE (theologian 02:41:54Z, supervisor 02:42:21Z):
   Both branches dispatch the FULL Run() including pre/post passes
   (PhiElimination + bindGuards + splitCriticalEdges + removeTrampolineBlocks
   + optimizeLongDecrefRuns). C path uses C versions; C++ path uses C++
   versions. Diff includes (a) refcount_insertion divergence AND (b) any
   divergence between C and C++ versions of the pre/post utility passes.
   Root-cause analysis must distinguish (a) from (b) using diff content.
   Full extraction (option II) deferred to W9 if conflation noise is
   unacceptable in practice.

ADAPTER (Step 3) BRIDGE SPEC — see _rc_oracle_adapter.h header for full
LITE TEMPLATE (5 invariants: API surface, iteration order, kEmptyRegSet
sentinel, RegisterSet typedef passthrough, oracle pin via source snapshot).

================================================================
FALSIFIER (verified pre-commit)
================================================================

`nm python | grep rc_oracle` returns EMPTY for production python build
(RC_ORACLE undefined). Verified pre-commit: 0 matches.
`nm python_rc_cpp | grep rc_oracle` returns NON-EMPTY (rc_oracle_run
symbol from libphoenix_rc_oracle.a). Will be verified by Step 5 self-test.

If production binary EVER acquires rc_oracle symbols (build system
accident enables RC_ORACLE), the falsifier triggers and Step 5's nm
production check halts the gate.

Synthetic refcount-bug injection (Step 5) is the larger oracle falsifier
— inject a known divergence into the C path, scripts/rc_diff_oracle.sh
must produce non-empty output. If empty under injection, oracle is
non-functional.

================================================================
DIFF SUMMARY
================================================================

11 files changed, 2267 insertions(+):
  Python/jit/compiler.cpp                     | +16 (Step 3.5 dispatcher)
  docs/oracle_scratch/.gitignore              | +3
  docs/oracle_scratch/CMakeLists.txt          | +70 (Step 4)
  docs/oracle_scratch/_rc_oracle_adapter.cpp  | +27 (Step 3)
  docs/oracle_scratch/_rc_oracle_adapter.h    | +132 (Step 3)
  docs/oracle_scratch/analysis_at_d81e5806c3.h| +256 (Step 2 reference)
  docs/oracle_scratch/rc_oracle.cpp           | +1376 (Step 2 cc4a18e snapshot)
  docs/oracle_scratch/rc_oracle.h            | +24 (Step 2 cc4a18e snapshot)
  docs/oracle_scratch/rc_oracle_entry.cpp    | +20 (Step 4 entry point)
  scripts/build_oracle.sh                     | +163 (Step 4 wrapper)
  scripts/rc_diff_oracle.sh                   | +180 (Step 1 driver)

Verification (compile-clean pre-commit):
  cmake --build phoenix_jit: PASS, 0 errors (RC_ORACLE undefined → only
  the #else branch compiles).
  make python: link PASS, no undefined references.
  nm python | grep rc_oracle: 0 matches (FALSIFIER SATISFIED).

Process lesson recorded: in multi-agent commit windows, the COMMITTING
agent must use explicit `git add <specific-files>` + verify staging with
`git status` BEFORE `git commit`. Default-staging captures untracked
files including other agents' work.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 22, 2026
Push 44 W3 follow-up per supervisor 03:07:52Z + theologian 03:07:25Z:
- rc_oracle_self_test.sh: expand from 1 → 4 injection classes (A/B/C/D)
- _rc_oracle_adapter.h: add invariant python#7 (oracle lifespan policy)
  to BRIDGE SPEC TEMPLATE (supersedes W12)

Per supervisor 03:07:52Z W4 vacuous-pass defeat directive:
"single-injection test is the W4 vacuous-pass class".

================================================================
PART 1: 4 INJECTION CLASSES (rc_oracle_self_test.sh)
================================================================

Generalized inject_class helper (sed → rebuild → diff → restore →
rebuild) replaces the hard-coded single-injection block.

Class A — refcount BALANCE under-count:
  Skip FIRST phx_rc_emit_incref via line-comment.
  Failure mode caught: under-count → leak under Py_REF_DEBUG.

Class B — refcount BALANCE over-count:
  Skip FIRST phx_rc_emit_decref via line-comment.
  Failure mode caught: over-count → leak (different mechanism than A).

Class C — refcount SEQUENCE:
  Skip SECOND phx_rc_emit_incref (different call-site than A) via
  line-comment.
  Failure mode caught: HIR position-dependent divergence — same opcode
  family as A but different injection position to test position
  sensitivity.

Class D — TYPE LATTICE:
  Change FIRST HIR_TYPE_OBJECT → HIR_TYPE_NULLPTR via sed.
  Failure mode caught: type-annotation flip — wrong refcount semantics
  for borrowed-vs-owned classification.

Each class:
  1. sed transformation applied
  2. cmp -s verifies source actually changed (catches stale sed pattern)
  3. Rebuild C path
  4. Run scripts/rc_diff_oracle.sh
  5. PASS = non-empty diff (oracle CATCHES the divergence)
     FAIL = empty diff under injection (oracle MISSED → non-functional)
  6. Restore source from backup + rebuild

Default invocation runs all 4 classes sequentially. --class=A|B|C|D
runs single class. trap EXIT ensures restore on script error.

================================================================
PART 2: INVARIANT python#7 (_rc_oracle_adapter.h)
================================================================

Added to BRIDGE SPEC TEMPLATE INVARIANTS PRESERVED section per
theologian + supervisor 03:07:52Z (supersedes earlier W12 framing):

  7. Oracle lifespan: utility decreases as emit methods diverge from
     d81e580 baseline. RETIREMENT TRIGGER: when scripts/
     rc_diff_oracle.sh on CLEAN run produces >30% pre/post divergence
     noise, retire (archive script). ESTIMATED LIFESPAN: 30-50 pushes
     from d81e580 (push 35) → retirement window ~push 65-85.
     Re-evaluate at push 50 (testkeeper clean-diff noise % post).

Also added invariant python#6 inline (oracle scope conflated diff —
already in commit msg of a99db92 but missing from header file).

Falsifier section expanded to enumerate 4 classes (A/B/C/D) with
their distinct failure-mode coverage per Pythia python#58's vacuous-pass
concern.

================================================================
VERIFICATION
================================================================

bash -n scripts/rc_oracle_self_test.sh: SYNTAX OK (260 lines).
diff --cached --stat: 2 files, +142/-48 — only the 2 intended files
(verified explicit-staging discipline per supervisor 02:51:14Z).

Push 44 W3 batch grows to 3 commits:
  a99db92 — W3 Steps 1-4 bundled (scratch lib + dispatcher)
  4f591a1 — W3 Step 5 v1 (single class A)
  THIS COMMIT — W3 Step 5 expansion (4 classes + invariant python#7)
ABBA cap 15 → 18.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Eliminate the C++ wrapper HIRBuilder::emitBeforeWith by folding its
PY_VERSION_HEX/opcode-branch logic into the existing C body
hir_builder_emit_before_with_c. Caller now passes the raw bytecode
opcode and the C body derives enter_id/exit_id/is_async locally.

This is the first Cat-B fold-into-C in the Phase 1 burndown (prior
batches python#2-python#5 were Cat-A clean-delegation deletes). Pattern is reusable
for emitSetupWith python#7 and emitSetupWithCommon (Register* helper).

Authorization: theologian 22:08:49Z + 22:10:41Z (GO Step B atomic post
Lib/test scope verify), supervisor 22:08:58Z + 22:10:51Z. Lib/test
scope verified clean (0 references).

Numstat:
  Python/jit/hir/builder.cpp     +3 -30  (delete wrapper + extern,
                                          add file-scope extern,
                                          rewrite caller)
  Python/jit/hir/builder.h       +0 -3   (delete decl)
  Python/jit/hir/builder_emit_c.c +33 -10 (fold opcode-branch logic)
NET: -7 lines, substantive (algorithmic fold, not delegation-marginal).

W44 gate: PASS (2 markers audited, 0 production callers).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Eliminate the C++ wrapper HIRBuilder::emitSetupWith by folding its
PY_VERSION_HEX conditional + handler_off compute into the existing C
body hir_builder_emit_setup_with_c. Caller now passes the raw bytecode
oparg + next_instr_off; the C body derives enter_id/exit_id/is_async
(version-conditional) and computes
handler_off = next_instr_off + oparg * sizeof(_Py_CODEUNIT) locally.

Second Cat-B fold-into-C in Phase 1 burndown (after python#6 emitBeforeWith).
Pattern remaining for emitSetupWithCommon (Register* helper sibling,
Phase 1 python#8).

Authorization: theologian 22:30:11Z + supervisor 22:30:26Z. Lib/test
scope verified clean (0 references) per medic 21:16:05Z gate.

Numstat:
  Python/jit/hir/builder.cpp     +5 -28  (delete wrapper + extern,
                                          add file-scope extern,
                                          rewrite caller)
  Python/jit/hir/builder.h       +0 -3   (delete decl)
  Python/jit/hir/builder_emit_c.c +28 -8 (fold version+compute logic)
NET: -6 lines, substantive (algorithmic fold-into-C).

W44 gate: PASS (2 markers, 0 production callers).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Implements scripts/w45_bridge_drift_falsifier.sh per
docs/w45-bridge-signature-drift-falsifier.md.

Mutate-Build-Verify-Restore loop:
- Mutates a bridge signature (extern "C" decl in builder.cpp + function
  definition in builder_emit_c.c, in lockstep) by appending a sentinel
  param 'int phx_w45_drift'.
- Verifies the build fails at the C++ dispatch-switch call site (which
  has the OLD arity).
- Restores both files; clean rebuild verifies tree state.

Catches the structural drift class identified by pythia python#90/python#91:
void* args at the bridge crossing erase the type-safety C++ overload
resolution would normally provide. 252+ dispatch sites in builder.cpp
post Phase 1 burndown — manual audit unscalable.

Initial 6 fixtures (per spec §2.2 + §2.6 retro):
- hir_builder_emit_before_with_c (Phase 1 python#6 retro)
- hir_builder_emit_setup_with_c (Phase 1 python#7 retro)
- hir_builder_emit_format_simple_c (Phase 1 python#2 sample)
- hir_builder_emit_copy_free_vars_c (Phase 1 python#4 sample)
- hir_builder_emit_get_yield_from_iter_c (Phase 1 python#4 sample)
- hir_builder_emit_primitive_load_const_c (Phase 1 python#5 sample)

Modes:
- --dry-run: stage mutations, no build (any agent — bypass build lock)
- --strict: exit 1 on FAIL (for gate integration)
- --verbose: show build stderr

Uses perl -0777 multi-line slurp for robust parsing of multi-line
extern decls + function definitions. Mutation marker (phx_w45_drift)
verified post-mutation to guard against silent no-op substitutions.

Build lock: BUILD mode invokes cmake --build --target jit; per CLAUDE.md
Phase 3D Build Lock, only testkeeper / gate_phoenix.sh may invoke with
builds enabled. --dry-run is unrestricted.

Authorization: theologian 21:55:24Z + supervisor 21:55:36Z + 22:33:17Z
DISPOSITION (C). §3.5 fold-into-C derivation falsifier (opcode-constant
shadow class) is deferred — needs W21 golden integration.

Sibling workstreams: W33 (zero-bridge verifier), W42 (refcount
correctness), W44 (DO-NOT-USE caller gate).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Phase 1 python#6 (emitBeforeWith) + python#7 (emitSetupWith) both folded their
PY_VERSION_HEX conditional + C++ wrapper logic INTO the C body, and
their callers now invoke hir_builder_emit_setup_with_common_c (the
internal C-bridge helper) directly from C — bypassing the C++ method
HIRBuilder::emitSetupWithCommon entirely.

That made the C++ wrapper DEAD: zero production callers.

Delete:
  builder.cpp: -21L (15L method def + 3L extern decl + 3L blanks)
  builder.h:   -10L (decl removed)
  builder_emit_c.c: +4 -5 (stale doc comment refresh — drop W27c
                          tag + C++ method back-reference)
NET: -32L pure deletion (no fold-into-C, no sig mutation).

The C body hir_builder_emit_setup_with_common_c is RETAINED — used
internally by hir_builder_emit_setup_with_c (Phase 1 python#7) and
hir_builder_emit_before_with_c (Phase 1 python#6) as a .c→.c helper.

Authorization: theologian 22:49:41Z (cross-check PASS, exhaustive
caller enumeration via grep -rnE '\bemitSetupWithCommon\b' Python
Include Lib/test → 0 production callers) + supervisor 22:49:52Z
(GO Step B). W45 fixture exemption justified per theologian 22:49:41Z:
shepard 22:46:33Z discipline applies to fold-into-C / sig-mutation;
delete-of-dead-code is neither (same precedent as Phase 1 python#1 INVOKE_*
delegation-stub deletes).

W44 gate: PASS (2 markers, 0 production callers).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Delete the pending_b2_blocks_ Class B vector + struct PendingBlock +
drain loop in translate(). The W26-era refactor of emitInlineExceptionMatch
removed all writers but left the queue declaration + drain plumbing as
load-bearing-looking dead state.

Independent grep verification (theologian 23:35:58Z + librarian
23:50:24Z + spec §2.1 grep-writers-before-Step-A discipline per pythia
python#93): 4 reference sites, ZERO writers. Mutation patterns
push_back/emplace_back/insert/operator[]/resize/assign/reserve all
NOT FOUND across cpython/. PendingBlock struct unused outside the
deleted field.

Reframes Phase 3 spec §2 inventory: pending_b2_blocks_ marked DELETED
in §2.1 errata; the §5 forcing-decision propagation validation is
now deferred to Batch 4 (block_map_, the next Class B candidate)
with mandatory pre-Step-A writer-grep per spec §2.1 amendment.

NO new bridges, NO new W45 fixtures (delete-of-dead-state per shepard
22:46:33Z + supervisor 23:36:13Z carve-out). NOT counted toward
W45 §3.5 5-batch backstop per supervisor 23:49:22Z (current count
holds at 4: python#6+python#7 fold-into-C + Phase 3 Batch 1+2).

Numstat (vs HEAD 1343895):
  Python/jit/hir/builder.cpp           +0  -6   (drain loop + clear)
  Python/jit/hir/builder.h             +0  -8   (struct + vector field)
  Python/jit/hir/builder_state_c.h     +4  -3   (Class B doc-list refresh
                                                  + dead-state footnote)
TOTAL: NET -13L pure deletion (forecast -15L; -2L variance).

Pre-commit compile-check: testkeeper 23:52:59Z BUILD_EXIT=0,
3-test sanity green (partial_conversions + W22 + W44).

W44 gate: PASS (2 markers, 0 production callers).

Authorization: theologian 23:35:58Z + supervisor 23:36:13Z (A)
DEAD-DELETE only (split from getSimpleExceptInfo per theologian
different-shape-bisect-granularity reasoning).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
Add hir_builder_state_block_map_blocks_lookup_cpp bridge accessing
HIRBuilder.block_map_.blocks (a std::unordered_map<BCOffset,
BasicBlock*>) via friend declaration. Rewire the existing C-side
bridge hir_builder_get_block_at_off in hir_c_api.cpp to call the new
state-flavored bridge instead of the C++ method directly.

§5 forcing-decision validation: PhxHirBuilderState declares block_map
as opaque pointer in spirit (Class B-kept with as-needed bridge
surface); the bridge is materialized + actively used by C-side code.
Disposition CLOSED for block_map_; pattern propagatable to remaining
Class B members (temps_, static_method_stack_) per spec §5 amendment.

Per theologian 00:06:05Z + supervisor 00:06:36Z DISPOSITION (X)
MINIMAL: pure addition of bridge + rewire of existing C-side bridge
caller. C++ method HIRBuilder::getBlockAtOff UNCHANGED — the 9
internal C++ callers in builder.cpp keep direct C++ access (no
indirection added on hot translate paths).

Bridge added (1, well within W25b ≤5/batch):
  hir_builder_state_block_map_blocks_lookup_cpp(builder, off) -> void*

W45 fixture: 1 new (state_block_map_blocks_lookup_cpp) added per
shepard 22:46:33Z same-commit discipline. W45 perl regex updated
([\s\*]+ before symbol) to handle void* return type. Dry-run: 13/13
fixtures stage cleanly.

Numstat (vs HEAD b92d85e):
  Python/jit/hir/builder.cpp           +10 -0  (bridge impl + friend access)
  Python/jit/hir/builder.h             +5  -0  (friend decl + comment)
  Python/jit/hir/builder_state_c.h     +9  -0  (1 bridge decl)
  Python/jit/hir/hir_c_api.cpp         +4  -2  (rewire body to bridge)
  scripts/w45_bridge_drift_falsifier.sh +2  -1 (1 new fixture +
                                                 void*-return regex)
TOTAL: NET +27L (forecast +26L; +1L variance, ~4%, under theologian
15% threshold).

Pre-commit compile-check: testkeeper 00:11:14Z BUILD_EXIT=0,
3-test sanity green (partial_conversions + W22 + W44).

W44 gate: PASS.

§3.5 backstop count post-land: 5/5 reached (W26 python#6+python#7 fold-into-C +
Phase 3 Batch 1+2+4; Batch 3 dead-delete didn't count). §3.5
fold-into-C derivation falsifier impl trigger fires next workstream
per supervisor 23:49:22Z + theologian §2.5 amendment.

Authorization: theologian 00:06:05Z (cross-check PASS, caller-count
correction 9 builder.cpp + 1 hir_c_api.cpp = 10 total) + supervisor
00:06:36Z (Step B GO).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
Implements scripts/w45_section_3_5_derivation_drift.sh per
docs/w45-bridge-signature-drift-falsifier.md §2.7. Trigger fired at
Phase 3 Batch 4 b44a514 (5/5 backstop reached: W26 fold-into-C
python#6 + python#7 + Phase 3 Batch 1 + Batch 2 + Batch 4).

Sibling to scripts/w45_bridge_drift_falsifier.sh (W45 §1-§2 signature
mutation). This script mutates DERIVED CONSTANTS, struct FIELD LAYOUTS,
and bridge RETURN TYPES that C-body implementations depend on.

Mode (B) source-mutation per spec §2.7.1 (mode (A) W21-golden-driven
deferred until W21 lands per §2.7.5).

Initial 4 fixtures per spec §2.7.2:
  Class A — fold-into-C derived constants:
    1. BEFORE_ASYNC_WITH opcode-derivation (Phase 1 python#6 emitBeforeWith
       C body) — rename constant in builder_emit_c.c, expect build
       fail at C body comparison site
    2. _Py_ID identifier-derivation (Phase 1 python#7 emitSetupWith body
       region) — rename macro in builder_emit_c.c lines 4140-4220,
       expect build fail at C body identifier sites
  Class B — Phase 3 bridge-derived field-reads:
    3. ExceptionTableEntry depth field rename (Phase 3 Batch 2) —
       rename in builder.h struct decl, expect build fail at
       builder.cpp push_cpp/entry_cpp impls
    4. block_map_blocks_lookup_cpp return-type void* -> int (Phase 3
       Batch 4) — change in builder_state_c.h, expect build fail at
       hir_c_api.cpp:hir_builder_get_block_at_off return statement

Restore: `git checkout HEAD -- <file>` per spec §2.7.3 (deterministic
cleanup; idempotent; no temp-file shuffling). EXIT trap restores any
touched files defensively.

Modes:
- --dry-run: stage mutations, no build (any agent — bypass build lock)
- --strict:  exit 1 on FAIL (for gate integration)
- --verbose: show build stderr

Build lock: BUILD mode invokes cmake --build --target jit; per
CLAUDE.md Phase 3D Build Lock, only testkeeper / gate_phoenix.sh
may invoke with builds enabled. --dry-run is unrestricted.

Dry-run verification: 4/4 fixtures stage cleanly; tree restored
(git status clean post-run, no leftover modifications).

§3.5 backstop count post-this-commit: 5/5 reached + impl landing.
Future fixtures appended atomic-with-burndown per shepard 22:46:33Z
+ spec §2.7.3 python#5.

Authorization: theologian 23:49:00Z §2.5 amendment + 00:14:30Z §2.7
sketch + supervisor 00:14:45Z SEQUENTIAL post-Batch-4-push disposition.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
…hon#7)

Per supervisor 02:45:37Z fast-path TRIGGER post Tier 8 Phase A
incident python#7 (R-retry under enhanced mtime-checkpoint discipline also
ROLLED BACK at HEAD 48339e2, same pattern as 01:23Z incident python#6).

mtime-checkpoint discipline DETECTED proactive (Write tool safety
check + post-write system-reminders) but did NOT prevent recurrence.
(R-retry) reasoning ('discipline addresses risk class') empirically
INVALIDATED — same external force re-reverts at every Tier 8 attempt.
Pythia python#105 'fever has name infection still spreads' validated
twice.

Theologian-pre-drafted amendment 02:26:02Z replaces 'Tier 8 pilot
scheduled' section with 'Tier 8 pilot BLOCKED (push 28+, 2026-04-24)':
- Pilot field exception_table_ POD-equivalent
- Phase A attempted 01:18:35Z + 02:39:00Z (R-retry); HALTED 01:23:55Z
  + 02:45:12Z by external file-state revert (incidents python#6 + python#7;
  observed-but-not-attributed per generalist 01:24:43Z + 02:45:12Z)
- Resume gated on Alex disposition + fixup PIR; both unmet by
  push 28 deadline (supervisor 02:13:12Z + theologian 02:13:54Z)
- DEADLINE reached push 28 at 02:15:47Z; second incident at 02:45:12Z
  re-confirms permanent-block-this-session

**Pythia python#103 escape question RE-OPENED.** Phase 3 keep-bias is the
END STATE pending future migrate-arm validation. 'Transitional
foundation cost paid back' framing is HONEST-ASPIRATIONAL not
RESOLVED. ZERO-C++ terminal goal (MEMORY.md L70 + L104) remains
gated on Tier 8 pilot landing in a future session.

Phase 3 cumulative +257L is END STATE this session. Future session
must re-attempt Tier 8 Phase A under same spec (post external-revert
root-cause attribution, since detection alone insufficient) OR
honestly amend Phase 3 closure framing to 'permanent scaffolding'.

Cross-link section also amended: §5 amendment line updated to
'keep-bias as design choice; Tier 8 migrate-arm pilot FILED but
BLOCKED — see Tier 8 pilot BLOCKED section above'.

Doc-only +24L. No §3.5 BUILD MODE per touched-files rule.

Authorization: theologian 02:26:02Z STAGED-ON-DISK + supervisor
02:45:37Z fast-path TRIGGER post HALT python#7.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
…amendment

Per supervisor 02:48:39Z atomic doc-only bundle. Closes the
6→7 escalation triggered by Tier 8 pilot Phase A (R-retry) recurring
revert at incident python#7.

W48 spec (docs/w48-nbs-inotify-file-watcher-spec.md, +194L NEW):
  Theologian 02:48:25Z spec per W42/W44/W45 spec pattern. Elevates
  PIR §2.1 option (a) inotify file-watcher from DEFERRED to ACTIVE
  workstream. Mechanism: pyinotify daemon as NBS-suite sidecar; narrow
  watch per agent edit-set; event correlation with agent Write tool
  calls; forensic snapshot for root-cause attribution (closes
  pythia python#105 (3) zero-attribution gap).
  4-escalation history honest framing: Alex directive D-1776434533 →
  gate python#3 D-1776887480 → 4-step discipline 03a0dcb → mtime-checkpoint
  48339e2 → W48. Each progressively detective, none preventive.
  Cost ~3-5 sessions multi-session NBS-suite extension.
  Acceptance: 7 items including CLAUDE.md rule 5 addition + Tier 8
  pilot retry under W48.

PIR amendment (docs/2026-04-24-pre-edit-revert-pir.md, +21/-2):
  - Incident table: appended incident python#7 (2026-04-24T02:45Z, same
    pattern as python#6, mtime-checkpoint detected but did not prevent)
  - Conclusion: 7 incidents (was 6), 0 root cause attributions
  - NEW 'Incident python#7 ESCALATION' subsection: documents (R-retry)
    reasoning empirically INVALIDATED + pythia python#105 'fever has name'
    validated twice
  - NEW 'W48 ESCALATION' subsection: cross-links W48 spec landing +
    Tier 8 pilot Phase A retry GATED on W48 landing

Doc-only bundle, no §3.5 BUILD MODE per touched-files rule. Closes
the post-incident-python#7 reactive cycle: closure-amendment shipped at
push 30 (f6328cd), W48 + PIR ship at push 31.

Authorization: theologian 02:48:25Z (W48 spec) + supervisor 02:48:39Z
(atomic bundle GO).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
ROOT CAUSE FIX for the 8-incident undiagnosed-recurring file-state
revert class (D-1776998268 + 7 priors).

Per supervisor 04:14:27Z post-incident-python#8 ROOT CAUSE IDENTIFICATION:
the §3.5 falsifier's restore_files() trap was the "external reverter"
across all 8 incidents. It ran `git checkout HEAD --` on TOUCHED_FILES
on script exit; if those files had unstaged modifications BEFORE the
script ran (e.g., agent's in-flight Tier 8 Phase A content), the trap
blew them away.

Empirical validation (this session 04:13:36Z):
- Test python#6 + python#7 (trivial content, single-mechanism): no revert
- Tests python#5/python#7 idle: no revert
- cmake build alone: no revert
- §3.5 invocation on staged Phase A: REVERT (PhxExceptionTable
  count 13 → 0; mtime bumped 1777002918 → 1777003987; builder_state_c.h
  no longer M in git status)

8 prior incidents now retroactively attributed to §3.5 trap firing
during build/gate cycles concurrent with agent Tier 8 attempts.
NO external actor (no VS Code, no Alex, no formatter, no cron).
W48 inotify daemon NOT NEEDED. (Iso-A) host relocation NOT NEEDED.
Class size CLOSED — class type changed from "undiagnosed-recurring"
to "self-inflicted via §3.5 trap, RESOLVED".

Fix mechanism: snapshot per-file content to /tmp on first
snapshot_file_if_new() call (per fixture mutation start). restore_files()
copies from snapshot (not HEAD), preserving pre-script unstaged state.
Snapshots cleaned + FILE_SNAPSHOTS array unset post-restore.

Re-validation (this session post-fix):
- §3.5 BUILD MODE 4/4 PASS
- post-restore build [OK]
- Phase A content (PhxExceptionTable count 13) SURVIVED §3.5 invocation
- ALL 6 Tier 8 staged files still M

Doc-only (script-only) push, no §3.5 BUILD MODE per touched-files rule
(this IS the §3.5 script being amended; meta-circular but doc-only
gate appropriate).

Authorization: supervisor 04:14:27Z FIX directive post-ROOT-CAUSE
identification (generalist 04:13:58Z catch).

Pythia python#105 'fever has name infection still spreads' was structurally
correct re self-inflicted infrastructure — but the infection wasn't
external-class undiagnosable; it was OUR OWN script's exit trap
trampling unstaged work. 5 detection layers (Alex directive D-1776434533,
gate python#3 D-1776887480, 4-step Pre-Edit WT Integrity D-1776995670,
mtime-checkpoint D-1776998268, W48 spec D-1776999077) added to detect
ourselves. Audit own scripts BEFORE external-actor hypotheses (per
new feedback memory entry).

Speculative pushed a commit to Speculative/cpython that referenced this pull request

Apr 26, 2026
Design notes for the next round of fork-side perf work, after the
autopsy-report consumer drove tracing overhead from ~1x (original
exp28 baseline) to ~3x via the OID-refresh / type-name-fidelity /
WAL_OBJ_SNAPSHOT correctness fixes.

Six optimizations enumerated with first-pass risk assessments
(LoC, invasiveness, crash risk):

1. User-code-only filter at capture time (~5-10x WAL volume win,
   high leverage; the simple variant is straightforward, the smart
   variant is more nuanced because mutations on user-visible objects
   from inside stdlib must still emit).

2. Resizable oid_map (~40 LoC, removes a sharp cliff at >16K live
   objects — what made one of our benchmarks hang for 20+ minutes).

3. Compact event encoding via varints (~2-3x smaller WAL, ~100 LoC,
   medium crash risk because varint decoding is finicky).

4. Streaming compression (~3-5x smaller bundles, stacks well with
   python#3, ~50 LoC + dep on liblz4/zstd).

5. Skip BIND for unchanged primitive values (modest win, ~20 LoC,
   trivial risk — freebie).

6. tp_dealloc hooks (~2x runtime speedup but high crash risk —
   foot-gun on cleanup ordering, race conditions, subclass coverage,
   collisions with other tools that patch tp_dealloc).

Suggested order: python#2, python#1, python#5, python#3, python#4, python#6.

None implemented; this is just a design-time scope-out so the work
is shovel-ready when perf becomes a blocker.

Speculative pushed a commit to Speculative/cpython that referenced this pull request

Apr 26, 2026
…nalysis

Two scope changes vs the first draft:

- The user-code-only filter is now framed as a pluggable classifier
  (mechanism vs policy split): the fork exposes
  _tracewal.set_classifier(callable), the consumer (autopsy-report
  here) supplies the predicate. Default = the existing path-based
  heuristic moved from load-time to capture-time. New escape hatches:
  include / exclude sugar for specific libraries (pure-Python lib
  debugging) and a full callable override for niche cases. Notes the
  event-type-aware filtering subtlety: control-flow events skip in
  stdlib but mutation events emit unconditionally so the loader's
  reconstructed state stays current when stdlib mutates user-visible
  objects. Mentions a future three-way (full / call-only / skip)
  extension that the binary tag accommodates.

- New "Background: the OID map memory story" section. Map currently
  grows unbounded with objects-ever-seen because we have no
  destruction signal (gc.callbacks misses refcount-driven deallocs;
  weakrefs don't work for list/dict/tuple/function/method).
  Heuristic eviction breaks identity. So the four mitigations stack:
  resize handles the cliff, user-code filter slows the growth rate
  (most stdlib oids never created), dealloc hooks finally bound it
  to live working set. Only python#3 makes it steady-state.

Reorder: tp_dealloc hooks bumped from python#6 to python#3 — runtime-perf
framing alone undersold them; they're also the only thing that
bounds map memory in long-running captures, which matters once we
move past tiny demo scripts.

Pre-demo work scoped to python#1 + python#2. Everything else explicitly post-demo.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 27, 2026
Phase 4.A pilot conversion of the BuiltinLoadMethodElimination pass
(theologian invariant pre-audit 08:10:43Z + patch-shape APPROVE
08:39:30Z + nit-close 08:43:33Z; supervisor 08:14:58Z). First mutating-
pass conversion under Phase 4 OPEN; methodology (b) sole-path swap +
per-commit ABBA gate per supervisor 08:15:23Z + theologian 08:15:08Z.

  Python/jit/hir/builtin_load_method_elimination_c.c (NEW, 295 LOC)
    Pure-C body for the LoadMethod / GetSecondOutput / CallMethod
    triple rewrite. Uses the Cat-A helpers already in
    blme_helpers_c.{c,h}: phx_get_method_object_from_type +
    phx_immutable_multithreaded_type_lookup. Container is a
    PhxBlmeArray linear-scan keyed on LoadMethodBase pointer
    (theologian recommendation; max LoadMethodBase per function is
    typically <50). Outer fixed-point loop has a defensive iteration
    cap (PHX_BLME_MAX_ITERATIONS=100) per theologian invariant python#8 —
    cap-hit fires JIT_DCHECK_C in pydebug, benign early-out in
    release. JIT_COMPILE_GUARD wraps each per-triple rewrite per
    invariant python#7. addReference for both method_obj AND type_obj per
    invariant python#6 (PyClassMethodDescr branch).

  Python/jit/hir/builtin_load_method_elimination.cpp (-172 +9)
    Deleted the C++ tryEliminateLoadMethod + Run bodies and the
    extern "C" wrapper. Run() now forwards to
    hir_builtin_load_method_elimination_run via static_cast<HirFunction>;
    jit::hir::BuiltinLoadMethodElimination remains an instantiable
    Pass for compiler.cpp:127's runPassIf chain.

  Python/jit/hir/hir_instr_c_verify.cpp (+9)
    Cross-C-struct name_idx-offset asserts for the LoadMethodBase set
    (HirLoadMethod / HirLoadMethodCached / HirLoadModuleMethodCached).
    No concrete C++ classes for these opcodes — Phoenix allocates them
    via C factories — so the load-bearing invariant is C-side layout
    consistency, not C↔C++ matching. Cross-arch DeoptBaseWithNameIdx
    layout is covered indirectly by the existing FillTypeAttrCache
    assert (same HIR_DEOPT_NAMEIDX_FIELDS macro origin).

Build: scripts/build_phoenix.sh --clean ThinLTO PASS (testkeeper
09:06:00Z, isolated to these 3 files). 5 JIT_DCHECK_C call sites,
1 new include cinderx/Common/jit_log_c.h.

ABBA (4-bench, 3-rep, baseline = vanilla CPython):
  fibonacci    2.29x  (+56.3%)
  nqueens      1.59x  (+37.2%)
  gen_simple   0.74x  (-34.7%)  pre-existing alert (push 59 baseline 0.70x;
                                BLME modifies CallMethod/LoadMethodBase
                                pairs, generators don't exercise that hot
                                path; no causal mechanism for new regression)
  func_calls   1.01x  (+0.6%)
  GEO-MEAN     1.28x   no >5% drop trigger; well above 1.0x floor

Per-trajectory accounting per docs/phase4-hir-burndown-spec.md §5
(post 7a11cc0 refinement):
- C added: +295 (.c body) + 9 (verifier) = +304
- C++ removed: 172 (algorithm body) — shell deletion deferred to
  Phase 4.D (compiler.cpp:127 still consumes the C++ Pass type)
- Shell-pending: builtin_load_method_elimination.cpp 21 LOC