Repository navigation
release: v3.7.0 - #92
Merged
Merged
Conversation
…null-export fix (v3.7.0)
Read gating (on by default when permissions is configured)
----------------------------------------------------------
The permission system previously enforced only at call sites — every inter-module
call went through applyTrap, but reading a non-function value off a module path
(self.db.secrets.token) bypassed enforcement because a data value has no
invocation step. A module exporting a Buffer, TypedArray, Date, or primitive
was effectively unprotected across self.* paths.
getTrap now consults the PermissionManager at every terminal-value return site.
runtime_enforceReadGate classifies the returned value (primitives, null, Buffer,
every TypedArray view, ArrayBuffer, DataView, Map, Set, WeakMap, WeakSet, Date,
RegExp, Promise, Error) and calls enforceAccess with the leaf path. Plain
objects, arrays, and functions are left alone — they become child wrappers and
go through call-gating as before. Namespace traversal stays ungated, external
user-code reads are exempt (no caller context), and the self-call bypass still
applies. The waiting-proxy resolver captures the caller at proxy-creation time
and reuses the helper, so lazy reads are gated identically to eager reads.
permissions.readGating defaults to true; readGating: false opts out and
restores pre-v3.7.0 call-only behavior. PermissionManager gained #readGating,
isReadGatingEnabled(), and setReadGating(value) (validates boolean, does NOT
clear the resolved cache — the flag only controls whether reads consult rules).
Runtime toggle
--------------
api.slothlet.permissions.control.readGating(true|false) flips gating after
init, paralleling control.enable()/disable(). control.readGatingEnabled
exposes the current state. Both live on the slothlet.permissions.control.*
namespace — deny-by-default for modules, callable from external app code.
Built-in lockCaller / bind allows
---------------------------------
slothlet.lockCaller and slothlet.bind are now allow-listed by default for all
callers. They pin caller identity onto callbacks — they grant no
security-sensitive access and only strengthen enforcement, so the boilerplate
allow rule every defaultPolicy:"deny" config previously needed is gone. A more
specific user rule still overrides. Joins the existing built-in deny on
slothlet.permissions.control.**.
Bug fix: null module export
---------------------------
A module exporting bare null (export const x = null) was surfacing on the API
as an empty object {}. Every other primitive (string, number, boolean, bigint,
symbol) and undefined exposed faithfully; only null was altered, because
typeof null === "object" sent it down the object-wrapping path in
___createChildWrapper. Fix: store bare null unwrapped (same handling as
undefined). Affects both eager and lazy modes; independent of permissions.
Docs / repo cleanup
-------------------
- docs/PERMISSIONS.md: new Read-Level Gating section, readGating config row,
control.* table entries, upgrade note, rewritten "Other slothlet.* Routes
Are Gated Too" section covering the lockCaller/bind built-in allows.
- README.md: promoted v3.7.0 to Latest; trimmed from ~1060 lines / 47 KB to
~480 lines / 27 KB by delegating each feature's deep dive to its existing
dedicated doc and rebuilding a comprehensive documentation index. Six
previously-orphaned docs are now linked (CONFIGURATION.md, LIFECYCLE.md,
RELOAD.md, VERSIONING.md, PERMISSIONS-CONDITIONS.md, generated/API.md).
Section order adjusted so content (Error Handling, Production & Development)
precedes the link index.
- docs/MODULE-STRUCTURE.md: new "Loading Pipeline Overview" section housing
the eager/lazy/materialization flow diagram that previously lived inline in
the README.
- Repo-wide markdown unwrap: every .md file had hard-wrapped paragraphs joined
back into single soft-wrapping lines. GitHub callouts (> [!NOTE] / [!TIP] /
[!IMPORTANT] / [!WARNING] / [!CAUTION]) and consecutive bold-label
declarations (changelog **Date** / **Type** / **Branch** triples) are
preserved on their own lines.
Tests
-----
- api_tests/api_test_permissions/db/secrets.mjs — fixtures exporting every
built-in data type (Buffer, every TypedArray, ArrayBuffer, Date, Map, Set,
WeakMap, WeakSet, RegExp, Promise, Error) plus primitives and null.
- api_tests/api_test_permissions/callers/data-reader.mjs — cross-file reader
module exercising self.db.secrets.* reads from a separate caller path.
- tests/vitests/suites/permissions/permissions-read-gating.test.vitest.mjs —
18 tests × 8 configs (eager/lazy × async/live × hooks-on/off) covering the
default-on behavior, opt-out, denied/allowed reads, namespace traversal
stays ungated, external reads exempt, self-call bypass, the cached-value
read path, primitives behind a wrapper, every built-in type gated,
primitives/built-ins returning UNWRAPPED with intrinsics intact, verbose
audit events on denied reads, enabled:false short-circuiting the gate,
context-conditional rules, the control.readGating() runtime toggle in both
directions (plus its non-boolean rejection), and null exposed as bare null.
- tests/vitests/suites/permissions/permissions-builtin-allow.test.vitest.mjs —
slothlet.lockCaller / slothlet.bind allowed under defaultPolicy:"deny" with
no rules, other slothlet.* routes staying denied, and a more specific user
deny rule overriding the built-in allow.
- tests/vitests/suites/permissions/permissions-config-validation.test.vitest.mjs —
non-boolean permissions.readGating throws INVALID_CONFIG.
Coverage: 100% statements / 100% branches / 100% functions / 100% lines
(4229 stmts / 3741 branches / 565 fns / 3980 lines). 285/285 vitest suites pass.
…gate attribution The lazy-mode waitingProxyCache was keyed by propChain alone, so two modules touching the same unmaterialized data path before materialization completed would share one cached proxy — pinning the read-gate caller (and audit attribution) to whoever read first. Include the caller's API path in the cache key so each reader gets its own creation-time snapshot.
Fix misleading JSDoc/inline comments that called readGating an "opt-in" flag. Per normalizePermissions defaults, it is on whenever permissions are configured and opted out via `permissions.readGating: false`. Also tidies the read-gating test PRIMITIVES table — marker's `value: undefined` falsely implied the symbol export was undefined; use an `expected: "symbol"` typeof check instead, since slothlet's loader gives a different Symbol instance than a direct ESM import. Regenerated types reflect the updated wording.
… slothlet.permissions.control
Context-bypass: the waitingProxyCache was keyed by caller + propChain
only, so the same module reading the same unmaterialized path under two
different context.run({...}, …) scopes would hit the cached proxy from
the first scope. Conditional rules then evaluated against the wrong
context — a potential bypass for context-sensitive permission rules.
Layer a WeakMap<context, Map> on top of the existing per-caller key so
each request context gets its own bucket; cache entries are GC'd when
the context is unreachable.
Typedef: add the slothlet.permissions.control namespace to SlothletAPI
so TS consumers can call the new readGating()/readGatingEnabled members
(plus existing enabled/enable/disable) without type errors.
Drive-by: clarify the remaining "opt-in" JSDoc wording on
runtime_enforceReadGate and the data-reader-b.mjs comment so both
describe the actual mechanism (per-caller cache key + per-context
bucketing).
Shinrai
approved these changes
May 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
🐛 Bug Fixes
🔧 Other Changes
👥 Contributors
Avg: 100.0% ·
9517625· Node lts/*