Skip to content

refactor: make module imports point one way - #1339

Open
brendanjryan wants to merge 32 commits into
mainfrom
refactor/layering
Open

brendanjryan wants to merge 32 commits into
mainfrom
refactor/layering

Conversation

@brendanjryan

Copy link
Copy Markdown
Collaborator

What

Makes module imports point one way, from low-level modules up to the CLI:

core primitives (src/*.ts) → internal → client / server → methods (tempo, stripe, evm, x402) → adapters → cli

A new src/layering.test.ts enforces this order: core, internal, client and server may not import methods, adapters or the CLI, and validation may not import the CLI. Entry points and barrels (index.ts, bin.ts, client/*, server/*, Methods.ts, client/node.ts) are allowlisted. Type-only imports are ignored.

Fix: mppx/validation loads again

src/validation/core.ts imported validatePaymentFlow from src/cli/validate/payment.ts, which pulls in the CLI's account and config code and incur. incur is bundled into dist/bin.js and isn't a runtime dependency, so in a clean install of 0.21.1, import('mppx/validation') throws Cannot find package 'incur'.

  • The pure checks (challenge, discovery, helpers, messages) move from src/cli/validate to src/validation.
  • Terminal printing moves to src/cli/validate/print.ts. The pc colors move to src/internal/pc.ts, and cli/utils still re-exports pc.
  • validate() and validateStream() take an optional payment: PaymentValidator, and mppx validate passes the CLI's. Without one, the payment phase reports a skipped check instead of paying.

Moves (no behavior change)

From To Why
server/internal/html/* internal/html/* Html.ts and Method.ts (core) imported server internals
server/internal/challengeMeta.ts internal/challengeMeta.ts used by core and by the methods
x402/{Header,Siwx,Types}.ts, x402/internal/ChallengeBrand.ts internal/x402/* internal/AcceptPayment and server/Mppx imported x402/
mcp/internal/Credential.ts internal/McpCredential.ts used by server/Transport
mcp/server/Transport.ts server/internal/mcpSdk.ts server/Transport ⇄ mcp/server/Transport was a cycle

mppx/x402, mppx/mcp-sdk/server and every other export resolve to the same API. mcp/server/Transport.ts remains as a re-export.

Checks

  • pnpm build, pnpm check:types, pnpm check:ci and pnpm check:package pass.
  • vp test --project node --project cli against a Tempo localnet: 4531 passed. The two failures are in src/cli/mcp.test.ts (Linux keyring… text where JSON was expected). They fail the same way on main on this machine, which has no keyring.
  • Packed tarball in a clean project: import('mppx/validation') loads and validate({ skipPayment: true }) runs. mppx, mppx/client, mppx/server, mppx/x402 and mppx/mcp-sdk/server import, and mppx validate --help runs.

The branch has 27 signed commits because the commit API takes a limited payload per call. Squash merge makes them one commit.

mppx/validation imported the CLI's payment flow, which pulled in the bundled incur dependency, so the published entry failed to load. validate() now takes an optional payment validator, and mppx validate passes the CLI's.

Shared HTML payment-page infrastructure, x402 wire helpers and the MCP credential helpers move under src/internal, and the MCP SDK server transport moves under src/server, so core, internal, client and server no longer import methods, adapters or the CLI. A new layering test enforces the order. Public entry points are unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T11:46:22.170760Z ece7ab0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tempoxyz-bot

tempoxyz-bot commented Nov 20, 2026 •

Copy link
Copy Markdown

👁️ Cyclops Security Review

✅ Reviewed a944c6e (latest) · Coverage: partial · ⚠️ 14 open findings · report
⚠️ Not checked: No in-repo library consumer of validateStream with onPaymentResults and an object-returning validator was found. External SDK consumers were not enumerated.
⚠️ Not checked: Batch aggregation of an explicit failed payment: ruled out without reading the cited code at this commit
⚠️ Not checked: Implicit payment when the validation API has no validator: ruled out without reading the cited code at this commit
ℹ️ Not verifiable from the source alone (needs running code or deployed state): The comment-stripping defect was reproduced in isolation, but no packed artifact with a retained forbidden edge was built or imported. A current production import failure is not established. To verify

# Severity Finding Introduced Status
1 🟢 Low validateStream reports custom payment validators as failed without CLI display label ece7ab0 ✅ Fixed in 09e96d2
2 ⚪ Informational Layering test regex misses side-effect and comment-quoted runtime imports ece7ab0 ✅ Fixed in a944c6e
3 ⚪ Informational Layering test misses imports routed through composing entry points 09e96d2 ✅ Fixed in a944c6e
4 🟡 Medium validate() batch result drops a payment validator's explicit succeeded flag 09e96d2 ✅ Fixed in a944c6e
5 🟢 Low Synthesized 'Payment: failed' check is not forwarded to onPaymentResults a944c6e 🟠 Open
6 ⚪ Informational Comment stripping can erase live imports from the layering check a944c6e 🟠 Open
7 ⚪ Informational Layering guard leaves cloudflare and viem unclassified although they import the tempo method layer 343d4b3 🟠 Open
8 ⚪ Informational Layering test skips unclassified layers, missing transitive validation-to-CLI imports ece7ab0 🟠 Open
9 ⚪ Informational Layering check reports erased import type queries as runtime imports ece7ab0 🟠 Open
10 ⚪ Informational Layering test ignores package self-reference imports of forbidden layers ece7ab0 🟠 Open
11 ⚪ Informational Layering test reports imports inside comments and strings as violations ece7ab0 🟠 Open
12 ⚪ Informational Layering test regex scans quote-free source in quadratic time ece7ab0 🟠 Open
13 ⚪ Informational Layering guard misses imports whose specifier uses string escapes ece7ab0 🟠 Open
14 ⚪ Informational Layering test follows symlinks under src and can fail or hang ece7ab0 🟠 Open
15 ⚪ Informational Layering test throws TypeError for directories named like Object properties ece7ab0 🟠 Open
16 ⚪ Informational Layering test misses template-literal and two-argument dynamic imports ece7ab0 🟠 Open
17 🟢 Low Standalone validation suggestions promise wallet provisioning without a payment validator ece7ab0 🟠 Open
18 ⚪ Informational Layering test skips imports in .mts source modules ece7ab0 🟠 Open

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/mppx@1339

commit: a944c6e

Comment thread src/validation/core.ts Outdated
Comment on lines +24 to +37
export type PaymentValidator = (
baseUrl: string,
endpoint: EndpointSpec,
verbose: boolean,
options: {
body?: string | undefined
query?: string[] | undefined
extraHeaders?: string[] | undefined
yes?: boolean | undefined
silent?: boolean | undefined
interactive?: boolean | undefined
onResults?: (results: CheckResult[]) => void
},
) => Promise<CheckResult[]>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low (exposure unconfirmed): validateStream reports custom payment validators as failed without CLI display label

The PR lets library callers pass their own PaymentValidator, but validateStream still derives the payment event's succeeded flag from a passing check labelled exactly 'Payment: successful'. Only the CLI validator emits that undocumented label, so a custom validator returning all-passing checks yields succeeded: false.

Valid? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 09e96d2. A PaymentValidator can now return { results, succeeded }, and validateStream uses that flag directly. A plain array still counts as succeeded only with a passing paymentSuccessLabel check, and that label is now exported. Tests in src/cli/validate.test.ts cover both forms.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addressed in 09e96d2

Comment thread src/layering.test.ts Outdated
Comment on lines +38 to +39
const specifier =
/(?:import|export)(\s+type)?[^'"]*?from\s+['"](\.[^'"]+)['"]|import\(\s*['"](\.[^'"]+)['"]\s*\)/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test regex misses side-effect and comment-quoted runtime imports

The new layering test finds imports with a regex that requires a from clause or a literal import() call. A side-effect import, or a binding import with a quote character before from, never matches, so violations() returns no entry for a forbidden validation-to-CLI edge and the test passes.

Valid? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 09e96d2. The layering test now strips comments first, then matches side-effect imports, dynamic import() calls and binding lists that contain quotes. Type-only imports are still skipped. A new test covers each kind.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addressed in a944c6e

…yering test (1/2)

Cyclops review of ece7ab0:

- A custom payment validator decided success only through the CLI's "Payment: successful" label. Validators can now return { results, succeeded }; a plain array keeps the label rule, exported as paymentSuccessLabel.
- The layering test missed side-effect imports, dynamic import(), and binding lists that contain quotes. It now strips comments and matches all three, with a test for each.
Comment thread src/layering.test.ts
Comment on lines +72 to +85
function violations() {
const found: string[] = []
for (const file of sourceFiles(src)) {
const relative = path.relative(src, file).split(path.sep).join('/')
if (allowed.has(relative)) continue
const layer = layerOf(file)
const rules = forbidden[layer]
if (!rules) continue
for (const specifier of runtimeImports(fs.readFileSync(file, 'utf8'))) {
const target = path.resolve(path.dirname(file), specifier)
if (!target.startsWith(src + path.sep)) continue
const targetLayer = layerOf(target)
if (rules.includes(targetLayer)) found.push(`${relative} (${layer}) imports ${targetLayer}`)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test misses imports routed through composing entry points

The new layering test treats root entry points such as index.ts and bin.ts as core. A constrained module that imports them is never flagged, even though they pull in EVM, x402 or the CLI. As a result, the guard cannot catch a validation-to-CLI edge that goes through bin.ts, which is exactly what it says it prevents.

Valid? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 343d4b3. The composing entry points (index.ts, bin.ts and the client/server barrels) are now their own top layer, and every constrained layer is forbidden from importing it. Adding an import of ../bin.js to validation/core.ts now fails the test with "validation/core.ts (validation) imports entry". A new test pins the layer mapping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addressed in a944c6e

Comment thread src/validation/core.ts Outdated
Comment on lines +212 to +215
const paymentResults = Array.isArray(validation) ? validation : validation.results
const succeeded = Array.isArray(validation)
? validation.some((r) => r.severity === 'pass' && r.label === paymentSuccessLabel)
: validation.succeeded

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium: validate() batch result drops a payment validator's explicit succeeded flag

This PR lets a PaymentValidator return {results, succeeded}, so the outcome no longer has to appear in the checks. validateStream keeps that flag, but validate() saves only the checks for each endpoint and builds the summary from check severities. A validator that reports succeeded false with no failing checks gives the same batch result as a successful payment.

Valid? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a944c6e. validate() now stores the flag as paymentSucceeded on each endpoint. When a validator returns succeeded: false without a failing check, validateStream adds a "Payment: failed" check, so the stream, the batch result and its summary all count the failure. A new test in src/cli/validate.test.ts covers both outcomes through validate().

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addressed in a944c6e

Root entry points such as index.ts and bin.ts compose higher layers. The
layering test now treats them as their own top layer, so a lower module that
imports one of them (for example validation importing bin.ts) fails the test.
…e() (1/2)

validate() now keeps the flag a payment validator returns as paymentSucceeded on each
endpoint. When a validator reports succeeded: false without a failing check,
validateStream adds a "Payment: failed" check, so the stream, the batch result
and its summary all count the failure.
Comment thread src/validation/core.ts
Comment on lines +224 to +236
// A validator that reports failure without a failing check still fails the run.
if (
!Array.isArray(validation) &&
!succeeded &&
!paymentResults.some((r) => r.severity === 'fail')
)
paymentResults = [
...paymentResults,
fail(
'Payment: failed',
'the payment validator reported that the payment did not succeed',
),
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low (trigger unconfirmed) · unverified: Synthesized 'Payment: failed' check is not forwarded to onPaymentResults

Mechanism: when a custom PaymentValidator returns {results, succeeded:false} with no failing check, validateStream (src/validation/core.ts:224-236) appends fail('Payment: failed', ...) to the yielded event's results. It never calls options.onPaymentResults with that check.

Full finding

Mechanism: when a custom PaymentValidator returns {results, succeeded:false} with no failing check, validateStream (src/validation/core.ts:224-236) appends fail('Payment: failed', ...) to the yielded event's results. It never calls options.onPaymentResults with that check. The sibling branch that synthesizes a result for a missing validator does forward it (core.ts:207, onResults?.(results)), which shows the core is responsible for forwarding its own synthesized results to the streaming callback. Trigger: a library caller uses validateStream with onPaymentResults and a validator that returns the object form with succeeded:false. Impact: streaming consumers that follow the reference CLI pattern, counting and printing payment checks only through onPaymentResults (src/cli/validate/index.ts:84, 125-127), never see the failure. Their failure tally and output show a failed payment with zero failing checks, which contradicts the comment's promise that the run 'still fails'. Batch validate() and consumers that read event.results do see it. Preconditions: the shipped CLI is unaffected because validatePaymentFlow returns CheckResult[] (payment.ts:178-192). The defect needs an object-returning custom validator together with onPaymentResults. Remediation: call options.onPaymentResults?.([failCheck]) when appending the synthesized check, mirroring the no-validator branch. Alternatively, document that onPaymentResults only carries validator-emitted checks and that consumers must also read event.results.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +46 to +54
/** Removes comments so imports quoted in them are not counted (and cannot hide real ones). */
function stripComments(code: string) {
return code.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:'"\\])\/\/.*$/gm, '$1')
}

/** Relative module specifiers that create runtime edges. Type-only imports are erased at build time. */
function runtimeImports(code: string) {
const found: string[] = []
for (const match of stripComments(code).matchAll(specifier)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational · unverified: Comment stripping can erase live imports from the layering check

The new stripComments pass treats any /* through the next */ as a comment, even when both delimiters are inside ordinary string literals. For example, in a scanned validation source file, put const opening = '/*' before import { validatePaymentFlow } from '../cli/validate/payment.js' and const closing = '*/' after it.

Full finding

The new stripComments pass treats any /* through the next */ as a comment, even when both delimiters are inside ordinary string literals. For example, in a scanned validation source file, put const opening = '/*' before import { validatePaymentFlow } from '../cli/validate/payment.js' and const closing = '*/' after it. The import is valid and remains live in TypeScript, but the exact regexes report its specifier before stripping and return no specifier after stripping. The forbidden validation-to-CLI rule is therefore never applied. This requires a source change, not a remote payment request. If such an import ships and is retained in the validation build, its CLI account dependency can make the public validation entry fail to load on installations without incur. No such shipped edge was demonstrated. Replace the source-text stripping and matching with TypeScript-aware syntax parsing, and add a regression fixture with a real import between string literals containing the comment delimiters.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +77 to +93
function violations() {
const found: string[] = []
for (const file of sourceFiles(src)) {
const relative = path.relative(src, file).split(path.sep).join('/')
if (allowed.has(relative)) continue
const layer = layerOf(file)
const rules = forbidden[layer]
if (!rules) continue
for (const specifier of runtimeImports(fs.readFileSync(file, 'utf8'))) {
const target = path.resolve(path.dirname(file), specifier)
if (!target.startsWith(src + path.sep)) continue
const targetLayer = layerOf(target)
if (rules.includes(targetLayer)) found.push(`${relative} (${layer}) imports ${targetLayer}`)
}
}
return found
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test skips unclassified layers, missing transitive validation-to-CLI imports

The new layering test checks only direct imports and skips every file whose top-level directory has no rule, without reading it. src/validation/core.ts imports src/discovery/Validate.ts at runtime, and discovery has no rule, so a CLI import added there passes the test. The head tree contains no such edge. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +20 to +29
const methods = ['tempo', 'stripe', 'evm', 'x402', 'integrations']
const adapters = ['cli', 'middlewares', 'proxy', 'mcp', 'validation', 'extensions']

const forbidden: Record<string, readonly string[]> = {
core: ['client', 'server', ...methods, ...adapters, 'entry'],
internal: ['client', 'server', ...methods, ...adapters, 'entry'],
client: [...methods, ...adapters, 'entry'],
server: [...methods, ...adapters, 'entry'],
validation: ['cli', 'entry'],
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational · unverified: Layering guard leaves cloudflare and viem unclassified although they import the tempo…

Mechanism: src/layering.test.ts is meant to keep core, internal, client and server free of methods, adapters and entry points. This push added the 'entry' class for composing entry points. However, the forbidden map (lines 20-29) lists method and adapter directories by name. src/cloudflare and src/viem are in neither list, and layerOf (lines 62-66) gives them their own directory names as layers.

Full finding

Layering guard leaves cloudflare and viem unclassified although they import the tempo method layer

Mechanism: src/layering.test.ts is meant to keep core, internal, client and server free of methods, adapters and entry points. This push added the 'entry' class for composing entry points. However, the forbidden map (lines 20-29) lists method and adapter directories by name. src/cloudflare and src/viem are in neither list, and layerOf (lines 62-66) gives them their own directory names as layers. Both directories import the tempo method layer at runtime: src/cloudflare/Channels.ts:6-15 imports tempo/internal/proof.js, tempo/session/precompile/Protocol.js and tempo/session/server/CloseSupervisor.js, and src/viem/Client.ts:6 imports tempo/internal/remote-fee-payer.js. Trigger: a core, internal, client, server or validation module adds import ... from '../viem/Client.js' or '../cloudflare/index.js'. The edge has target layer 'viem' or 'cloudflare', which is in no forbidden list, so violations() returns nothing and the test passes. The lower layer still pulls the tempo method in at runtime. Impact: the guard misses the cross-layer dependency it exists to catch. For example, mppx/server or mppx/client could start bundling tempo session and precompile code, or the validation entry could pick up method dependencies, with no failing test. This is the same gap the entry-layer fix closed for index.ts and bin.ts, here in a sibling population. Evidence: E1-E5. Preconditions: a future edit adds such an import. A repository-wide grep found no current core, internal, client, server or validation import of viem/ or cloudflare/, so nothing is violated today. Remediation: classify every top-level directory under src/ explicitly, with cloudflare and viem at the method level (add them to methods) and discovery and identity at their intended level. Also make the test fail when layerOf returns a directory missing from the classification, so new directories cannot go unchecked.

First reported at 343d4b3; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +43 to +44
const specifier =
/\bimport\s*['"]([^'"]+)['"]|\b(?:import|export)\b(\s+type\b)?(?:[^;'"=()]|'[^']*'|"[^"]*")*?\bfrom\s*['"]([^'"]+)['"]|\bimport\(\s*['"]([^'"]+)['"]\s*\)/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering check reports erased import type queries as runtime imports

The layering test added in this PR skips import type declarations as erased, but its dynamic-import pattern also matches inline import types such as typeof import('../cli/config.js'). Those emit no JavaScript, yet violations() reports them as forbidden runtime edges. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +52 to +60
function runtimeImports(code: string) {
const found: string[] = []
for (const match of stripComments(code).matchAll(specifier)) {
if (match[2]) continue
const target = match[1] ?? match[3] ?? match[4]!
if (target.startsWith('.')) found.push(target)
}
return found
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test ignores package self-reference imports of forbidden layers

The new layering test only inspects dot-prefixed import specifiers. A value import of the CLI layer through the package's own export name, such as 'mppx/cli' or 'mppx/cli/plugins', from src/validation is never classified, so the test passes on a tree it is meant to reject. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +43 to +49
const specifier =
/\bimport\s*['"]([^'"]+)['"]|\b(?:import|export)\b(\s+type\b)?(?:[^;'"=()]|'[^']*'|"[^"]*")*?\bfrom\s*['"]([^'"]+)['"]|\bimport\(\s*['"]([^'"]+)['"]\s*\)/g

/** Removes comments so imports quoted in them are not counted (and cannot hide real ones). */
function stripComments(code: string) {
return code.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:'"\\])\/\/.*$/gm, '$1')
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test reports imports inside comments and strings as violations

The new layering test matches import specifiers against raw file text, so import-like text in a comment, JSDoc example, string or template literal counts as a dependency. A ruled-layer file that only mentions a forbidden layer's relative path this way fails the test without importing anything. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +43 to +44
const specifier =
/\bimport\s*['"]([^'"]+)['"]|\b(?:import|export)\b(\s+type\b)?(?:[^;'"=()]|'[^']*'|"[^"]*")*?\bfrom\s*['"]([^'"]+)['"]|\bimport\(\s*['"]([^'"]+)['"]\s*\)/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test regex scans quote-free source in quadratic time

The specifier regex that violations() runs over every eligible source file restarts a lazy scan to the next quote from each import or export token. A quote-free file with many such tokens costs quadratic time: 458,769 bytes took 5.2 s, against 0.13 ms for same-size text without tokens. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +43 to +44
const specifier =
/\bimport\s*['"]([^'"]+)['"]|\b(?:import|export)\b(\s+type\b)?(?:[^;'"=()]|'[^']*'|"[^"]*")*?\bfrom\s*['"]([^'"]+)['"]|\bimport\(\s*['"]([^'"]+)['"]\s*\)/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering guard misses imports whose specifier uses string escapes

The layering test extracts import specifiers with a regex and resolves the raw quoted text without decoding string escapes. An import written '../\u0063li/validate/payment.js' loads ../cli/validate/payment.js at runtime, but the guard computes the layer '\u0063li' and reports nothing. No file at the pinned commit uses such a spelling.

Full finding

The layering test extracts import specifiers with a regex and resolves the raw quoted text without decoding string escapes. An import written '../\u0063li/validate/payment.js' loads ../cli/validate/payment.js at runtime, but the guard computes the layer '\u0063li' and reports nothing. No file at the pinned commit uses such a spelling.

First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +68 to +75
function* sourceFiles(dir: string): Generator<string> {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const file = path.join(dir, entry.name)
if (entry.isDirectory()) yield* sourceFiles(file)
else if (/\.tsx?$/.test(entry.name) && !/\.(test|test-d|gen)\.tsx?$/.test(entry.name))
yield file
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test follows symlinks under src and can fail or hang

The walker in src/layering.test.ts yields every non-directory entry ending in .ts or .tsx, including symbolic links, and violations() opens each with readFileSync. A link under a checked layer makes the test parse a file outside src, throw ENOENT when the link dangles, or block when the target never returns EOF. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +23 to +29
const forbidden: Record<string, readonly string[]> = {
core: ['client', 'server', ...methods, ...adapters, 'entry'],
internal: ['client', 'server', ...methods, ...adapters, 'entry'],
client: [...methods, ...adapters, 'entry'],
server: [...methods, ...adapters, 'entry'],
validation: ['cli', 'entry'],
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test throws TypeError for directories named like Object properties

The layering test looks up each source layer in a plain object and checks only truthiness. A top-level src directory named constructor, __proto__ or toString resolves to an inherited Object.prototype member, so the test throws instead of skipping the unlisted layer. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +43 to +44
const specifier =
/\bimport\s*['"]([^'"]+)['"]|\b(?:import|export)\b(\s+type\b)?(?:[^;'"=()]|'[^']*'|"[^"]*")*?\bfrom\s*['"]([^'"]+)['"]|\bimport\(\s*['"]([^'"]+)['"]\s*\)/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test misses template-literal and two-argument dynamic imports

The new layering test finds dynamic imports with a regex that requires import(, one quoted relative string and a closing parenthesis. A forbidden import written with a no-substitution template literal or a second options argument produces no match, so violations() returns nothing for it and the test passes. No file at the pinned commit uses a missed spelling.

Full finding

The new layering test finds dynamic imports with a regex that requires import(, one quoted relative string and a closing parenthesis. A forbidden import written with a no-substitution template literal or a second options argument produces no match, so violations() returns nothing for it and the test passes. No file at the pinned commit uses a missed spelling.

First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

@tempoxyz-bot

Copy link
Copy Markdown

Low (exposure unconfirmed): Standalone validation suggestions promise wallet provisioning without a payment validator

validate() from mppx/validation now skips the payment phase when no payment validator is supplied, but computeSuggestions still tells mainnet-only callers to validate testnet because "Tempo wallets are automatically provisioned". Provisioning exists only in the CLI's injected validator, so following the suggestion through the same API yields another skipped payment check. First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment thread src/layering.test.ts
Comment on lines +68 to +75
function* sourceFiles(dir: string): Generator<string> {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const file = path.join(dir, entry.name)
if (entry.isDirectory()) yield* sourceFiles(file)
else if (/\.tsx?$/.test(entry.name) && !/\.(test|test-d|gen)\.tsx?$/.test(entry.name))
yield file
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Layering test skips imports in .mts source modules

The new layering guard walks src with a filter that accepts only .ts and .tsx names, so a .mts module is never scanned. A forbidden runtime import placed in such a file, for example validation importing cli, does not fail the test. No .mts file exists at this commit.

Full finding

The new layering guard walks src with a filter that accepts only .ts and .tsx names, so a .mts module is never scanned. A forbidden runtime import placed in such a file, for example validation importing cli, does not fail the test. No .mts file exists at this commit.

First reported at ece7ab0; recheck at this head: still present.

Valid? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants