You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: compose the same api in eager and lazy mode, and make the structure check compare them - #585
This now launches the two actual modes, but the assertion still does not compare the printed API Structure tree: extractApiStructure retains only root function metadata and callable paths. An eager result can therefore omit or misplace a primitive/plain namespace key and still pass. Parse and normalize the structure section (or have the tool emit a machine-readable shape) and compare it as part of this parity check.
Previously-missed finding from the 665c0f1b review (all-api-structures.test.vitest.mjs:132, parity test ignores the structure tree): fixed in d8c6b712. inspect-api-structure now prints a mode-neutral API Shape of the loaded api (every key, node kind, callable arity, primitive value; a lazy node is always a function-typed proxy, so the printed tree itself cannot be compared), and the test deep-compares it. Per-load random ids are compared by type only, and a fixture that refuses to load must fail with the same error code in both modes. Before, the error went to stderr and two empty outputs compared equal.
The full comparison found one real divergence, filed as #588 and fixed in a085a4e2: lazy materialize.materialized stayed false and wait() never resolved after a file/folder collision, a reload, or a root shutdown/ folder, because the materialization counter was moved by wrappers that were never counted (or never reachable). All 576 parity cases pass.
Resolves #583, #584, #586, #587, #588 — closed when this ships to the default branch.
Use one consistent own-property conflict check across composition paths
src/lib/processors/flatten.mjs:269
The shared resolver does not actually make every path consistent because its callers use three different conflict predicates: propertyIsEnumerable, key in default, and hasOwnProperty. For example, a non-enumerable own member is overwritten under merge in the addapi/flatten branches, while an inherited class method is treated as a conflict only in the hybrid branches. This contradicts this method’s “same-named own member” contract and makes the result depend on the composition path. Centralize an own-property check (hasOwnProperty) for all call sites before applying the mode.
Previously-missed finding from the 83a1b489 review (flatten.mjs:269, three different conflict checks): fixed in 1e61458e. Probing each shape showed real defects, not just inconsistency:
A default with a non-enumerable, read-only own member plus a same-named named export failed the load ("Cannot assign to read only property"): propertyIsEnumerable missed the member, then the copy's property was assigned.
A class instance's prototype methods never counted, so a named add replaced the instance's add under merge.
On the function-default path implToWrap[key] !== undefined counted Function.prototype's call/bind.
Every path now asks Flatten#defaultHasMember: an own property (enumerable or not) or one a prototype the module defines provides; Object.prototype, Function.prototype and Array.prototype are not the default's members. A named export that wins over a read-only member replaces it (Flatten#assignNamedExport) instead of throwing. The probe also exposed a lazy-only divergence: a class-instance default of a folder's same-named file lost its prototype methods when the folder had a sibling (the materializer rebuilt it as a plain object); it is now composed as the instance, members in eager's order. New fixture api_smart_flatten_default_member_conflict, suite smart-flattening-default-member-conflict (48 tests, all 8 configs). Docs: MODULE-STRUCTURE.md and C19 in API-RULES-CONDITIONS.md.
inspect-api-structure.mjs:403: the compared shape was cut at the display depth, so eager/lazy differences below it compared equal. Fixed in eabc2b38: every lazy node is loaded at any depth first, and the shape is built with no depth limit. maxDepth now applies only to the printed structure and callable list. Test: "compares the whole shape, below the display depth too" (fixture api_test_special_numbers/nested.mjs). The all-api-structures parity suite still passes with the full-depth comparison (736 + 8).
inspect-api-structure.mjs:566: the callable-paths walk skipped every _-prefixed key. Fixed in eabc2b38: only shutdown is skipped, because framework keys are not on the node's surface. Test: "lists an underscore-prefixed function among the callable paths" (api.nested._hidden()).
composition.mjs:33: the module overview still described the array copy as slice(). Fixed in 2c3a8487: it now describes the copy as keeping elements, holes, other own members and descriptors.
The strategy table no longer matches the implementation it documents: plain functions are layered when addsMembers is true, and arrays are copied with all own descriptors rather than via slice. Keeping this table stale makes the helper’s intended identity and descriptor semantics misleading.
composition.test.vitest.mjs:26: the strategy table was out of date. Fixed in da43792d: a plain function gets a callable layer when named exports are added; an array is copied with its elements, holes, other members and descriptors; a composition layer is copied as a fresh layer over the same value.
Also in this push, 9c748287: tests/validate-typestubs.mjs now stages its consumer (core link + carved @cldmv/slothlet-types) in its own temporary project with its own package.json, and type-checks with --preserveSymlinks. It no longer writes into the project's node_modules. When that folder is shared with another checkout, an interrupted run used to leave the staged copy there, and it was picked up by every other checkout, which broke the "absent" case. An existing @cldmv/slothlet link was also reused as-is, even when it pointed at another tree. If the absent case fails, the message now names any copy installed above the project.
The layer forwards getPrototypeOf but has no setPrototypeOf trap. Consequently Reflect.setPrototypeOf(layer, replacement) succeeds by changing only the shell, while Object.getPrototypeOf(layer) still reports the underlying value's prototype; callers receive success for a mutation that is not observable. Refuse prototype changes, as this layer already refuses preventExtensions, because forwarding the mutation would modify the module export.
Layer array subclasses instead of cloning private state
src/lib/helpers/composition.mjs:412
This copies every array by descriptors and then restores its prototype, but that cannot reproduce private fields held by an Array subclass. A default or named export such as class Items extends Array { #tag = "x"; tag() { return this.#tag; } } becomes an Items-looking copy whose tag() throws, just like the class-instance cloning problem this helper avoids. Treat non-plain arrays as stateful instances and layer them instead of copying them.
composition.mjs:351: a layer had no setPrototypeOf trap, so Reflect.setPrototypeOf(layer, other) succeeded but changed only the shell. Fixed in 24d581a2: a change is refused, and setting the prototype it already reports succeeds, as on an object. Test: "refuses changing a layer's prototype…" in helpers/composition.
composition.mjs:412: an Array subclass instance was copied by descriptors, which lost its private fields (tag() threw). Fixed in 24d581a2: it is treated as a class instance, kept as itself and layered when members are added. Only plain arrays are copied. Test: "keeps an Array subclass instance itself…".
Both tests fail before the fix and pass after. The default-shape matrix stays at 168/168.
A lazy node is built on a function target before what it holds is known,
since a folder may turn out callable, and a Proxy's form is fixed when it
is made. Once it loaded a namespace object it stayed a function:
typeof api.deep was "function" where eager reads "object",
Function.prototype.toString accepted it, and calling it threw
INVALID_CONFIG_NOT_A_FUNCTION instead of the engine's TypeError.
A loaded node holding no function is now rebuilt on eager's object
target, as an array or a primitive already was (#585), and put in its
parent in place of the lazy proxy. A reference taken before the load
keeps the lazy proxy, which forwards to the loaded node.
Fixes#811
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area: coreTouches core library / runtime source codearea: testsTouches test files, fixtures, or test infrastructure! fix → nextv4 flow: fix contributor PR targeting the next integration branchtype: documentationRelates to docs, README updates, guides, or inline code comments
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
📦 Dependencies
No dependency updates
🔧 Other Changes
👥 Contributors