Skip to content

spikes: W-4899 gradual-ownership witness model (mutex category) + interop falsification matrix (#4899) - #4955

Open
dankezo wants to merge 2 commits into
limitlessprojects:mainfrom
dankezo:spike/w4899-gradual-ownership
Open

dankezo wants to merge 2 commits into
limitlessprojects:mainfrom
dankezo:spike/w4899-gradual-ownership

Conversation

@dankezo

@dankezo dankezo commented Nov 30, 2026

Copy link
Copy Markdown

Spike for #4899 (Wildcard Track): an executable model of the Sound Gradual Ownership witness for ONE category (mutex), plus the Gate 3 interop falsification matrix. No Hybrid language or compiler change; standalone directory spikes/w4899-gradual-ownership/, Python 3 stdlib only.

What it does

  • witness_model.py reads real .hy sources, finds managed(..., "mutex", ...) frontiers, extracts managed bindings, guard mutexes, task spawns, lock/unlock/mutation/escape ops, and simulates three task schedules against the witness contract: R1 lockset (a mutation is legal only while the mutating task holds the binding's guard mutex), R2 owner epoch (no mutation after frontier exit), R3 escape seal (references stashed outside the block stay tracked). Every violation blames the exact file:line of the managed declaration, parsed from the source.
  • interop_matrix.py classifies 12 idiomatic Go interop shapes as SEALED / EXIT-ONLY / UNSEALABLE under a stated decision rule (no deep-copy, no reflection), with three executable demonstrations of the defeat mechanisms.
  • Expectations were pre-registered in RESULTS.md and committed before the implementation was run.

Measured results

  • Corpus 18 (managed decl at line 80): CLEAN. 16 guarded mutations, 0 violations, 67 witness ops. The declared discipline is backed by a real lock.
  • Corpus 02 (managed decl at line 70): VIOLATIONS. All 8 extracted task mutations of counts are unguarded and blame line 70. The block declares a "runner mutex" that does not exist anywhere in the program (no lock operation at all), so the witness catches the declaration as unbacked - the deterministic form of the corpus file's own honesty note.
  • fx1 (wrong mutex held): 1 violation; the held set names the ledger's mutex l.mu while the guard is a.mu; blame fixtures/fx1-wrong-mutex.hy:27.
  • fx2 (escaped reference mutated after exit): 1 violation, rule R2 through the escaped alias; the worker's in-block guarded mutation stays clean; blame fixtures/fx2-escaped-after-exit.hy:25.
  • fx3 (actor state, two task tokens): DECLINED. The actor category is not wired in this spike, so Gate 2 as written (all 3 fixtures) is not claimed; the scoped result is 2/2 on the mutex-applicable fixtures with exact blame.
  • Schedule invariance: identical violation sets under spawn-order, reverse, and round-robin schedules for every analyzed program.
  • Gate 1: the zero-cost leg holds in the model - the pure fixture (fx0, no managed block) lowers to an identical op stream with witnesses on or off, 0 witness ops. The <25% overhead leg against plain Go is NOT MEASURED: it needs the hy-emit integration and a Go toolchain, and this environment has no Go toolchain. A Python bookkeeping-cost proxy is included and labeled as a cost shape only.
  • Gate 3: the falsification criterion FIRES. SEALED 3/12, EXIT-ONLY 3/12, UNSEALABLE 6/12; not-sealed share 75% against the issue's >20% threshold. Failure boundary: freeze-digest sealing delivers the full guarantee only for pure value shapes; reference-carrying shapes are at best EXIT-ONLY (retained references mutate silently after exit), and any / behavioral-interface / pointer-field / callback / channel shapes are unsealable without deep-copy or reflection.

Tests

  • Spike: 17 unit tests, all passing (python3 -m unittest discover -s tests).
  • Neighboring repo suites, untouched by this change: tools/test_managed_gate.py 27/27, tools/test_check_guarantees.py 25/25, tools/test_check_corpus_census.py 21/21.
  • The change adds files only under spikes/w4899-gradual-ownership/ (9 files, +1331/-0).

Limits, honestly: this is an executable model of the proposed witness semantics, not an hy-emit implementation: no code generation, no runtime/go helpers, no task-token threading. The extractor is a narrow line-based reader for the corpus idiom (struct-field mutexes, task spawns, index/field mutations); a binding whose guard it cannot identify is treated as unguarded, the conservative direction. Reads are not guarded. Categories actor, atomic, finalizer, interop have no witness here; interop is studied only through the Gate 3 matrix.

…interop matrix)

Pre-registered expectations for issue limitlessprojects#4899, committed before the
implementation run per spike convention: corpus 18 CLEAN, corpus 02
flagged at its managed line, fx1/fx2 blamed exactly, fx3 DECLINED,
Gate 3 falsification expected to fire at 75% not-sealed.
Mutex-category witness model over the issue's corpus anchors:
corpus 18 CLEAN (16 guarded mutations), corpus 02 flagged (8
unguarded mutations of counts, blame :70 - the declared runner
mutex does not exist in the program). fx1 wrong-mutex and fx2
escaped-after-exit each blamed exactly; fx3 actor DECLINED.
Gate 3 falsification fires: 3/12 SEALED, not-sealed 75% > 20%.
Gate 1 zero-cost leg holds in the model; the Go overhead leg is
NOT MEASURED (no hy-emit integration, no Go toolchain here).
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