Skip to content

chore - the baker rediscovers Incan's own compiler and SDK on every invocation #1546

Description

@dannymeijer

Area

Tooling (CLI/formatter/test runner), Runtime / Core crates (stdlib/core/derive)

Summary

The baker treats Incan as an input to discover, not as a constant

Incan's compiler and SDK reach the baker prebuilt and sealed. The SDK publisher writes sdk-inventory.json and the ten .incnlib provider descriptors together, records a sha256: digest for each provider in the inventory, and places the whole thing in a content-addressed directory whose name is that content's digest. Store entries are the same shape: entries/sha256-<digest>.loaf/loaf.json, where the directory name is the digest of the file inside it.

None of that can change without changing its own name. Yet the baker rediscovers all of it on every invocation.

Sealed identity and verification exist for external, user-provided code — code the baker has genuinely never seen and cannot trust. Incan itself is not in that category, and spending the same machinery on it is a category error rather than a slow path.

Measured

On a warm store, an explicit bake of a trivial project that compiles nothing — it reports action: "toolchain_loaf", so every unit it needs is already present:

  • 1,454 store-manifest reads of 61 distinct files. Every Loaf manifest parsed, schema-checked and re-digested 26 times in one process.
  • 4 complete rebuilds of the SDK provider records — 6 when the bake materializes both profiles, 2 in a plain incan build. Each one re-reads and re-deserializes the whole 6.6 MB provider surface and re-validates all ten descriptors against the inventory that shipped with them.
  • Sampling one profile: discover_for_oven 24% of the run, sdk_provider_records 20%, split between validate_sdk_descriptor (15%) and deserializing the api_metadata surface (14%).

Total wall clock for that no-op bake: 14.1 s with both profiles, 7.0 s narrowed to one.

What has already landed

Three changes take the within-process half of this, and together bring the suite's configuration from 14.1 s to 2.26 s:

All three are process-local memos. They make the rescan cheap. They do not remove it.

What this issue is for

Each bake is a new process that re-establishes the same immutable compiler and SDK from cold. A test file running fifty bakes pays that fifty times, and make with no code changes re-derives it rather than passing straight through.

The shape of the fix is that Incan's own compiler and SDK carry one identity, stamped when they were built, which the baker consumes as given:

  • The verification result for a content-addressed entry is a pure function of a name that is already a digest. It should be written down once, beside the store, not re-derived per process.
  • validate_sdk_descriptor re-establishes agreement between two files the same publisher wrote at seal time. That agreement belongs in the seal.
  • The decoded provider surface is a constant per SDK release. It should be loadable in one read of one pre-decoded artifact rather than ten JSON parses.

The acceptance test is the one stated plainly: with no changes to the compiler, the kernel, or the SDK, an invocation has nothing to establish. Fifty bakes reproduce nothing fifty times.

Scope notes

  • External, user-provided code keeps every check it has today. Nothing here weakens admission of anything the baker did not ship.
  • The store's lease and capacity model is unaffected; this is about what a reader must re-derive, not about what a writer must prove.
  • Concurrency matters: the compiler suite runs many baker processes against one store, so anything persisted has to be written under the existing store locks.

Part of #1037.

Scope

  • In scope: the behaviour described above, and the acceptance stated under Done when.
  • Out of scope: any change to what a reader must prove about admitted code; this is about work that is repeated, not about checks that are owed.
  • Risks: recorded inline above where a measurement or a withdrawal established one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    runtime / core cratesSuggestions, features, or bugs related to the `incan-core`, `incan-stdlib`, 'incan-derive` cratestoolingSuggestions, features, or bugs related to the Tooling (CLI/formatter/test runner)

    Type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions