Skip to content

Scheme host: hydra.lib.* def-modules flat-loaded, shadowing kernel impl calls (self-host gap) #599

Description

@joshsh

Parent: #375 (nearest host-completion umbrella; redirect if a dedicated scheme-completion parent is preferred)

Summary

scheme-to-<target> bootstrap generation fails once the scheme host boots its own kernel with the
primitive registry loaded. The registry (overlay/scheme/libraries.scm) imports each generated
hydra.lib.* PrimitiveDefinition def-module under a def: prefix, but the scheme bootstrap
flat-preloads those def-modules into the global namespace. Their exported hydra_lib_<sub>_<fn>
symbols (PrimitiveDefinition data) then shadow the host kernel's impl calls of the same flat name.

Observed failure

scheme-to-python (bootstrapping demo, full cell):

ERROR: In procedure %resolve-variable:
Unbound variable: def:hydra_lib_chars_is_alpha_num

(and, in the shadowing form: Wrong type to apply: PrimitiveDefinition)

Root cause

The scheme host's form-rewriting flat loader loads every generated module's forms into the global
environment rather than resolving them as real R7RS libraries. The registry references PrimitiveDefinition
data as def:hydra_lib_<sub>_<fn>, but the flat load either doesn't bind the def:-prefixed name, or
binds the plain name and collides with the impl. See the #473-labelled comments at
heads/lisp/scheme/src/main/scheme/hydra/bootstrap.scm:337-339.

Current state / scope

The scheme host is validated only up to generation; the driver lib pass + redirect are unit-tested, and
the #501 overlay-path loaders are fixed, but the def-module resolution is still a flat global load. This is
not CI-gated (run-bootstrapping-demo isn't in CI), so it doesn't block main, but it means scheme is not
a complete self-hosting host.

Fix direction

Resolve hydra.lib.* def-modules as real R7RS libraries (per the env-for-rec dispatch model already used
in overlay/scheme/.../lib/system.scm for run-tests) rather than flat-loading them into
interaction-environment.

Notes

Related known-gap memory: project_473_self_host_lib_pass_gap. The #473 label in the code comments refers
to the refactor that surfaced this, not the issue tracking the fix (this one).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions