Skip to content

parse-reader: splice multi-line spec continuations so -> stays top-level#4

Merged
hierophantos merged 2 commits into
mainfrom
claude/fix-eigentrust-pitfall-6-m5bE8
Apr 27, 2026
Merged

parse-reader: splice multi-line spec continuations so -> stays top-level#4
hierophantos merged 2 commits into
mainfrom
claude/fix-eigentrust-pitfall-6-m5bE8

Conversation

@kumavis
Copy link
Copy Markdown
Contributor

@kumavis kumavis commented Apr 25, 2026

EigenTrust pitfall #6 (2026-04-23) reported that a multi-line spec like

spec eigentrust-step
     [List [List Rat]]   ;; matrix C
     [List Rat]          ;; pre-trust p
     Rat                 ;; damping
     [List Rat]          ;; current t
     -> [List Rat]       ;; next t
defn eigentrust-step [c p alpha t] ...

failed with spec: spec type for eigentrust-step has no arrow but defn has 4 params. The user attributed it to line comments, but those are
stripped by the tokenizer; the real cause is indent grouping. Each
continuation line with multiple tokens was wrapped via wrap-stx-list
into a sub-list, so the line -> [List Rat] became (-> (List Rat)).
split-on-arrow-datum only scans the top level of the spec body
tokens, so the buried arrow was invisible and decompose-spec-type
treated the body as a zero-arrow relation type.

For nodes whose first token is spec or spec-, switch
tree-node->stx-elements to a flatten variant that splices indent-
grouped continuation lines directly into the parent token stream.
Metadata-style continuations whose first token is a keyword-like
symbol (:doc, :where, :method, ...) are still wrapped, so the
existing process-spec metadata loop continues to recognize them.

Bracket-grouped function-type parameters like [-> A Bool] are
unaffected — they come from explicit brackets, not indent grouping,
and remain sub-lists with -> as the head. Other forms (defn,
def, match, ...) are unchanged: only spec-form nodes take the new
path.

Test coverage in test-spec-multiline-ws.rkt covers the eigentrust
reproducer, the metadata-continuation case, the bracketed prefix-arrow
function-type case, and a non-regression check on defn body
indent-grouping.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

@kumavis kumavis force-pushed the claude/fix-eigentrust-pitfall-6-m5bE8 branch from f98914a to f44bf48 Compare April 25, 2026 08:34
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 25, 2026
Cherry-picked from PR #2 (commit f3a3ca3). The benchmark file references
the pre-D.5b TMS API (`tms-write`, `tms-cell-value`, `tms-read`,
`tms-commit`) which was removed when the TMS was refactored into the
`tms-cell` struct + `atms-write-cell` interface. The file is a
historical baseline-measurement artifact (Pre-0 micro-benchmark) that
does not run in CI or the regression suite, but `raco pkg install
--auto` compiles every .rkt in the collection, so its unbound-identifier
error fails the build.

Add `racket/prologos/benchmarks/micro/info.rkt` with
`compile-omit-paths '("bench-bsp-le-track2.rkt")` so `raco setup`
skips it. This is a minimal CI-unblock; the full migration to the
current TMS API is out of scope for this PR (same as f3a3ca3's scope).

Without this, PR #4 (and the other pitfall PRs branched from main) all
fail CI in the `raco pkg install` step.

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis added a commit that referenced this pull request Apr 26, 2026
Adds a pre-pass before the main process-command loop that pre-registers
each spec'd defn's name in the global env with its declared type. This
makes forward references between top-level defns resolve regardless of
source order, so the canonical even?/odd? pattern (and any other mutual
or forward-reference cycle) works without source-order workarounds.

Approach: (b) — leverage the existing spec system. The pre-pass calls
expand-top-level on each surf, walks surf-def and surf-def-group, and
for each annotated def elaborates ONLY the type and installs the name
via global-env-add-type-only. The main loop's process-def then
overwrites the entry with the freshly-zonked type once the body is
elaborated. Approach (b) was preferred over (a) placeholder types and
(c) SCC analysis because Prologos's idiomatic style already pairs
defns with specs, and a placeholder type would have required taught
the type-checker to tolerate it.

Pre-registration uses the legacy parameter path (current-prelude-env)
rather than the cell path: it's visible to global-env-lookup-type via
Layer 2 fallback, is properly test-isolated (run-ns-* helpers reset
the parameter), and gets overwritten by the cell-path write in the
main pass.

Behavior on spec-less mutual recursion: Prologos already handles this
via inferred hole-typed defns ('_ -> _'). The pre-pass skips defs
without a type annotation, so spec-less defns continue to elaborate
through their existing path. Both spec'd and spec-less mutual
recursion now resolve.

Three call sites updated (one per top-level entry path):
  - process-string-inner (sexp string)
  - process-surfs (WS string, common tail)
  - process-file-inner (.prologos file)

Tests:
  - tests/test-mutual-recursion.rkt: 7 tests covering canonical
    forward reference, two-way mutual cycle, three-way chain,
    self-recursion regression, and spec-less mutual recursion.
  - All pre-existing tests still pass (test-multi-body-defn,
    test-spec-ordering, test-process-ws-01/02, test-spec,
    test-pattern-defn-01/02, test-elaborator,
    test-elaborator-network, test-module-network-01,
    test-process-parse-01: 227 tests total).

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
…level

EigenTrust pitfall #6 (2026-04-23) reported that a multi-line `spec` like

    spec eigentrust-step
         [List [List Rat]]   ;; matrix C
         [List Rat]          ;; pre-trust p
         Rat                 ;; damping
         [List Rat]          ;; current t
         -> [List Rat]       ;; next t
    defn eigentrust-step [c p alpha t] ...

failed with `spec: spec type for eigentrust-step has no arrow but defn
has 4 params`. The user attributed it to line comments, but those are
stripped by the tokenizer; the real cause is indent grouping. Each
continuation line with multiple tokens was wrapped via `wrap-stx-list`
into a sub-list, so the line `-> [List Rat]` became `(-> (List Rat))`.
`split-on-arrow-datum` only scans the top level of the spec body
tokens, so the buried arrow was invisible and decompose-spec-type
treated the body as a zero-arrow relation type.

For nodes whose first token is `spec` or `spec-`, switch
`tree-node->stx-elements` to a flatten variant that splices indent-
grouped continuation lines directly into the parent token stream.
Metadata-style continuations whose first token is a keyword-like
symbol (`:doc`, `:where`, `:method`, ...) are still wrapped, so the
existing process-spec metadata loop continues to recognize them.

Bracket-grouped function-type parameters like `[-> A Bool]` are
unaffected — they come from explicit brackets, not indent grouping,
and remain sub-lists with `->` as the head. Other forms (`defn`,
`def`, `match`, ...) are unchanged: only spec-form nodes take the new
path.

Test coverage in test-spec-multiline-ws.rkt covers the eigentrust
reproducer, the metadata-continuation case, the bracketed prefix-arrow
function-type case, and a non-regression check on `defn` body
indent-grouping.

https: //claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x
Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
@kumavis kumavis force-pushed the claude/fix-eigentrust-pitfall-6-m5bE8 branch from aa14042 to ff099e9 Compare April 26, 2026 01:03
Copy link
Copy Markdown
Contributor Author

@kumavis kumavis left a comment

Choose a reason for hiding this comment

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

looks good, requested an additional type to ensure it's compatible with additional keywords

Comment thread racket/prologos/tests/test-spec-multiline-ws.rkt
kumavis added a commit that referenced this pull request Apr 26, 2026
Adds a pre-pass before the main process-command loop that pre-registers
each spec'd defn's name in the global env with its declared type. This
makes forward references between top-level defns resolve regardless of
source order, so the canonical even?/odd? pattern (and any other mutual
or forward-reference cycle) works without source-order workarounds.

Approach: (b) — leverage the existing spec system. The pre-pass calls
expand-top-level on each surf, walks surf-def and surf-def-group, and
for each annotated def elaborates ONLY the type and installs the name
via global-env-add-type-only. The main loop's process-def then
overwrites the entry with the freshly-zonked type once the body is
elaborated. Approach (b) was preferred over (a) placeholder types and
(c) SCC analysis because Prologos's idiomatic style already pairs
defns with specs, and a placeholder type would have required taught
the type-checker to tolerate it.

Pre-registration uses the legacy parameter path (current-prelude-env)
rather than the cell path: it's visible to global-env-lookup-type via
Layer 2 fallback, is properly test-isolated (run-ns-* helpers reset
the parameter), and gets overwritten by the cell-path write in the
main pass.

Behavior on spec-less mutual recursion: Prologos already handles this
via inferred hole-typed defns ('_ -> _'). The pre-pass skips defs
without a type annotation, so spec-less defns continue to elaborate
through their existing path. Both spec'd and spec-less mutual
recursion now resolve.

Three call sites updated (one per top-level entry path):
  - process-string-inner (sexp string)
  - process-surfs (WS string, common tail)
  - process-file-inner (.prologos file)

Tests:
  - tests/test-mutual-recursion.rkt: 7 tests covering canonical
    forward reference, two-way mutual cycle, three-way chain,
    self-recursion regression, and spec-less mutual recursion.
  - All pre-existing tests still pass (test-multi-body-defn,
    test-spec-ordering, test-process-ws-01/02, test-spec,
    test-pattern-defn-01/02, test-elaborator,
    test-elaborator-network, test-module-network-01,
    test-process-parse-01: 227 tests total).

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
@kumavis kumavis force-pushed the claude/fix-eigentrust-pitfall-6-m5bE8 branch from ff099e9 to 1b10e8a Compare April 26, 2026 03:02
`check-true` requires the result to be literally `#t`. `memq` returns
the matching tail (a list) on success, so the assertions tripped on
the truthy-but-not-`#t` value. Switch to `check-not-false`, which
correctly accepts any non-`#f` result.

The main `check-equal?` checks already passed — these assertions were
redundant safety nets. Verified with `raco test`: 10/10 tests pass.

https: //claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x
Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
@kumavis kumavis force-pushed the claude/fix-eigentrust-pitfall-6-m5bE8 branch from 1b10e8a to 71bf4af Compare April 26, 2026 03:42
@kumavis
Copy link
Copy Markdown
Contributor Author

kumavis commented Apr 26, 2026

requested test was added 👍

Copy link
Copy Markdown
Contributor

@hierophantos hierophantos left a comment

Choose a reason for hiding this comment

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

LGTM. Surgical scope (one fork in tree-node->stx-elements + 3 local helpers); other forms (defn, def, match) untouched; metadata-keyword exception correctly preserves :doc / :where / :method continuation lines as wrapped sub-lists for process-spec's metadata loop.

Audit-passed against our codebase: 935 existing specs are all single-line, so zero existing code is affected. The fix is purely additive — unblocks multi-line type signatures, which we'll want for complex dependent / session / effect types that are core to the language vision.

Approving.

@hierophantos hierophantos merged commit 3d7ccb1 into main Apr 27, 2026
1 check passed
@hierophantos hierophantos deleted the claude/fix-eigentrust-pitfall-6-m5bE8 branch April 27, 2026 04:20
hierophantos added a commit that referenced this pull request Apr 27, 2026
Add Phase 4 to the addendum design doc as a future sub-phase covering
process-command sequential orchestrator retirement. Closes the gap
between the thesis ("no sequential orchestrators alongside the BSP
scheduler") and the original phase breakdown (which delivered only the
in-form orchestrator retirement at metavar-store).

Three locations updated in 2026-04-21_PPN_4C_PHASE_9_DESIGN.md:

§1.1 Thesis: extended from three architectural moves to four. Move 2
"Orchestration" retitled to "Orchestration (in-form)" to disambiguate
from the new move 4 "Orchestration (between-form)".

§1.2 Phase scope: added Phase 4 description with bullets covering
process-command retirement, BSP-stratum-handler dispatch per form
type, topology-phase semantics, mutual recursion as falling-out, and
coordination with PM Track 12 + PM Track 10. LoC TBD; mini-design at
phase open per addendum methodology.

§3 Progress Tracker: added Phase 4 row before V (Capstone) row,
status ⬜, references #22 + PR #14.

Designed when current Phase 1 (tropical fuel) and Phase 2 (in-form
strata) close. Motivating use case: mutual recursion (PR #14, kumavis
pitfall #4) currently scaffolded via pre-pass; structural fix lands
with this phase.

Tracking issue: #22
Dailies entry: 2026-04-26 dailies "Parallel session — external
contributor PR review pass"
kumavis pushed a commit that referenced this pull request Apr 27, 2026
Per user review of #0-#10: many entries were either out-of-scope
(env limitations, not Prologos issues) or wrong (claims I never
actually tested). Re-tested every claim against a real Racket and
revised the doc.

Numbers are reserved per the user's instruction — entries marked
DELETED keep their slot so cross-refs don't drift.

Detail:

  #0  DELETED — out-of-scope (Racket toolchain not in sandbox).
                Environment limitation, not a Prologos issue.

  #1  REFRAMED — was "capability subtype + promise resolution
                composition." Re-titled to honestly reflect what
                this actually is: an OCapN-side Phase 0
                deferred-implementation note (eventual cross-vat
                receive isn't wired up yet). NOT a Prologos bug.

  #2  DELETED — false claim. Tested with a real Racket: WS-mode
                wildcard match `match | _ -> body` on user data
                types elaborates AND evaluates correctly when the
                function carries a proper `spec`. The
                `prologos::data::datum` comment I cited applies to
                a narrower polymorphic-context case, not a blanket
                wildcard ban as I asserted.
                Cleanup of behavior.prologos (~250 -> ~70 LOC)
                follows.

  #3  DELETED — false claim. Tested: `data Step step : [Nat -> Nat]`
                (with bracketed function type per the lseq-cell
                convention) accepts a function value, including
                closures with captured state. Open-world actor
                behaviour storage IS supported. The closed-enum
                BehaviorTag in our implementation was a needless
                workaround driven by this incorrect pitfall.
                Cleanup tracked separately.

  #4  KEPT, REFRAMED — real, narrowed claim. grammar.ebnf §6
                lines 1153/1187/1199 promise `Mu` (sexp) and `rec`
                (WS) for recursive sessions. Both elaborate to
                `Unknown session type: rec` / `Mu`. So pitfall #4
                is now: "rec/Mu in grammar but not in elaborator."
                CapTP's stream-level well-typedness is therefore
                the documented ceiling; per-exchange sub-protocols
                remain the workaround.

  #5  KEPT — `none`/`some` need explicit type args in some inference
            contexts. Real ergonomics tension, accurately
            documented.

  #6  DELETED — out-of-scope. WS-mode `let p := body` and sexp-mode
                `(let (p v) body)` are TWO surface forms by design
                (grammar.ebnf §7 line 1236). User-error, not a
                Prologos bug.

  #7  DELETED — was a quantitative restatement of #2. With #2
                recanted, #7 evaporates: behavior modules can be
                wildcard-collapsed, dropping ~180 LOC.

  #8  DELETED — false claim. Tested: `data Box1 box1 : [Sigma [_ <Nat>] Bool]`
                and `data Table table : Nat -> [List [Sigma [_ <Nat>] Bool]]`
                both elaborate cleanly. The named-struct
                ActorEntry/PromiseEntry workaround in vat.prologos
                was unnecessary; can be simplified back.

  #9  DELETED — user error. `def` for value bindings vs `defn` for
                functions is documented (grammar.ebnf §3
                lines 189-190, prologos-syntax rules). Mis-using
                `defn` for a 0-ary constant isn't a Prologos bug.

  #10 DELETED — out-of-scope. Network sandbox blocking external
                docs is an environment limitation.

#11-#20 were not in scope of this review and remain as-is for the
user to review next.
kumavis pushed a commit that referenced this pull request Apr 27, 2026
Per user direction:
- Replace the body of every DELETED entry with a single-sentence
  explanation. Numbers reserved per prior instruction.
- Delete #15 (QTT multiplicity on fst/snd thrice). I re-tested
  with a real Racket — `pair [snd p] [fst p]` then a third use of
  `fst p` works fine; no multiplicity error. The failure I had
  conflated this with was actually #14's "match-and-reconstruct
  Sigma" issue.

Result: pitfalls doc shrinks from 765 to 534 lines. Remaining
real claims: #1, #4, #5, #11, #12, #13, #14, #16, #17, #18, #19,
#20 (the user has reviewed only #0-10 so far; #11-20 still
pending their review).
kumavis added a commit that referenced this pull request Apr 28, 2026
…alls #15)

A two-line def with type annotation —

    def c : [List Int]
      := '[1 2 3]

— silently suppressed evaluation: PHASE-TIMINGS reported reduce_ms=0
and the bound name elaborated but never reduced. The same def collapsed
to one line worked normally. The silent-no-work shape was particularly
bad for benchmarks (reported zero reduce time regardless of workload).

Add a def-form-node? branch to tree-node->stx-elements and a
flatten-with-boundaries/def variant that splices ONLY continuations
whose first token is :=. All other continuations (bare body, bracketed
application chain, etc.) stay wrapped, preserving today's

    def c
      + 1 2

→ (def c (+ 1 2)) semantics for the bare-body idiom.

Narrower than the spec splice rule (#4 / #6) on purpose: spec needs to
expose -> from anywhere in a multi-line type signature, def only needs
to expose := which is always the head of a natural line break.

Test coverage in test-def-multiline-ws.rkt covers:
  - Datum equivalence between one-line and two-line shapes (12 cases).
  - Bare-body wrapping is preserved.
  - End-to-end via run-ns-ws-last (silent-suppression regression pin).
  - Multi-line BODY after :=, := alone on a line, and definitions
    spanning lines as bracketed groups.

Three-level WS validation:
  - Level 1 (sexp): the test file uses run-ns-last where applicable.
  - Level 2 (WS string): ws-read / run-ns-ws-last cover the dispatch
    and elaboration paths.
  - Level 3 (WS file): process-file on a .prologos with the two-line
    form reports reduce_ms=5 / reduce_steps=39, matching the one-line
    shape exactly (was reduce_ms=0 / reduce_steps=0 before).

https://claude.ai/code/session_01MbncYJnrvjzhbVWw4xGi5x

Co-authored-by: kumavis <1474978+kumavis@users.noreply.github.com>
kumavis pushed a commit that referenced this pull request May 4, 2026
Original PIR text claimed runtime/core/ contains the BSP scheduler.
Wrong — actual runtime/core/ has only data structures (cell store +
profile counters + format buffer). The BSP scheduler stayed in each
kernel file (hybrid kernel's worklist + fire_against_snapshot +
merge_pending_writes + swap_worklists are inlined in
prologos-runtime-hybrid.zig).

Stage 3 design called for core/bsp.zig (~150 LOC) + core/worklist.zig
(~60 LOC) as Phase 1 deliverables. Actual Phase 1 extracted only
cells.zig + profile.zig + format.zig. The factoring scope shrank
silently — neither the implementing commit nor any subsequent commit
acknowledged the gap. Surfaced when the user asked "what's in the
hybrid core zig side?" during PIR review.

Corrections:
- §1 (What Was Built): explicit "data structures only" + cross-ref
  to wrong-assumption #9
- §2 (Stated Objectives): added "reality check on the design quote"
  flagging the drift
- §3 delivered table: Phase 1 status changed to "✅ partial"
- §4 timeline: Phase 1+3+4 line clarifies scheduler not extracted
- §5 deferred: new row for BSP scheduler factoring
- §8 D1 + anti-decision: caveat added; "BSP scheduler abstraction"
  claim corrected to "cell-store comptime-parameterization
  abstraction"
- §9 #2: factoring narrative softened to "data structures only"
- §11 #3: original kernel template + factoring made explicit at
  data-structure layer only
- §12 #2 + #8: kernel-LOC framing corrected; "factored core LOC was
  bigger than expected" reframed to "smaller than expected — and
  the gap is the BSP scheduler"
- §13 architecture: "consuming runtime/core/" framing softened to
  "consumes for cell store + profile + format helpers; the BSP
  scheduler is inlined"
- §14 #3, #7, #8: "future kernels instantiate the same scheduler"
  claim corrected to "instantiate CellStore + reuse profile
  counters; each kernel still writes its own scheduler"
- §15 technical debt: new row for "BSP scheduler not factored"
- §17 wrong assumptions: new #9 "Phase 1 will factor the BSP
  scheduler into core" — Wrong; codifies the silent scope shrinkage
- §18 #4: "factoring at second-instance" pattern reinforced with
  "complete vs minimum-viable shared surface" caveat
- §21 lessons: new entry for "phase-close should compare delivered
  scope against design plan"
- §24 open Q #4: kernel-PU consumption clarified — needs scheduler
  reuse in-place or triggers the extraction debt

Errata block added at the top of the PIR documenting which sections
were corrected and why.

https://claude.ai/code/session_01Tycs6BWKG58Wo99YVPg6DF
kumavis pushed a commit that referenced this pull request May 4, 2026
Two follow-up phases that need Prologos-language work, not
OCapN-track work:

Phase 22 — Open-world actor behaviors. Currently `BehaviorTag`
is a closed enum of 7 cases. Real Goblins-style users need
first-class behavior closures stored heterogeneously in the
actor table. Blocked on:
  - Heterogeneous existential containers
  - First-class trait-method values
  - Or per-actor existential types

Phase 23 — Stream-level session typing. CapTP needs μ-recursive
session types `μX. &> {deliver:X, listen:X, abort:end}` for
stream-level well-typedness. Blocked on pitfall #4: grammar
admits `Mu`/`rec` but the elaborator rejects them.

Both deferrals documented in
docs/tracking/2026-04-29_OCAPN_INTEROP_DESIGN.md with proper
"why" rationale and "scope of follow-up" pointers (language
workstream, not OCapN). The OCapN port is unblocked on these —
current closed-enum behaviors + per-exchange session types are
sufficient for the wire compatibility we've achieved.

https://claude.ai/code/session_01YM6gc3cMNH2Ymor4jdZY8u
kumavis pushed a commit that referenced this pull request May 4, 2026
…spatch fix

Both PReduce-lite and Hybrid Runtime PIRs now carry an "Addendum
(2026-05-04, swappable-backend refactor)" block at the top + targeted
updates to §3 (delivered files), §15 (technical debt closure), and
§23 (key files).

PReduce-lite PIR:
- Top-of-doc addendum referencing the refactor design doc, the new
  three-file backend layer (preduce-core + backend-racket + backend-
  hybrid), and the functional-threading model rationale (SH-endpoint fit).
- §3 file table: added preduce-core.rkt (153 LOC) and preduce-
  backend-racket.rkt (~100 LOC); annotated preduce.rkt as "1509 →
  ~1480 (post-backend-refactor)" with a note on the b-* primitive
  rewrite.
- §23 key-files: replaced the two-file PReduce-lite engine entry
  with the post-refactor five-file layout (preduce-core, backend-
  racket, backend-hybrid, preduce, preduce-hybrid).

Hybrid Runtime PIR:
- Top-of-doc addendum (separate from the existing BSP-scheduler-in-
  core errata) covering: (a) the parallel-impl debt closure (407 →
  66 LOC for preduce-hybrid.rkt; ~6× larger AST coverage on the
  kernel — Phase 1-10b vs Phase 8b only); (b) the native-dispatch
  regression discovered + fixed (initial backend-hybrid wrapped
  int-arith as callback; #:native-op hint restored kernel tags 0-7);
  (c) post-fix benchmark numbers (W4 hybrid 2× faster than lite for
  user-ctor workloads; W5 31% faster wall + 14× faster kernel-side
  for int-arith).
- §1 What Was Built: pre-refactor vs post-refactor narrative on the
  preduce-hybrid.rkt collapse + the new preduce-backend-hybrid.rkt.
- §3 file table: preduce-hybrid.rkt 407 → 66 (−341 LOC); added
  preduce-core.rkt + preduce-backend-hybrid.rkt rows.
- §15 technical debt: TWO entries struck through (rendered as ~~old
  text~~) and replaced with "CLOSED 2026-05-04" notes:
  - "Two parallel reducers" debt (closed by the refactor proper)
  - "Native int-arith dispatch lost" regression (closed by the
    #:native-op hint mechanism)

Both addenda cross-reference [`2026-05-04_PREDUCE_BACKEND_REFACTOR_DESIGN.md`]
which carries the full design plan + 9-phase rollout tracker.

The structural lessons reinforced:
- "Factor at second-instance" pattern (PReduce-lite §18 #4) — the
  refactor extracted the factoring at the right time, with a third
  Racket-reducer consumer (future preduce-distributed?) on the
  horizon.
- "The parallel-impl debt was real" — the hybrid PIR's §15 entry
  warned about it; the refactor cashed in the warning.
- "Phase-close should compare delivered scope against design plan"
  (Hybrid §17 #9) — the same lesson surfaced AGAIN: the initial
  backend-hybrid Phase 4 commit didn't compare its native-dispatch
  scope against the pre-refactor preduce-hybrid's; the regression
  hid for two commits before the user's "is there a bug" question
  exposed it. Codified for the third time; pattern is now confirmed
  load-bearing.

https://claude.ai/code/session_01Tycs6BWKG58Wo99YVPg6DF
kumavis pushed a commit that referenced this pull request May 4, 2026
Adds prologos::ocapn::* — a single-vat, pure-functional model of the
OCapN/Goblins actor system, built entirely in Prologos with the
existing capability-types and session-types primitives.

Library (lib/prologos/ocapn/):
  - refr.prologos          capability hierarchy: OCapNRefr / NearRefr
                            FarRefr / SturdyRefr / PromiseRefr +
                            UnresolvedPromise / ResolvedNear / Far /
                            BrokenPromise. Subtype edges encode
                            attenuation.
  - syrup.prologos         abstract Syrup value model (atoms, list,
                            tagged, refr, promise). No bytewise codec.
  - promise.prologos       monotone promise algebra (fulfill/break +
                            queue mechanics for pipelined messages).
  - message.prologos       CapTP op:* values: deliver, deliver-only,
                            listen, abort, gc-export, gc-answer,
                            start-session.
  - behavior.prologos      closed-enum BehaviorTag + per-tag step
                            functions for cell, counter, greeter,
                            echo, adder, forwarder, fulfiller.
  - vat.prologos           local vat: spawn, send, send-only, drain
                            + step-vat / run-vat with explicit fuel
                            (no mutation, no threads).
  - captp-session.prologos five sub-protocols modelled as session
                            types: Handshake, Deliver, Listen,
                            DeliverOnly, Gc — with `dual` for the
                            responder side and example defproc
                            clients.
  - core.prologos          public API re-exports + Goblins-flavoured
                            aliases (spawn-actor / ask / tell / drain).

Tests (tests/test-ocapn-*.rkt, 8 files):
  refr / syrup / promise / message / behavior / vat / pipeline /
  captp / e2e — exercise per-module unit semantics and the full
  actor-system round-trip.

Acceptance file:
  examples/2026-04-27-ocapn-acceptance.prologos

Pitfalls catalogue:
  docs/tracking/2026-04-27_GOBLIN_PITFALLS.md — ten language /
  ergonomics issues encountered during the port. Open the file for
  the next port to start with eyes open. Headline issues:
  closed-world data wildcard match (#2), no first-class actor
  closures (#3), no recursive session types (#4), sandbox couldn't
  exercise the suite (#0).

Constraints followed:
  - No new Racket FFI introduced; everything in Prologos source
  - Only stdlib imports (data::list, data::option, data::nat,
    data::string, data::bool)
  - Capability types declare the refr authority lattice
  - Session types declare each CapTP wire sub-protocol

Status: implementation is static-syntax-clean by inspection; not
run on a real Racket toolchain in this environment. Pitfall #0
documents the verification gap.
kumavis pushed a commit that referenced this pull request May 4, 2026
Per user review of #0-#10: many entries were either out-of-scope
(env limitations, not Prologos issues) or wrong (claims I never
actually tested). Re-tested every claim against a real Racket and
revised the doc.

Numbers are reserved per the user's instruction — entries marked
DELETED keep their slot so cross-refs don't drift.

Detail:

  #0  DELETED — out-of-scope (Racket toolchain not in sandbox).
                Environment limitation, not a Prologos issue.

  #1  REFRAMED — was "capability subtype + promise resolution
                composition." Re-titled to honestly reflect what
                this actually is: an OCapN-side Phase 0
                deferred-implementation note (eventual cross-vat
                receive isn't wired up yet). NOT a Prologos bug.

  #2  DELETED — false claim. Tested with a real Racket: WS-mode
                wildcard match `match | _ -> body` on user data
                types elaborates AND evaluates correctly when the
                function carries a proper `spec`. The
                `prologos::data::datum` comment I cited applies to
                a narrower polymorphic-context case, not a blanket
                wildcard ban as I asserted.
                Cleanup of behavior.prologos (~250 -> ~70 LOC)
                follows.

  #3  DELETED — false claim. Tested: `data Step step : [Nat -> Nat]`
                (with bracketed function type per the lseq-cell
                convention) accepts a function value, including
                closures with captured state. Open-world actor
                behaviour storage IS supported. The closed-enum
                BehaviorTag in our implementation was a needless
                workaround driven by this incorrect pitfall.
                Cleanup tracked separately.

  #4  KEPT, REFRAMED — real, narrowed claim. grammar.ebnf §6
                lines 1153/1187/1199 promise `Mu` (sexp) and `rec`
                (WS) for recursive sessions. Both elaborate to
                `Unknown session type: rec` / `Mu`. So pitfall #4
                is now: "rec/Mu in grammar but not in elaborator."
                CapTP's stream-level well-typedness is therefore
                the documented ceiling; per-exchange sub-protocols
                remain the workaround.

  #5  KEPT — `none`/`some` need explicit type args in some inference
            contexts. Real ergonomics tension, accurately
            documented.

  #6  DELETED — out-of-scope. WS-mode `let p := body` and sexp-mode
                `(let (p v) body)` are TWO surface forms by design
                (grammar.ebnf §7 line 1236). User-error, not a
                Prologos bug.

  #7  DELETED — was a quantitative restatement of #2. With #2
                recanted, #7 evaporates: behavior modules can be
                wildcard-collapsed, dropping ~180 LOC.

  #8  DELETED — false claim. Tested: `data Box1 box1 : [Sigma [_ <Nat>] Bool]`
                and `data Table table : Nat -> [List [Sigma [_ <Nat>] Bool]]`
                both elaborate cleanly. The named-struct
                ActorEntry/PromiseEntry workaround in vat.prologos
                was unnecessary; can be simplified back.

  #9  DELETED — user error. `def` for value bindings vs `defn` for
                functions is documented (grammar.ebnf §3
                lines 189-190, prologos-syntax rules). Mis-using
                `defn` for a 0-ary constant isn't a Prologos bug.

  #10 DELETED — out-of-scope. Network sandbox blocking external
                docs is an environment limitation.

#11-#20 were not in scope of this review and remain as-is for the
user to review next.
kumavis pushed a commit that referenced this pull request May 4, 2026
Per user direction:
- Replace the body of every DELETED entry with a single-sentence
  explanation. Numbers reserved per prior instruction.
- Delete #15 (QTT multiplicity on fst/snd thrice). I re-tested
  with a real Racket — `pair [snd p] [fst p]` then a third use of
  `fst p` works fine; no multiplicity error. The failure I had
  conflated this with was actually #14's "match-and-reconstruct
  Sigma" issue.

Result: pitfalls doc shrinks from 765 to 534 lines. Remaining
real claims: #1, #4, #5, #11, #12, #13, #14, #16, #17, #18, #19,
#20 (the user has reviewed only #0-10 so far; #11-20 still
pending their review).
kumavis pushed a commit that referenced this pull request May 4, 2026
Two follow-up phases that need Prologos-language work, not
OCapN-track work:

Phase 22 — Open-world actor behaviors. Currently `BehaviorTag`
is a closed enum of 7 cases. Real Goblins-style users need
first-class behavior closures stored heterogeneously in the
actor table. Blocked on:
  - Heterogeneous existential containers
  - First-class trait-method values
  - Or per-actor existential types

Phase 23 — Stream-level session typing. CapTP needs μ-recursive
session types `μX. &> {deliver:X, listen:X, abort:end}` for
stream-level well-typedness. Blocked on pitfall #4: grammar
admits `Mu`/`rec` but the elaborator rejects them.

Both deferrals documented in
docs/tracking/2026-04-29_OCAPN_INTEROP_DESIGN.md with proper
"why" rationale and "scope of follow-up" pointers (language
workstream, not OCapN). The OCapN port is unblocked on these —
current closed-enum behaviors + per-exchange session types are
sufficient for the wire compatibility we've achieved.

https://claude.ai/code/session_01YM6gc3cMNH2Ymor4jdZY8u
kumavis pushed a commit that referenced this pull request May 4, 2026
New file: docs/tracking/2026-05-04_PROLOGOS_LANGUAGE_PITFALLS.md
Tracks bugs in the Prologos compiler stack as they surface during
downstream work (running real programs through the hybrid kernel).
Distinct from upstream OCapN goblin-pitfalls.md which catalogs
OCapN-specific design pitfalls.

Format per entry: discovered date, surfacing program, symptom, root
cause hypothesis, workaround, status (🔴 open / 🟡 worked-around /
🟢 fixed), affects, path to fix.

Initial entries:
  #1 (🟡): FQN-qualified prelude symbols (e.g. prologos::data::list::nil)
       not resolved by preduce.rkt's expr-fvar lookup. Affects both
       backends. Surfaced by ocapn-hybrid-5 + ocapn-hybrid-7.
  #2 (🟢): Kernel FormatBuffer 1024-byte limit silently truncated
       profile JSON. Fixed prior commit by bumping to 8192 bytes.
  #3 (🔴): Silent prelude shadowing under :refer-all produces
       confusing inference errors. Surfaced when ocapn-hybrid-8
       called [int? a] on SyrupValue and got prologos::data::datum::
       int? instead. UX issue, not correctness.
  #4 (🟡): Identity-bridge install sites in compile-and-bridge +
       dynamic-β don't pass #:native-op 'identity, missing the
       Phase-10-style native dispatch.

Three new OCapN programs (all running on kernel):
  ocapn-hybrid-6: multi-arg defn (pick) matching on 2 args with
                  one binder + one ctor pattern per arm. 16 fires,
                  117 µs. Result (false, true).
  ocapn-hybrid-7: uses prologos::ocapn::promise directly —
                  pst-fulfilled + pst-broken predicates. 10 fires,
                  103 µs. (Note: works around Pitfall #1 by
                  constructing pst-fulfilled/pst-broken directly
                  instead of using `fresh` which depends on `nil`.)
  ocapn-hybrid-8: MIXED native + callback profile. int+/int* go to
                  KERNEL-INT-ADD-TAG / KERNEL-INT-MUL-TAG (NATIVE),
                  bool?/tagged? go through Racket callbacks.
                  Result: **3 native fires (5.6 µs) + 6 callback
                  fires (92 µs)** — first program where the per-tag
                  KIND mix is visible in the kernel profile.

NOTES.md test-status table extended to 8 programs (5+factorial+3
new). Average kernel time per OCapN program: 30-130 µs depending
on dispatch depth.

https://claude.ai/code/session_01Tycs6BWKG58Wo99YVPg6DF
kumavis pushed a commit that referenced this pull request May 6, 2026
Per-track LOC contribution estimates for the remaining Phase 7
migration targets, with rationale + risk weighting + prerequisite
ordering. Grounded against current code-size baselines:
  Zig kernel: 913 LOC
  Racket reducer + backends + bridge: 2347 LOC

Summary (track / Zig delta / Racket delta / cb-time absorbed):
  #5 boolrec -> kernel_select         +0    +30    ~4%   (free; just routing)
  #4 ctor-N native ABI                +400  +200/-100  ~5% workload, ~50% OCapN
  #3 expr-reduce match dispatch       +200  +200/-150  ~10%
  #2 expr-natrec step                 +150  +50/-30    ~5% effective, ~17% theoretical
  #1 recursive expr-fvar + expr-app   +1000 +400/-200  ~60%
  #7 CHAMP collection ops             +5000+ +500/-200 ~4% (synthetic; defer)

Net if #1-#5 land: Zig +1750 LOC (~3x growth); Racket -50 LOC net.
Surface complexity migrates from Racket compile-expr to Zig kernel.

Three suggested orderings (A: biggest payoff first; B: incremental;
C: value-engineering minimum). All start with #5 (free), all
prerequisite #4 before #3.

Doc identifies 5 open design questions: ctor-N ABI choice
(heap-backed vs bit-packed), closure representation, tail-call
semantics, eager arm compilation interaction with recursion,
bot-guard convention formalization.

Three things this analysis does NOT settle:
- Whether #1 is feasible without losing static-beta benefits
  (B1/B2/H1/J1/J2 do zero runtime fires today; native apply costs
  more rounds).
- Per-fire cost of native call apparatus (somewhere between 115ns
  native and 4100ns callback; not measured).
- Whether #1+#2+#3 land as one track or three (architecturally
  coupled; landing them independently means a stub-laden middle
  state).

https://claude.ai/code/session_01Tycs6BWKG58Wo99YVPg6DF
kumavis pushed a commit that referenced this pull request May 6, 2026
… result

Two updates after shipping the looseBVarRange fix (commit 4f6b3f0):

1. Investigated relationship to issue #45 (EigenTrust O(k²) reducer
   blowup). Conclusion: orthogonal root causes despite shared symptom.
   - #58 (mine): closed reduced accumulator + shift walking it
   - #45: unreduced redex chain accumulator + repeated whnf
   The looseBVarRange fix solves #58 but does NOT close #45 (which
   needs a strict-vs-lazy evaluation strategy fix or thunk sharing).
   Both PIR and survey doc updated with this analysis.

2. Re-enabled test-ocapn-bridge-interop.rkt locally to verify whether
   the looseBVarRange fix unblocks Phase 24's CI gate. Result: NOT
   sufficient. Local run timed out at 5+ minutes. Not worse than
   pre-fix (>8 min) but no clear "fast and green" signal. The
   bridge-interop test does substantially more reduction work than
   the synthetic perf test (decode + dispatch + drain + pump), and
   the residual N^1.6 scaling multiplies through the pipeline.

   Updated .skip-tests entry from "perf-blocked" to "perf-improved-
   but-still-slow" with reference to the survey's option #4
   (hash-consing) as the natural next step. PIR's "What's left"
   section updated with post-mortem of the failed re-enable
   attempt.

Per user direction, did NOT update github issue #45 or #58 — local
documents only.

https://claude.ai/code/session_01YM6gc3cMNH2Ymor4jdZY8u
hierophantos added a commit that referenced this pull request May 17, 2026
…ant rewrite (A: round-entry batch / B: local-var per-fire)

User challenged my "Q-M deferred to Phase 2 PAR" framing: "Our current BSP
scheduler IS the parallel BSP from PAR research (PAR essentially closed for
now). Is that not so?" Audit confirmed user is right; this commit corrects
the design doc.

## Audit findings (verified in code)

- driver.rkt:435 sets `current-parallel-executor` globally to
  `(make-parallel-thread-fire-all)` — parallel BSP IS production default
- PAR Track 2 R1-R2 closed with BSP-as-production-default; 4.45× speedup
- Codebase has FIVE scheduler entry points, each with different loop
  structure + different fuel-decrement pattern:
  1. run-to-quiescence-inner (sequential Gauss-Seidel; box-mutation per-fire)
  2. run-to-quiescence-inner/traced (same + tracing)
  3. run-to-quiescence-bsp (parallel BSP; ALREADY batch-decrement-by-N at
     line 2384's round-entry — production main loop)
  4. run-widen-phase (sequential widening; struct-copy per-fire)
  5. run-narrow-phase (sequential narrowing; struct-copy per-fire)

## The CRITICAL discovery

The parallel BSP main loop (entry point #3) ALREADY does
round-entry batch decrement at line 2384:
```
[fuel (- (prop-network-fuel net) n)]
```
where n = (length pids). Fuel decrements happen ON THE MAIN THREAD,
sequentially, BEFORE workers spin up. Workers fire against the
post-decrement snapshot but don't touch fuel.

This means Phase 1C migration to D.4 + Option 13 is simpler than
described: change the struct-copy field update to a cell-write at the
same site. The substrate changes (struct field → cell); the concurrency
pattern doesn't change.

## §10.3.A two-variant rewrite

The original §10.3.A pseudocode described a single per-fire local-var
pattern. The audit showed this pattern is WRONG for the parallel BSP
main loop (which has no per-fire body). It's CORRECT for the sequential
schedulers (#1, #2, #4, #5).

Two variants:
- **Variant A** (round-entry batch): parallel BSP main loop. ONE
  net-cell-write per BSP round, on main thread, BEFORE workers.
  Cost: ~6 ns/round; amortized ~0.06 ns/cycle at N=100.
- **Variant B** (local-var per-fire): four sequential schedulers.
  Local-var box + per-fire decrement + cell-write at phase end.
  Cost: ~2.16 ns/cycle amortized (per §13.6.A spike).

The scheduler CHOOSES the variant fitting its loop structure. Both
preserve orthogonality (cell mechanism is unchanged).

## Q-M correction

- Was: "DEFER-TO-PHASE-2-PAR" (incorrect framing)
- Now: RESOLVED IN-SCOPE 2026-05-15 — parallel BSP main loop already
  serializes fuel-state updates on main thread; Phase 1C migration
  changes substrate but not concurrency pattern

## §9.9 open questions resolved

Walkthrough of Phase 1B mini-design open questions with Option 13 + audit
applied. 7 of 8 architectural questions RESOLVED:
- Q-1B-8 → A2 (cell-meta on prop-cell struct; perf pressure dissolved
  under Option 13's boundary-only dispatch)
- Q-1B-9 → F2 (predicate receives (current, new-value, net))
- Q-1B-10 → B1-prime (cell-meta + dispatch in propagator.rkt; thin
  specialized-cells.rkt for convenience)
- Q-1B-11 → D1 (storage strategy enum: 'general + 'monotone-counter)
- Q-1B-12 → E1 (fire-on enum: 'any-change + 'threshold-crossing)
- Q-1B-13 → G1 (predicate runs AFTER merge)
- Q-1B-14 → L1 (local-var = let-scoped ephemeral box)

3 implementation-detail questions remain deferred to code (Q-1B-1
API naming; Q-1B-2 +inf.0 vs sentinel; Q-1B-4 residuation as helper).

## Design doc updates in this commit

- §10.3.A rewritten with two-variant pattern + scheduler/variant
  matrix; trade-offs note updated (Parallel BSP RESOLVED IN-SCOPE)
- §10.4 sub-phase plan: 1C-i enumerates all 5 entry points with variant
  assignment; 1C-ii migrates per-variant
- §10.5: D-1C-10 NEW (wrong-variant risk); D-1C-11 NEW (preserve batch
  semantic for parallel BSP main)
- §10.7: Q-1C-M corrected from DEFER to RESOLVED IN-SCOPE; Q-1C-K/L/N
  added
- §9.9 reorganized: 7 questions RESOLVED with specific leans; 3 deferred
  to code
- Top-of-doc Revision Summary: audit-correction note added
- DESIGN_PRINCIPLES.org § Scheduler-State Cells: deferred-write pattern
  rewritten with two variants + scheduler/variant assignment table

## Files in this commit

- docs/tracking/2026-04-26_PPN_4C_TROPICAL_QUANTALE_ADDENDUM_DESIGN.md
  (§10.3.A + §10.4 + §10.5 + §10.7 + §9.9 + top-of-doc updates)
- docs/tracking/principles/DESIGN_PRINCIPLES.org (§Scheduler-State Cells
  two-variant pattern note)
- docs/tracking/standups/2026-04-26_dailies.md (walkthrough narrative +
  audit findings + lessons)

## Honest acknowledgment

The "deferred to Phase 2 PAR" framing was lazy. PAR Track 2 R1-R2
closed; parallel BSP IS production. Phase 1B/1C must handle parallel
composition NOW, not defer it. User's challenge surfaced this gap.
The audit cost ~10 min of grepping + reading; it produced a substantive
design correction. Pattern: external questions about production reality
catch design assumptions that internal exploration misses.

Phase 1B is now ready to enter Stage 4 implementation with:
- All architectural decisions locked in (7 resolved questions + spike +
  spike-A validation)
- Five-scheduler-entry-point migration plan per variant
- §13.7 measurement gates at each sub-phase boundary
- Codified two-variant deferred-write pattern in DESIGN_PRINCIPLES.org
hierophantos added a commit that referenced this pull request May 17, 2026
…h scope 2→18)

1C-i pre-implementation audit per Per-Phase Protocol. Five findings
surfaced (α/β/γ/δ/ε); user confirmed all leans; §10 doc cleanup
(D-1B-iii-4 carryover) applied as 1C-i's mechanical work.

Audit findings:

α — Entry points #1 + #2 already have partial Variant B pattern
  (informational). run-to-quiescence-inner (drain at 2039) + /traced
  (2087) already use box-mutation + per-fire decrement + finalize
  flush. Migration simplifies to source/sink redirect for #1+#2;
  full helper introduction for #4+#5. Helpers apply uniformly.

β — Tier 1 BSP fast path doesn't decrement fuel (RESOLVED β1).
  run-to-quiescence-bsp Tier 1 (lines 2562-2573) bypasses fuel
  decrement entirely (single-pass flush for deterministic cases).
  β1 preserves this semantic under D.4 — no net-cell-write in
  Tier 1; cell value unchanged after Tier 1 round.

γ — run-to-quiescence-widen is a wrapper with check sites only
  (RESOLVED: not a 6th entry point). Line 3353 wrapper has 3 check
  sites (3357/3360/3367) but no decrement. Migrates under 1C-iii.

δ — typing-propagators.rkt:2269 is fuel-SUBSTITUTION, not speculation
  rollback (RESOLVED: Q-1C-1 closes simpler). Pattern is bounded-
  typing-run fuel-budget-substitution. D.4 migration is 4-line cell-
  API substitute + restore; no helper needed.

ε — Bench migration scope is 18 sites, NOT 2 (LOAD-BEARING; ε2).
  Q-Audit-1's "2 bench refs" only counted bench-alloc.rkt (2 sites).
  bench-ppn-track4c.rkt has 16 ADDITIONAL sites directly accessing
  prop-net-hot-fuel (Pre-0 microbench sections M7/A7). Under D.4
  retirement these break at compile.
  Resolution ε2: 2 bench-alloc.rkt sites migrate mechanically; 16
  bench-ppn-track4c.rkt sites RETIRED-PER-D.4-CANONICAL with
  annotations + comment-out. Historical baseline data preserved in
  tropical-pre0-baseline-2026-04-26.txt; new CM*+CW* benches measure
  the new pattern.

§10 doc cleanup applied (D.4 sections only; D.3 historical RETIRED-
PER-D.4-CANONICAL + §9.2.0.7 rename-history preserved):
- fuel-cost-cell-id → fuel-cell-id (~10 sections)
- fuel-cost-cell → fuel-cell (descriptive references)
- (+ current n) → (- current n) Option A direction (§10.2 + §10.3.A
  Variant A/B pseudocode)
- cost-framing variable names → remaining-framing (Variant B pseudo)
- cost= display → remaining= display
- §10.3 read-as-value, saved-fuel, pretty-print examples updated

Scheduler entry point line numbers re-verified (drifted significantly
since 2026-05-15 audit due to Phase 1B's prop-cell/prop-net-warm
extensions + BSP scheduler refresh):
- #1 run-to-quiescence-inner: 1835 → 2030 (drain at 2039)
- #2 /traced: 1870 → 2087
- #3 run-to-quiescence-bsp Tier 2: 2315 → 2532; snapshot at 2606
- #4 run-widen-phase: 2989 → 3214
- #5 run-narrow-phase: 3042 → 3267
- (6) run-to-quiescence-widen (new finding): 3353

A baseline capture strategy: rely on existing Pre-0 baseline data +
§13.6.A spike measurements rather than introduce new per-entry-point
microbench. A = M7 24 ns/call + B.M7.2 5.7 ns/call; C = §13.6.A
Variant A 0.06 ns/cycle + Variant B 2.16 ns/cycle.

Design doc changes:
- NEW §10.0.1 (~190 lines): 1C-i Mini-Audit Findings
- §10.2 substrate plan: Option A direction + bench scope 18 sites
- §10.3 per-site patterns: Option A + saved-fuel reframed
- §10.3.A Variant A pseudocode: corrected direction + Tier 1 note
- §10.3.A Variant B pseudocode: uses helpers + Option A direction
- §10.4 1C-ii-b notes α finding; 1C-v scope expanded to 18 bench
- §3 Progress Tracker: 1C-i marked ✅

Process observations (codification candidates):
- Audit counts grow as implementation work proceeds (ε pattern)
- Design-doc framing can be more complex than code reality (δ)
- Per-phase audit discipline catches line-drift pre-implementation

Suite state unchanged: 8286 tests / 127.4s / 0 failures (no code
changes; pure design + doc work).

Next: 1C-ii-a — Variant A migration. Replace line 2606's
[fuel (- (prop-network-fuel net) n)] with net-cell-write to
fuel-cell-id BEFORE workers spin up. ~5-10 LoC + 1-2 tests.
Cost target ~0.06 ns/cycle amortized.
hierophantos added a commit that referenced this pull request May 17, 2026
…er 2 (β1 lockstep)

Production code change: propagator.rkt line 2603-2609 region. +6 LoC
production + 76 LoC tests. Suite GREEN at 8289 / 126.4s / 0 failures.

Implementation (Variant A; parallel BSP main loop entry point #3):

After existing snapshot struct-copy (keeps [fuel (- ... n)] field update
per β1 lockstep), ADD:

  [snapshot+fuel (net-cell-write snapshot fuel-cell-id
                                 (- (net-cell-read net fuel-cell-id) n))]

Then thread snapshot+fuel through 5 downstream uses:
- (executor snapshot+fuel pids) line 2612
- (bulk-merge-writes snapshot+fuel ...) lines 2624, 2626
- snapshot+fuel as if-branch return line 2625
- (net-cell-read snapshot+fuel ...) line 2682

The cell-write triggers on-write predicate (<= new 0) firing
contradiction structurally if remaining-fuel hits zero. Option A
semantic (cell stores REMAINING fuel; decrement by n).

β1 lockstep transitional: BOTH struct field AND cell update in lockstep.
Cell-value equals struct-field-value at every observation point.
Acceptable transitional scaffolding ONLY because retirement obligation
captured at destination sub-phase:

  D-1C-ii-a-1 (retirement obligation): [fuel (- ...)] struct field update
  at line 2606 RETIRES at 1C-iv alongside prop-net-hot-fuel field itself.
  Only cell-write remains as production pattern post-1C-iv.

Captured in §10.4 1C-iv scope, §10.0.2 drift risk, Progress Tracker.

Tests added (test-tropical-fuel.rkt, 3 new test-cases, +76 LoC):

(1) cell-field-lockstep — Tier 2 BSP A→B copy; verify field = cell
    after round (β1 invariant)
(2) Tier 1 fast path preservation — fire-once empty-inputs propagator;
    verify NEITHER field NOR cell changed (β1 preservation; structural)
(3) exhaustion via cell-mechanism — budget=2 + 2 props; verify
    contradiction fires (cell on-write-check or legacy check site)

Verification:
- Delimiter check: balanced
- raco make driver.rkt: clean
- Targeted: 77 tests / 6.3s / all pass
- Full suite: 8289 / 126.4s / 0 failures (+3 tests; -1.0s wall)

VAG: PASS with named caveats (β1 dual update is transitional scaffolding
with captured retirement; microbench verification deferred to 1C-vi
A/B/C report per §13.7).

Drift risks closed:
- D-1C-ii-a-1: retirement obligation captured (§10.4 1C-iv + tracker)
- D-1C-ii-a-2: snapshot+fuel threading verified (5 sites + suite GREEN)
- D-1C-ii-a-3: (<= new 0) boundary verified by Test 3
- D-1C-ii-a-4: Tier 1 preservation verified by Test 2

Process observations:
- α discussion clarified no retirement at 1C-ii-a (just diff cleanliness);
  user's "is this retiring something?" prevented drift in framing
- β1 retirement obligation explicit capture (per user direction) prevents
  transitional dual-write from becoming permanent belt-and-suspenders
- All 4 drift risks named at mini-design closed at implementation

Next: 1C-ii-b — Variant B migration (4 sequential scheduler entry points;
#1 + #2 simpler redirect per pre-existing partial Variant B; #4 + #5 full
helper introduction). Cost target ~2.16 ns/cycle amortized per §13.6.A.
hierophantos added a commit that referenced this pull request May 17, 2026
…n) + FORK CHECKPOINT

1C-ii-b mini-design conversation 2026-05-16. Four questions (α/β/γ/δ);
one (α) architecturally load-bearing. All resolved with user.

Resolutions:

α2 — Box pattern at #4 + #5 (matches §10.3.A Variant B canonical design).
  The 1C-i α finding revealed #1 + #2 already have partial Variant B
  (box-mutation pattern); #4 + #5 use recursive function with per-fire
  struct-copy decrement. α1 (per-fire lockstep keeping recursive structure)
  would deviate from Variant B design + miss §13.6.A perf target. α2
  refactors recursive → box pattern, matching design intent.
  Trade-off: preempts 1C-iii migration for check sites at lines 3217 +
  3270 (those check sites migrate to per-iteration box checks under α2).
  D-1C-ii-b-2: 1C-iii scope reduces from 11 to 9 check sites; captured
  explicitly so 1C-iii doesn't double-migrate.

β1 — Helper signature: set-box! mutation style (matches §10.3.A
  pseudocode + #1 + #2 idiom + §13.6.A spike measurement pattern):
    (init-fuel-local-var! net) -> box
    (flush-fuel-local-var! net box) -> net

γ1 — Helpers inline in propagator.rkt (tightly coupled to BSP scheduler
  code; ~15-25 LoC doesn't justify separate module).

δ-3-tests — Mirror 1C-ii-a pattern: cell-field-lockstep at sequential
  phase exit + helper correctness + sequential exhaustion via
  cell-mechanism. Per-entry-point coverage via full suite GREEN.

Drift risks named:
- D-1C-ii-b-1 (LOAD-BEARING; retirement obligation): β1 lockstep at
  1C-iv. flush-fuel-local-var! writes BOTH cell + struct field during
  1C-ii-b through 1C-iii. At 1C-iv, struct-field write retires
  alongside prop-net-hot-fuel field; only cell-write remains. Affects
  all 4 sequential schedulers (share the helper). Captured in §10.4
  1C-iv scope.
- D-1C-ii-b-2 (LOAD-BEARING; scope reduction): α2 preempts 1C-iii
  migration for lines 3217 + 3270. 1C-iii scope 11 → 9 captured in
  §10.4 1C-iii scope.
- D-1C-ii-b-3: widen/narrow used by abstract interpretation; full
  suite catches semantic regressions.
- D-1C-ii-b-4: #1 + #2 redirect preserves inner-loop set-box! pattern.
- D-1C-ii-b-5: recursive→box refactor mechanical mistake risk.

Implementation sketch (confirmed; pending impl):
- Helpers in propagator.rkt (~15-25 LoC; init returns box; flush writes
  both cell + field; D-1C-ii-b-1 retirement at 1C-iv)
- #1 + #2 redirect (~10-20 LoC): preserve existing box pattern; init
  source + finalize sink use helpers
- #4 + #5 refactor (~40-60 LoC): recursive define → let loop; per-fire
  box decrement replaces struct-copy [fuel (sub1 ...)]; check sites
  3217 + 3270 migrate to (<= (unbox local-fuel) 0)

Revised total scope: ~115-205 LoC (larger than §10.4 original ~40-60
LoC estimate due to recursive→box refactor at #4 + #5).

Design doc changes:
- NEW §10.0.3: 1C-ii-b Mini-Design Resolutions (4 questions + retirement
  obligation + 1C-iii scope reduction + drift risks + impl sketch)
- §10.4 1C-ii-b: refined with α2 box pattern + helper details + scope
  estimate ~115-205 LoC; 1C-ii-b row notes #1+#2 simple redirect vs
  #4+#5 refactor distinction
- §10.4 1C-iii: scope REDUCED to 9 check sites (was 11) per D-1C-ii-b-2;
  lines 3217 + 3270 marked PREEMPTED by 1C-ii-b
- §10.4 1C-iv: scope expanded with explicit "retire 1C-ii-b β1 lockstep
  sync" task (D-1C-ii-b-1 retirement obligation)
- §3 Progress Tracker: 1C-ii-b mini-design ✅; 1C-ii-b impl ⬜ pending;
  1C-iii scope reduced annotation; 1C-ii-b row notes revised scope

🍴 FORK CHECKPOINT 2026-05-16:

User plans to fork back to `75d0c47e` (Phase 1B SUBSTRATE END-OF-PHASE
summary commit). Future session re-enters at that commit; design doc +
dailies file carry forward ALL 1C work (4 commits this fork).

Commits accomplished this fork (since 75d0c47):
- 97163e1 whole-phase 1C mini-design + Phase 1V scope (§10.0)
- cd770a0 1C-i mini-audit + §10 doc cleanup (§10.0.1; 5 findings)
- c7cbffc 1C-ii-a mini-design (§10.0.2)
- e94b0b8 1C-ii-a impl (Variant A; 8289/126.4s/0 fails)
- THIS commit: 1C-ii-b mini-design (§10.0.3) + fork checkpoint

Dailies entry includes comprehensive re-entry pointers:
- Cumulative architectural state at fork checkpoint
- 4-step re-orientation guide for fresh session
- Watching list of codification candidates accumulated across 1C arc

Process observation: Q-1C-ii-b-α surfaced a genuine architectural choice
(not just diff cleanliness like 1C-ii-a's α). The recursive-vs-box
pattern decision at #4 + #5 has real perf implications AND triggers a
sub-phase boundary blur (preempts 1C-iii for 2 sites). Explicit capture
of LOAD-BEARING + scope reduction prevents drift.

Codification candidate: "Audit-driven scope refinements should
propagate from §10.0.x mini-audit findings into §10.4 sub-phase plan
estimates BEFORE next sub-phase opens." 2 data points (1C-i ε bench
2→18; 1C-ii-b α scope 40-60→115-205). Watching list.

No code changes; pure design clarification + fork checkpoint. Suite
state unchanged: 8289 tests / 126.4s / 0 failures.

Next (per re-entry plan): 1C-ii-b implementation per §10.0.3 sketch.
~45-90 min estimated.
hierophantos added a commit that referenced this pull request May 17, 2026
…e drift caught

Per Stage 4 Per-Phase Protocol step 2: audit codebase BEFORE 1C-ii-b
implementation, even though mini-design landed (§10.0.3). Mini-design ↔
mini-audit are co-dependent; audit refines design before code lands.

Five findings (F1-F5) + 3 structural confirmations (F6-F8) + 2 new drift
risks (D-1C-ii-b-6/7).

**Key finding F1 — Line drift confirmed (D-1C-i-1 materialized)**:
+11 line shift at #4 (run-widen-phase 3214→3225; check 3217→3228) +
#5 (run-narrow-phase 3267→3278; check 3270→3281) + wrapper
(run-to-quiescence-widen 3353→3364) since 1C-i audit (2026-05-16
earlier). §10.0.3's preempted-check-site references at 3217+3270
updated to 3228+3281 in §10.4 1C-ii-b + 1C-iii rows + §3 Progress
Tracker.

**Key finding F3 — DESIGN REFINEMENT to §10.0.3 at #1+#2 finalize**:
Audit reality: the existing finalize at #1 (lines 2050-2058) + #2
(lines 2092-2095) writes BOTH worklist AND fuel-field via a single
struct-copy. Replacing with `flush-fuel-local-var!` (cell + field for
fuel; not worklist) would lose worklist update.

Resolution Option A (cleanest):
- #1 + #2 init: use `init-fuel-local-var!` ✓ matches §10.0.3
- #1 + #2 finalize: keep existing struct-copy verbatim; ADD
  `(net-cell-write n* fuel-cell-id (unbox remaining-fuel))` after it
- #4 + #5: use BOTH helpers per §10.0.3 sketch (no worklist
  interleaving; helper fits cleanly)

Helper signature stays generic; application mechanism varies per-site
based on existing code structure. D-1C-ii-b-6 names the asymmetry for
future maintainers.

**Other findings**:
- F2: #1 split between `run-to-quiescence-inner` (outer guard at 2030;
  check at 2034 stays 1C-iii scope) + `run-to-quiescence-drain` (box
  pattern at 2039+)
- F4: widen wrapper check sites (3368/3371/3378) stay 1C-iii scope
- F5: `net-fuel-remaining` accessor (line 3110) is 1C-iv scope
- F6: helper placement at line ~2027-2029 (before
  run-to-quiescence-inner; first user of helpers)
- F7: helpers don't exist yet (clean introduction)
- F8: 1C-ii-a tests (test-tropical-fuel.rkt:404-475) are mirror
  template

**Revised scope (audit-driven; tighter than §10.0.3)**:
~106-167 LoC (down from ~115-205) due to F3 refinement saving
~10-40 LoC of unnecessary refactoring.

**Persisted**:
- §10.0.4 NEW: full audit findings + F3 refinement + drift risks
- §10.0.3 amended with forward-pointer to §10.0.4
- §3 Progress Tracker: new "1C-ii-b mini-audit ✅" row
- §10.4 1C-ii-b + 1C-iii line numbers refreshed
- Dailies entry capturing audit findings + process observation

**Codification candidate**: 3rd data point on "Mini-audit step is
materially load-bearing for scope precision" (1C-i ε bench 2→18; 1C-ii-b
α scope 40-60→115-205; this audit 115-205→106-167). Strong watching-list
status; codify after 1 more.

No code changes; design doc + dailies only. Suite state unchanged at
8289 tests / 126.4s / 0 failures.
hierophantos added a commit that referenced this pull request May 17, 2026
…rn + convergence-check filter

Implementation per §10.0.3 mini-design + §10.0.4 audit refinement (F3 Option A).
Migrates 4 sequential scheduler entry points (#1/#2/#4/#5) from per-fire
struct-copy to box-pattern fuel tracking with β1 lockstep flush at observation
points.

**Helpers** (~30 LoC at line ~2030, before run-to-quiescence-inner):
- init-fuel-local-var! — reads cell into mutable box (Option A: REMAINING)
- flush-fuel-local-var! — writes box to BOTH cell + struct-field (β1 lockstep
  transitional; struct-field write retires at 1C-iv per D-1C-ii-b-1)

**#1 + #2 redirect** (per F3 Option A — helper init only):
- run-to-quiescence-drain (#1): init source migrated; existing finalize
  struct-copy preserved (handles fuel-field alongside worklist); cell-write
  ADDED after struct-copy for β1 lockstep
- run-to-quiescence-inner/traced (#2): mirrors #1
- Helper NOT used at #1+#2 finalize (would lose worklist flush); F3 audit
  refinement saved ~10-40 LoC over §10.0.3's symmetric design

**#4 + #5 recursive→box refactor** (~80 LoC mirrored):
- run-widen-phase (#4) + run-narrow-phase (#5): converted from recursive
  define with per-fire [fuel (sub1 ...)] struct-copy to (let loop ...) with
  box init at entry, box decrement per fire, flush at all 3 exits
  (contradiction / fuel-exhausted / null-worklist)
- 2 preempted check sites (refreshed line numbers per §10.0.4 F1) migrate to
  (<= (unbox local-fuel) 0) box check; 1C-iii scope reduces from 11 to 9

**Convergence-check filter** (D-1C-ii-b-8 NEW load-bearing invariant):
- run-to-quiescence-widen's narrow-loop convergence check compared full
  (prop-network-cells narrowed) vs (prop-network-cells net) via equal?
- My flush updates fuel-cell-id every narrow round → cell 11 differs per
  round → equal? always #f → narrow loop never converges → fuel exhausts
- Fix: filter scheduler-state cells (fuel-cell-id + fuel-budget-cell-id)
  from BOTH sides of the equal? via champ-delete before comparison
- **Principled per Cell/Propagator/Scheduler Orthogonality**: scheduler-state
  cells should not participate in propagator-driven convergence checks.
  Codification candidate captured.

**Tests added** (test-tropical-fuel.rkt; +118 LoC):
1. cell-field-lockstep at sequential phase exit (via run-to-quiescence-widen)
2. helper correctness (init returns box from cell; flush writes BOTH cell + field)
3. exhaustion via cell-mechanism at sequential scheduler

**Verification**:
- Delimiter check: GREEN both files
- raco make: clean
- Targeted (5 files; 105 tests): all PASS in 6.6s
- Full suite: **8292 tests / 113.7s / 0 failures** (-12.7s vs 1C-ii-a baseline
  126.4s; +3 tests). Wall-time improvement likely from box pattern eliminating
  per-fire struct-copy alloc for widen+narrow paths.

**Drift risks**:
- D-1C-ii-b-1 (retirement obligation): cell+field dual write retires at 1C-iv
  alongside prop-net-hot-fuel field
- D-1C-ii-b-2 (1C-iii scope reduction 11→9): captured in §10.4 + §3 Progress
  Tracker with refreshed line numbers
- D-1C-ii-b-6 (helper asymmetry at #1+#2): documented inline + §10.0.4 F3
- D-1C-ii-b-7 (1C-iii scope boundaries): line 2034 + 3477/3480/3487 NOT
  touched (1C-iii scope respected)
- **D-1C-ii-b-8 NEW** (convergence-check filter as load-bearing invariant):
  future modifications to prop-network-cells semantics OR new scheduler-state
  cells must update the filter

**Process observation**: the F3 audit refinement (helper init-only at #1+#2)
saved ~10-40 LoC of unnecessary refactoring AND preserved the worklist flush
semantic that would have been lost under §10.0.3's symmetric design.
Audit-precedes-implementation paid off again (3rd data point on this watching
pattern).

**Codification candidate (NEW)**: "Cells-map convergence checks must filter
scheduler-state cells per Cell/Propagator/Scheduler Orthogonality." Watching
list; 1 data point.

**Watching list update**: "Audit-driven scope refinements propagate into §10.4
estimates pre-next-sub-phase" now has 3 data points (1C-i ε; 1C-ii-b α; 1C-ii-b
F3) — strong codification candidate; codify after 1 more.

Tracker + dailies updated. β1 lockstep retirement obligation at 1C-iv captured
in §10.4 scope so transitional dual-writes can't drift into permanent
belt-and-suspenders.

Next: 1C-iii (9 check sites; line numbers re-audited at 1C-iii mini-audit).
hierophantos added a commit that referenced this pull request May 17, 2026
…ests (per §10.0.7 α3)

Per §10.0.7 α3 atomicity decision: 1C-vi splits into 2 commits BY KIND.
This is Commit 1 (code additions); Commit 2 (measurement artifacts) follows.

8299 tests / 120.9s / 0 failures (+5 tests vs 8294 baseline; suite within
S1 variance band 119.3s ± 10%).

## What this commit adds

### New: racket/prologos/benchmarks/micro/bench-tropical-fuel.rkt (~430 LoC)

CANONICAL HOME for post-D.4 tropical-fuel production microbenches per §10.0.7
δ2 + η1 (couples F5 stub-reference gap closure + §9.10 Phase 1B implementation
checklist capture + δ allocation verification in one commit).

8 sections:
1. M10 — Residuation operator cost (5 boundary cases; per §9.10)
2. M11 — Tropical tensor cost (3 cases; per §9.10)
3. M12 — SRE domain registration/lookup overhead (per §9.10)
4. Production cell-API per-call cost (C-M7/M8/M13; informational)
4.5. Option 13 deferred-write AMORTIZED cost (Variant A + Variant B
     simulations using REAL production helpers init-fuel-local-var! +
     flush-fuel-local-var!; apples-to-apples comparison with §13.6.A spike's
     W3-O13 amortized-per-fire pattern)
5. Allocation verification (D-1B-ii-3 per §11.3 Phase 1V item #4) — 10k +
   100k decrement runs via bench-mem
6. GC profile (R3-equivalent; 100k decrements via bench-gc) — target ZERO
   major-GC at 100k (matches Pre-0 R3.1 baseline)
7. A7-equivalent high-frequency decrement scaling (1k/10k/100k)
8. R4 — Cell layout cost (compound vs flat tagged-cell-value; per §9.10)

Initial run results captured at session 2026-05-16:
- Algebra primitives: M10 ~2.5 ns; M11 ~0.9 ns; M12 ~9 ns lookup
- Per-call cell-API: C-M7 ~450 ns; C-M13 ~75 ns (informational; per-call
  cost reflects immutable interface overhead — what Option 13 amortizes)
- Option 13 amortized (production): Variant A 6.82 ns/cycle at N=100; 1.72
  at N=1000 (parallel BSP); Variant B 7.38 ns/cycle at N=100; 2.94 at
  N=1000 (sequential)
- Spike reference: §13.6.A W3-O13a.2 = 2.16 ns/cycle (MOCK; CHAMP-free)
- Production overhead = amortized - 2.16 ns ≈ 3-5 ns (CHAMP cell-meta
  lookup + immutable interface)
- GC: 0.000 ms major-GC at 100k (matches R3.1 baseline ✓)

Detailed A/B/C analysis + verdicts go in Commit 2's report doc.

### test-tropical-fuel.rkt: +3 tests

- γ3-b (1) "exhaustion at zero remaining; cell value AT exhaustion equals 0"
  — verifies Option A semantic (cells store REMAINING; cell at exhaustion = 0)
- γ3-b (2) "on-write predicate fires structurally at (<= new 0)"
  — verifies the D.4 §4.6 cell-layer predicate semantic (no separate
  threshold propagator; boundary cases: positive remaining, exactly 0,
  negative over-drain)
- δ3 "0-allocation regression gate (D-1B-ii-3 / Phase 1V item #4)"
  — catches future allocation regression at suite-run time; threshold
  conservative per D-1C-vi-2 (5× current observed; ~400 bytes/dec baseline;
  alarm at 2000 bytes/dec)

40/40 tests pass in test-tropical-fuel.rkt.

### test-elaboration-parity.rkt: +2 tests (γ3-a)

New "Phase 1C-vi — tropical-fuel-counter-parity (D.4 reframed; §15 axis)"
section with 2 active parity-test cases:

- 'tropical-fuel-simple-arithmetic — [int+ 2 3] → 5
- 'tropical-fuel-polymorphic-id — [(fn [x] x) 3N] → 3N

Under D.4 reframing (per §10.0.7 F9): OLD struct-field counter RETIRED at
1C-iv-b; live A/B parity impossible; "parity" reframes to regression-vs-
historical-baseline. These tests assert SMALL representative elaboration
outputs (single expressions; NOT the full 28-command probe — that's handled
at Commit 2's probe + acceptance run).

16/16 parity tests pass.

## Cross-references

- §10.0.7 (this addendum's 1C-vi mini-design + mini-audit; commit 67448ca)
- §10.4 1C-vi sub-phase plan
- §13.6.A Option 13 spike result (commit 77daf81)
- §13.7 per-phase measurement plan (1C-vi row)
- §15 parity test skeleton (tropical-fuel-counter-parity axis)
- §9.10 Phase 1B implementation checklist (M10/M11/M12/R4 captures — closed
  here via δ2 + η1 coupling)
- F5 mini-audit finding (bench-tropical-fuel.rkt stub-reference gap — closed)

## Drift risks addressed (per §10.0.7)

- D-1C-vi-1 (A/B/C divergence): bench-tropical-fuel.rkt now produces both
  per-call (informational) and amortized (apples-to-apples with spike)
  measurements; A/B/C report (Commit 2) interprets correctly
- D-1C-vi-2 (regression test threshold): δ3 uses conservative 5× baseline
  threshold (2000 bytes/dec alarm); avoids false positives from variance
- D-1C-vi-4 (new infrastructure correctness): bench-tropical-fuel.rkt
  patterns mirror bench-specialized-cell-spike.rkt's bench-mem/bench-gc/
  bench-ns macros (per design); cross-checked with 1B-iv test fixtures

## Tests rationale

3 new behavioral tests (γ3-b × 2 + δ3) + 2 new integration tests (γ3-a × 2)
= +5 suite-level tests. All exercise NEW behaviors:
- γ3-b: behavioral contract under D.4 cell-mechanism
- δ3: regression gate at suite-run time
- γ3-a: representative workload parity vs historical baseline
hierophantos added a commit that referenced this pull request May 17, 2026
…context preserved

Per user direction: fork back to last fork-point (75d0c47) and re-gain context
from this checkpoint forward. This commit captures comprehensive session arc
state in the dailies so the next session has complete re-entry pointers
regardless of fork-back-and-re-execute OR fork-forward path.

## What this FORK CHECKPOINT preserves

### Session arc commits (since prior FORK CHECKPOINT 1b8e16a)

4 substantive commits:
- 67448ca §10.0.7 1C-vi mini-design + mini-audit (7 resolutions; 9 audit
  findings; 5 drift risks; 2 NEW codification candidates)
- aa0bbe4 1C-vi Commit 1 code additions (bench-tropical-fuel.rkt ~430 LoC +
  γ3-a/γ3-b/δ3 tests; 8299/120.9s/0 failures)
- ee5010c 1C-vi Commit 2 measurement artifacts (A/B/C report ~340 lines +
  3 data files + production-realistic-N + probe wall +19.2% finding + Issue
  #63 + multi-surface tracking; Phase 1C CLOSED)
- 4061afc §7.7 1A-iii-b mini-design + mini-audit (5 resolutions + 12 audit
  findings incl. 2 CRITICAL inversions; 3 non-optional design doc
  corrections; 5 drift risks; 3 NEW codification candidates)

### Cumulative architectural state captured

**Phase 1C COMPLETE**: D.4 cell-as-canonical fully realized + A/B/C report
grounding production reality (Option 13 amortization is N-dependent;
production median N=3 vs synthetic N=100; per-call cell-API ~450 ns
dominated by 3-level nested struct-copy NOT CHAMP lookup; probe wall +19.2%
at upper-ceiling of §11.3 target; GC profile intact)

**Phase 1A-iii-b PRE-IMPLEMENTATION COMPLETE**: mini-design+audit done;
implementation BLOCKED on 1A-iii-c (per α audit-inverted ordering);
ε1 single atomic commit (~300-450 LoC pure deletion) ready

**Phase 1A-iii-c**: NOT YET OPENED (next-session task)

**Phase 1V**: expanded scope — item #1 (merge-fn cache) + NEW item #1-bis
(fuel-cell direct-ref cache; surfaced from user question at 1C-vi Commit 1
checkpoint) + item #3 (SRE property-sweep conditional) + item #4 ✅
COMPLETED at 1C-vi

**Multi-surface tracking discipline established** (per user β resolution):
Issue #63 + MASTER_ROADMAP forward-refs at OE Series Track 1 + PReduce
Track 4 + DEFERRED.md, all cross-referenced

### Net delta this session arc

- +5 tests (8294 → 8299)
- +20s wall (within S1 variance band 119.3s ± 10%)
- +1 phase sub-phase complete (1C-vi closes Phase 1C)
- +160 lines design doc (§7.7 + §7.8)
- +5 NEW codification candidates surfaced (2 from 1C-vi + 3 from 1A-iii-b)

### Re-entry pointers (for fresh session)

5-step orientation:
1. Read this dailies in full (start from prior FORK CHECKPOINT through this)
2. Read design doc (§3 Progress Tracker + §7 + §7.7 + §7.8 + §8 + §10.0.7 +
   §11.3 + A/B/C report)
3. Read 1C-vi A/B/C report (docs/tracking/2026-05-16_TROPICAL_1C_VI_ABC_REPORT.md)
4. Re-execute OR fork-forward (commit replay sequence captured)
5. Verify recent commits (5 named for post-4061afcb verification)

### Pending decisions / open items

- IMMEDIATE next-session task: 1A-iii-c mini-design+audit OPENING
  (surface ATMS AST 14-file pipeline retirement; ~600-1000 LoC; 3 open
  questions Q-1A-iii-c-1/2/3 from §8.6)
- Audit findings inherited: test-atms.rkt OUT of 1A-iii-c scope (per F10);
  pretty-print.rkt:502 retires HERE; trace-serialize.rkt atms-event:* are
  SEPARATE struct family — preserved
- Then sequence: 1A-iii-b implementation (unblocked) → Phase 1V VAG

### Suite state

8299 tests / 120.9s / 0 failures (unchanged this commit — docs-only).

## Files changed

- docs/tracking/standups/2026-05-13_dailies.md: FORK CHECKPOINT entry
  (~170 lines) appended at end

No code changes; no design doc changes (design doc + commit messages
already capture state; this FORK CHECKPOINT consolidates the narrative
for re-entry).

No tests needed: dailies-only commit; no behavioral change.
hierophantos added a commit that referenced this pull request May 24, 2026
…entation pending next session

Strong checkpoint entry for 2026-05-20 session close:
- Current HEAD: df9dacc (PM 13 + 2A.b mini-design captured)
- Suite: 8228 / 109.1s / 0 failures (last measured 2A.a close)
- Phase 2A.b: 🔄 mini-design + audit complete; implementation PENDING

Includes:
- Status matrix across all addendum phases
- 3 NEW architectural deliverables summary (PM 13, Parent Design Doc Phase 4 update, §8.7.b)
- Operational principle codified: "off-network ≡ scaffolding"
- 8-step implementation plan from §8.7.b.9 with file:line references
- 8 drift risks from §8.7.b.8 to scrutinize
- Tasks status carried forward (#4 ✅ / #5 🔄 / #6 ⬜)
- Key reference docs ordered for next-session hot-load
- 4 critical context items NOT to lose (handler-as-scaffolding is PM 13 scope;
  box-bridge is structural scaffolding; adversarial 3-column framing discipline;
  operational principle for decision-making)
- 6 codification candidates watching list

Rationale for checkpoint: context budget pressure after substantial design
work (mini-design + audit + PM 13 capture + Parent Design Doc update +
§8.7.b persistence). Implementation requires another ~95-110 LoC + test
rewrite + validation cycles. Cleaner to land in fresh session per Stage 4
"conversational implementation cadence" — checkpoint surfaces what was built,
what's next.

Next session: hot-load HANDOFF_PROTOCOL → read §8.7.b → execute 8-step
implementation list → validate → close 2A.b.
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.

3 participants