Skip to content

Execute new-space through compiled function calls - #327

Open
godelclaw wants to merge 1 commit into
trueagi-io:mainfrom
godelclaw:fix/new-space-main-20261116
Open

godelclaw wants to merge 1 commit into
trueagi-io:mainfrom
godelclaw:fix/new-space-main-20261116

Conversation

@godelclaw

Copy link
Copy Markdown

On main, (= (make-space) (new-space)) returns the unevaluated new-space
expression. Using that result with add-atom then raises an atom type error.
Register new-space as a runtime operation with a Symbol result and
deterministic cardinality, so ordinary, computed and strict-det factory
calls allocate fresh spaces.

Use the private atomic-counter allocator from stable PR #321, including
occupied-name checks and handles that cannot collide with a literal space
symbol. It keeps the existing Symbol representation without retaining every
unused handle in a registry.

A main-specific cache safeguard leaves loads that allocate spaces uncached:
replaying a captured handle without advancing the allocator could reuse that
handle. Files that only define a factory remain cacheable. The safeguard adds
two counter reads on a cache miss and no work to the cache-hit path.

Validation against upstream main ee5cacb:

  • test.sh passes: 334 positive examples, 169 expected failures, all matrices;
    its optional tilepuzzle oracle comparison reaches its existing timeout.
  • Five lifecycle/occupancy tests, 16 ordinary assertions, three assertions
    under each of --strict and --strict-det, and two expected Symbol/Grounded
    mismatches pass on SWI-Prolog 10.1.9 and 10.1.20.
  • Python: 21 passed, including both new cache tests. The existing local
    test_second_load_replays_the_snapshot failure also occurs on unchanged main.
  • Eight concurrent Prolog threads allocate 80,000 distinct handles. Sampled
    unrelated scalar/data-head/computed-call inference counts match main.

Register fresh Symbol handles using the existing private atomic-counter allocator, skipping occupied predicate, primitive-row and import-state names. Declare its builtin signature and deterministic cardinality without adding a per-handle registry or metatype lookup.

Do not snapshot a load that allocates fresh spaces: the counter is outside the cached runtime state. Loads defining factories without allocating remain cacheable. Cover ordinary, computed, strict-det and cached-load routes, Symbol/Grounded behavior, handle lifetime and occupancy.
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