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(wrapper): let a member named like a wrapper property win, and refuse then by name - #580
This rejects then only when it comes from a scanned file/folder name. A module can still declare a named then export because extractExports() only rejects framework-reserved keys; after composition, the wrapper get trap unconditionally returns undefined for then, so that export is silently unreachable despite the new documentation saying then cannot be any member name. Reject the export key as well and add eager/lazy coverage.
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Copilot review 5458921724, "Previously missed: Named then exports remain silently unreachable" (src/lib/processors/loader.mjs:517): addressed in 07437148.
The export was not merely unreachable: a module exporting then hung slothlet() indefinitely in eager and lazy mode, ESM and CommonJS alike (already the case on next). Its namespace is thenable, so awaiting it calls the module's then.
then is now a reserved export name. A CommonJS module exporting it is refused with MODULE_RESERVED_EXPORT in #loadCJSIsolated, before the namespace is awaited, and extractExports refuses it alongside the framework-reserved keys. Tests cover a CJS fixture across the matrix plus extractExports directly.
An ES module exporting then cannot be refused by name, because import() calls its then before any export is visible. Importing through a wrapper module would avoid that, but it would move every module load outside the runner's module graph (vitest/coverage, instance import hooks, customImport, browser CSP), so it is not done. docs/MODULE-STRUCTURE.md documents the limitation.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Lazy reloads lose member metadata, and same-named nested directories are incorrectly omitted.
0 open findings
Previously missed (1)
In code that hasn't changed since last review
Lazy folder drops same-named subdirectories
src/lib/builders/modes-processor.mjs:247
#folderMemberNames also drops a same-named subdirectory, but only a same-named file is flattened into the folder. During lazy materialization, a same-named subdirectory is explicitly treated as a legitimate nested namespace (see the populateDirectly guard around lines 1893–1900). For a structure such as name/name/get.mjs, the outer lazy wrapper therefore omits its real name member and answers its own "name" string instead, so the child cannot be reached before some other access materializes the parent. Filter self-named files only; retain every directory name.
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Copilot review 5459561968, "Previously missed: Lazy folder drops same-named subdirectories" (src/lib/builders/modes-processor.mjs:247): not changed in this PR.
The cited structure (name/name/get.mjs) does not reach x.name.name in lazy mode for a reason unrelated to name. On next, lazy mode flattens any folder whose only entry is a same-named folder (x/foo/foo/get.mjs composes x.foo.get lazily, x.foo.foo.get eagerly). That eager/lazy divergence is pre-existing and is filed as #581, with the fix on its own branch. Modelling it in the member-name list here would only duplicate the composition rules.
Validate then exports across synthetic and default paths
src/lib/processors/loader.mjs:1145
This check does not cover every export shape that becomes API members. Synthetic leaves bypass extractExports entirely (modes-processor.mjs:480–482), so api.add("svc", { exports: { then() {} } }) is accepted, while the wrapper's unconditional then trap makes that export unreachable. Likewise, export default { then() {} } presents only default in this loop, then the default object's own then is adopted as a child. Validate composed export/member names in the shared regular/synthetic processing path (while retaining the early CJS guard that prevents assimilation hangs).
Previously-missed finding from the c25f5eff review (loader.mjs:1145, then exports on synthetic and default paths): fixed in d8d1fb88. The wrapper now refuses a then member (MODULE_RESERVED_EXPORT) where it adopts its impl's members, the one point every member goes through. That covers a default object's or default function's own then, a key of an exported object, and an api.add() inline exports entry, none of which reach extractExports. The CommonJS load-time guard is unchanged. Covered by the new api_test_reject_then_default fixture (default object, root file, refused at load in both modes) and a synthetic-exports test over the named / default / nested shapes.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Lazy reloads discard fresh member metadata, and deep API paths can still traverse the wrong wrapper through waiting proxies.
0 open findings
Previously missed (1)
In code that hasn't changed since last review
Chained lazy child traversal resolves to the wrong wrapper
src/lib/handlers/api-manager.mjs:1311
This pre-walk does not actually descend through an ordinary unmaterialized lazy child. Reading that child returns a waiting proxy, and resolveWrapper(waitingProxy) maps back to the ancestor wrapper that created it; therefore a following special segment such as name materializes/checks the ancestor, not the child. For an existing outer.inner/ lazy folder with no name member, api.add("outer.inner.name.deep", …) still reaches ensureParentPath with inner unloaded, reads its wrapper-owned "inner" name, and rejects the path as non-traversable. Resolve/await chained waiting proxies to their concrete child before testing the next wrapper-answered segment.
… shutdown; refuse a CommonJS Proxy's read `then`
- A path's dispatcher mounts run in order, and each writes only while
its dispatcher is still the path's. A write already under way when
unregister or shutdown lands is taken back out unless a newer
dispatcher was registered for the path since.
- The CommonJS export guard refuses an own `then` whose read is a
function, as the namespace copy reads it, not only one described as
callable: a module.exports Proxy may describe data while its get trap
answers a function.
…ched, and order teardown with the path's mounts
- A mount that fails on boundApi after writing api now removes what it
wrote before rejecting, so rollback never sees a half-mounted
dispatcher.
- teardownDispatcher's removal joins the path's chain: it runs after
any mount in flight, and the path's next mount waits for it, so a
removal that pauses cannot delete a dispatcher registered after it.
…eparator
The separator checks covered only the logical path and the moduleID, so
a versioned add could mount at a path whose tag carried the separator,
which remove() and leaves() split on.
Review 5485616543… follow-up: the latest review on 7e0331ff listed 0 findings, but its summary noted that version tags can still inject the reserved composite-key separator into effective API paths.
Fixed in 0dc798fa. Reproduced: api.slothlet.api.add("auth", dir, {}, { version: "v__slothlet_sep__x" }) mounted, with or without an explicit moduleID, because the separator checks covered only the logical path and the moduleID. remove() / leaves() split their argument on the separator, so that mount path could be split to another module's id. A tag holding the separator is now refused with INVALID_CONFIG_API_PATH_INVALID (API_PATH_REASON_RESERVED_SEPARATOR, segment index 0), and the api is left unchanged. Test: versioning-conflict "refuses a version tag holding the reserved moduleID separator", with and without a moduleID, all 8 configs; both failed before.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
It changes foundational proxy and dispatcher invariants, and dotted version-tag dispatch still lacks an end-to-end regression test.
0 open findings
Previously missed (1)
In code that hasn't changed since last review
Add end-to-end test for dotted version tag dispatch
src/lib/handlers/api-manager.mjs:1921
The new atomic mount handling for dotted version tags is not exercised end-to-end. The existing 2.0.0 test only checks versioning.list("auth"); it never invokes api.auth, so a regression that mounts or resolves the value through split segments would still pass. Please add a test that registers a dotted tag and calls the logical dispatcher.
Review on 0dc798fa, previously missed item "Add end-to-end test for dotted version tag dispatch" (src/lib/handlers/api-manager.mjs:1921): added in a24a5d78. versioning-default-auto "mounts a dotted version tag as one segment and dispatches the logical path to it" registers 1.0.0 and 2.0.0 and checks that:
… module fails both modes
The inspector's materialize step only touched nodes whose function name
contained "lazy", so a lazy api was compared before its modules loaded.
A fixture refusing a module at load (#580's MODULE_THENABLE_EXPORT
fixtures) then failed eager and looked loaded in lazy. Every lazy node is
now awaited, recursively, and a refusal surfaces as the api's load error,
which the structure test compares across modes.
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
thenby name #580) (0dc798f)thenby name #580) (7e0331f)then(fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (30e1a2e)thenby name #580) (e54cbbe)thenby name #580) (637c573)thenon paths, refuse assigned thenables, and keep sealing caller-independent (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (b8b9c5b)then, keep a frozen callable node gated, and carry a lazy self-named node's siblings (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (a7894e0)then(fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (cca46b1)thenby name #580) (a32227a)thenby name #580) (ed5a87c)thenby name #580) (5622c42)thenby name #580) (9b279e9)thenby name #580) (b210f97)thengetter without running it (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (29e0d85)thenby name #580) (5c5587c)thenby name #580) (e1772cb)thenwrites, a staticthen, and reach a callable folder's name/length/prototype members (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (5a5f6ec)thenon a module's default too (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (72771f4)thenon lazy folder values and keep its error code (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (78a053d)thenby name #580) (6bcd52c)thenmember on every shape that becomes an api member (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (16133fd)thenby name #580) (59cbaff)thenas an export name instead of hanging the load (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (2b667b9)thenby name #580) (cda9e41)thenby name (fix(wrapper): let a member named like a wrapper property win, and refusethenby name #580) (28c7530)📦 Dependencies
No dependency updates
🔧 Other Changes
thenby name #580) (a24a5d7)thenby name #580) (6f4a64f)thenby name #580) (ba3d04c)👥 Contributors