- Direct protocol package for Forge-local tRPC procedures.
- Current live source footprint is minimal (
index.ts,core/core.router.ts).
core/core.router.tsdefines a singlesyncmutation with runtime guardrails:- rejects empty/whitespace
kindand caps length to 128 chars, - rejects empty
targetsarrays, arrays above 64 entries, and whitespace-only target entries, - rejects overlong target entries (>128 chars),
- rejects duplicate
targetsafter trim normalization, - rejects Unicode control/format characters (
Cc+Cf) in rawkind, target entries, andreasonbefore trim-normalization to avoid hidden payload drift (including invisible format chars) into sync services, - rejects empty/whitespace
reasonand caps length to 512 chars, - rejects unknown input keys via strict schema mode,
- throws a clear error when
ctx.app.service.syncis missing/non-invokable and includes constructor-aware received runtime type diagnostics (undefined,null,object:Object,function:SyncHandler, etc.) for faster configuration debugging, - safely falls back to
object:uninspectable-constructorwhen constructor introspection itself throws, preventing secondary diagnostic crashes while building error messages, - sanitizes constructor-name diagnostics by stripping control/format chars and truncating overly long names to keep missing-handler errors stable and log-safe,
- catches/normalizes accessor failures while reading
ctx.app.service.sync(stable protocol error instead of leaking getter internals) and preserves underlying throwable asError.causefor debuggability, - normalizes trimmed
kind,targets, andreasonbefore service dispatch, - normalizes
kind/targets/reasonto Unicode NFC for stable canonical payload representation, - catches non-
Errorthrowables/rejections fromsyncand emits a stable protocol error with received throwable type details (string,number, etc.) to keep failure shape predictable while improving operator diagnostics.
- rejects empty/whitespace
index.tsexports router helpers and wirescorenamespace; typing remains intentionally loose.- Package test script now runs
"test": "npm run dist && jest --runInBand"so tests always execute against freshly built output and cannot drift from source edits; runnable viarushx test. test/core.router.test.jsnow covers both dispatch behavior and schema-level rejection paths.
- Rejected class constructors as non-invokable sync handlers so
core.syncfails fast with a stable configuration error before runtime invocation throwsClass constructor ... cannot be invoked without 'new'. - Expanded missing-handler diagnostics to include named-function detail (
function:<name>) so operator triage can distinguish plain callable functions from class-constructor wiring mistakes. - Clarified validation error text from
control characterstocontrol/format charactersso operator-facing failures match the actualCc+Cfrejection behavior already enforced in code and tests. - Hardened function-type diagnostics so if reading a handler's
.namethrows (proxy/getter edge cases), the router still reports a stablefunction:uninspectable-nametype instead of crashing while constructing an error message. - Hardened class-constructor detection so
Function.prototype.toStringinspection failures (for example revoked proxies) no longer crash routing logic before normal handler invocation/error flow. - Added explicit
function:anonymousdiagnostics for unnamed class-constructor handlers so missing-handler errors remain actionable even when runtime metadata omits a function name.
- Tightened control-character validation order so raw
kind,targets, andreasonare checked before trim-normalization; this closes a gap where leading/trailing control bytes (for example a trailing newline) could be trimmed away and accepted. - Expanded control-character coverage from ASCII-only to full Unicode
Cccontrols so C1 bytes (for example\u0085) cannot bypass payload/log safety checks. - Extended validation to Unicode format controls (
Cf, for example zero-width space\u200B) so invisible characters cannot bypass payload/log safety checks. - Added NFC Unicode normalization for payload strings so canonically equivalent text (for example
cafévscafe\u0301) is dispatched consistently and duplicate-target detection remains reliable across composition forms. - Updated the package test pipeline to build before Jest, preventing stale
build/artifacts from masking source-level router changes during maintenance runs. - Preserved original throwables in
Error.causefor accessor/read and non-Error sync failures so operators can inspect root cause without losing the stable protocol-facing error message. - Added received-type diagnostics to non-Error sync failure messages (
received string,received number, etc.) so production triage can identify bad throw/reject patterns without spelunking stack traces. - Added explicit received-type diagnostics for missing/non-callable
ctx.app.service.sync(including null/undefined) so environment misconfiguration can be identified directly from protocol errors without extra instrumentation. - Expanded missing-handler diagnostics to include constructor-aware object labels (for example
object:Object) so non-callable object wiring mistakes can be triaged quickly without additional local logging. - Hardened diagnostic type rendering so if a malformed/proxy-like
syncobject throws when reading.constructor, the router still returns a stable missing-handler error (object:uninspectable-constructor) instead of failing during error-message construction. - Simplified router readability per review feedback on PR #2: extracted string validation to
zz.string(...), moved sync input validation intosyncInputSchema, and replaced the inlinesuperRefineduplicate check with a concise schema-levelrefinewhile preserving behavior/messages.
- Tighten
ctxtyping forcore.syncto reduceanyusage without adding unnecessary abstraction. - Add schema tests for
kindnormalization edge-cases and mixed valid/invalidtargetsarrays.