Skip to content

release: v3.7.0 - #92

Merged
Shinrai merged 5 commits into
masterfrom
release/3.7.0
May 20, 2026
Merged

Shinrai merged 5 commits into
masterfrom
release/3.7.0

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

  • feat: read-level permission gating, lockCaller/bind built-in allows, null-export fix (v3.7.0) (483b11d)

🐛 Bug Fixes

  • fix(permissions): bucket waiting-proxy cache by request context; type slothlet.permissions.control (9cb20b5)
  • fix(permissions): key waiting-proxy cache by caller for correct read-gate attribution (7821b4a)

🔧 Other Changes

  • docs(permissions): clarify readGating is default-on (not opt-in) (4ec646b)
  • chore: bump version to 3.7.0 (3c06569)
👥 Contributors

coverage

Metric Coverage
Statements 100.0%
Branches 100.0%
Functions 100.0%
Lines 100.0%

Avg: 100.0% · 9517625 · Node lts/*

Shinrai and others added 2 commits May 19, 2026 17:16
…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.
@cldmv-bot cldmv-bot Bot added release Marks a pull request as a pending release — merge to publish a new version semver: minor This release adds new functionality in a backwards-compatible way labels May 20, 2026
@Shinrai Shinrai self-assigned this May 20, 2026
@Shinrai
Shinrai requested a review from Copilot May 20, 2026 00:47
@Shinrai Shinrai linked an issue May 20, 2026 that may be closed by this pull request

This comment was marked as resolved.

…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.

This comment was marked as resolved.

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.

This comment was marked as resolved.

… 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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 47 changed files in this pull request and generated no new comments.

@Shinrai
Shinrai merged commit 1591aba into master May 20, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Marks a pull request as a pending release — merge to publish a new version semver: minor This release adds new functionality in a backwards-compatible way

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: null module export exposed as an empty object {}

2 participants