Repository navigation
impl(027): increment 6, the native crate - #131
Conversation
AI review (findings)Group 1 of 2Review Findings1. Makefile — wrong
|
c77d571 to
45f834b
Compare
30f0d54 to
c9000ff
Compare
45f834b to
c2a7e85
Compare
c9000ff to
11a1b4e
Compare
c2a7e85 to
9e68054
Compare
11a1b4e to
08f56b1
Compare
9e68054 to
d7996f4
Compare
08f56b1 to
a079e9b
Compare
d7996f4 to
cf86dd0
Compare
a079e9b to
5033d49
Compare
cf86dd0 to
df762d0
Compare
5033d49 to
904e9c9
Compare
6054b28 to
ca37009
Compare
904e9c9 to
2c0874d
Compare
AI review (findings)Group 1 of 2Reviewing the new
Lines 6-8 call {"head": "2c0874d2ff8f639bd00811fd2e11ceead4fa62b5", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/index.js", "line": 312, "summary": "compileSync calls bytes(undefined) when neither definition nor plan is supplied, producing InternalError instead of InvalidDocument, and silently picks plan when both are supplied rather than raising InvalidDocument as the async compile path does."}, {"path": "integrations/rustev-node/tests/no_unsafe.rs", "line": 8, "summary": "read_to_string is called on every read_dir entry without checking file_type first; a subdirectory under src/ would cause an unwrap panic rather than a meaningful test failure."}]}Group 2 of 2Reviewing the five files in group 2.
These are schema-level documentation bugs that generated into this new public API file. The type union itself ( {"head": "2c0874d2ff8f639bd00811fd2e11ceead4fa62b5", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/types/rustev-documents.d.ts", "line": null, "summary": "In RustevPlan2.AddressOverride and RustevPlan3.AddressOverride the JSDoc on `to` reads the Party type description ('Who can act on an outcome…') instead of the correct address-override description; compare RustevDefinition1.AddressOverride.to which correctly says '`host`, `upstream` or `none`; never `caller`'."},{"path": "integrations/rustev-node/types/rustev-documents.d.ts", "line": null, "summary": "In RustevPlan2.RemediationDecl and RustevPlan3.RemediationDecl the JSDoc on `for` likewise carries the Party type description instead of the correct '`caller`, `host` or `upstream`' description seen in the definition schemas."}]}Subject: ca37009...2c0874d, diff digest eb4f1f9c1eee04594a57c8bba412b8c87cb419134521842ea6b8d35e7e96a5d2, 2 call(s). An AI comment is not an approval. |
ca37009 to
f3b0975
Compare
2c0874d to
da7b57e
Compare
AI review (findings)Group 1 of 2Reviewing the new
while (this.native.shutdown() > 0) {
await new Promise((r) => setTimeout(r, 5));
}If a cancelled decision does not complete (e.g., a host seam ignores the abort signal indefinitely), this loop never exits. The spec expects honest termination after cancellation, but there is no liveness guarantee here enforced by the binding itself.
The {"head": "da7b57e8f312d03b8b19d3db4587516980bab968", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/tests/no_unsafe.rs", "line": 10, "summary": "read_dir is not filtered to files; a subdirectory in src/ would cause read_to_string().unwrap() to panic instead of failing the assertion."}, {"path": "integrations/rustev-node/src/lib.rs", "line": 380, "summary": "command_async tasks spawned via spawn_blocking are not counted in in_flight, so shutdown() can report zero in-flight while blocking command tasks are still running."}, {"path": "integrations/rustev-node/index.js", "line": 383, "summary": "The post-cancellation shutdown loop has no timeout, leaving shutdown() permanently stuck if any cancelled decision never completes."}, {"path": "integrations/rustev-node/index.js", "line": 119, "summary": "require(local) for a local .node file is not wrapped in try/catch, so a corrupt or ABI-mismatched build produces an untyped error instead of the typed PlatformPackageMissing class."}]}Group 2 of 2Reviewing the five files in this group: the new Node types declaration, the updated WASM types banner, the spec increment, the generator script, and the release set.
{"head": "da7b57e8f312d03b8b19d3db4587516980bab968", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/types/rustev-documents.d.ts", "line": null, "summary": "In the RustevPlan2 and RustevPlan3 namespaces, AddressOverride.to and RemediationDecl.for carry the Party type's docstring ('Who can act on an outcome…') instead of the constraint present in RustevDefinition1/2 ('never `caller`' / 'caller, host or upstream'), potentially misleading Node.js callers into treating `\"caller\"` as valid for AddressOverride.to."}]}Subject: f3b0975...da7b57e, diff digest b3da39e4d536f402c50fa5a2a60d326dced933b7e297efa06189696cbf4c9906, 2 call(s). An AI comment is not an approval. |
f3b0975 to
3f31f3c
Compare
da7b57e to
8f44c05
Compare
3f31f3c to
7f5eedc
Compare
8f44c05 to
9878333
Compare
AI review (findings)Group 1 of 2Review
|
0f8535c to
847339d
Compare
92ff104 to
801d0d3
Compare
AI review (findings)Group 1 of 2Review
|
847339d to
86bf20d
Compare
801d0d3 to
49607c8
Compare
86bf20d to
04eed4d
Compare
49607c8 to
3b02e05
Compare
AI review (findings)Group 1 of 2Reviewing the diff, which introduces a new napi-rs Node.js binding ( Findings1. TOCTOU race between shutdown check and
|
04eed4d to
2a8eeeb
Compare
3b02e05 to
5772002
Compare
AI review (findings)Group 1 of 2Reviewing the PR, which adds a Node-API binding (
The parser handles
copyFileSync(join(pkg, 'index.js'), join(dir, 'index.js'));
// only index.js is copied; node_modules is NOT created
require(join(dir, 'index.js')); // expects MODULE_NOT_FOUND → PlatformPackageMissingNode's
#[napi]
pub fn advance_clock(&self, ms: u32) -> Result<()> { … }
{"head": "5772002e4efef577f4b60387b95f1bd2961b64b2", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/tests/no_unsafe.rs", "line": 50, "summary": "code_of does not handle b\"...\" byte-string literals as a unit; the b prefix is emitted as code and the string content is kept verbatim, so any byte string containing the substring \"unsafe\" would cause a false-positive assertion failure."}, {"path": "integrations/rustev-node/test/negative.test.mjs", "line": 234, "summary": "The 'missing platform package' test copies only index.js into a temp dir, but Node's require resolution ascends parent directories, so if the platform package is installed in any ancestor node_modules the test silently loads it instead of throwing PlatformPackageMissing."}, {"path": "integrations/rustev-node/src/lib.rs", "line": 296, "summary": "advance_clock accepts ms as u32 on the Rust side but is typed as number in index.d.ts; napi-rs truncates JavaScript values above u32::MAX (~4.29 billion ms) without error, violating the declared type contract."}]}Group 2 of 2Reviewing the six files in this group.
The platform → extension mapping ( No bugs or security issues found. The one item worth flagging is the heavyweight libc probe. {"head": "5772002e4efef577f4b60387b95f1bd2961b64b2", "verdict": "findings", "findings": [{"path": "tools/rustev-conformance/js/copy-addon.mjs", "line": 26, "summary": "process.report.getReport() generates a full diagnostic report (memory maps, handles, CPU) just to probe glibcVersionRuntime; a stat check on /lib/libc.musl-*.so.1 or an equivalent lightweight test would be less wasteful for a build-time script."}]}Subject: 2a8eeeb...5772002, diff digest f53ffda19f86037693098c0c453f1618d1defa8ba38fad32c38299c84bf74e82, 2 call(s). An AI comment is not an approval. |
2a8eeeb to
4712dee
Compare
5772002 to
d131805
Compare
4712dee to
7ca58d5
Compare
d131805 to
9c164ee
Compare
AI review (findings)Group 1 of 2Review
|
AI review (findings)Reviewing the PR — a new
The .ok_or_else(|| usage(format!("{k} is a string")))Every other
let counted = Blocking::enter(self.inner.clone());
self.live()?; // one check; no recheck inside spawn_blocking
self.inner.rt.spawn_blocking(move || { ... commands::run(...) ... })
let counted = Blocking::enter(self.inner.clone());
// no live() check here
self.inner.rt.spawn_blocking(move || {
// live() fires inside engine.compile() / engine.load()
})The consequence: a compile/load that races with shutdown can fail even after No security issues found. The panic-catching ( {"head": "e28fb80a602ab1abf82580eb3987085404e6aab8", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/commands.rs", "line": 32, "summary": "Error message `\"{k} is a string\"` is grammatically a description, not a refusal; all other usage messages use the `must be` form."}, {"path": "integrations/rustev-node/src/lib.rs", "line": null, "summary": "`prepare_async` places no `live()` check outside `spawn_blocking` while `command_async` does, so a mid-flight shutdown kills a queued compile/load but lets a queued command complete — the two blocking-pool paths behave inconsistently under shutdown."}]}Subject: 89a6ffd...e28fb80, diff digest 26c383fa75ba67e6de760451120688820443f0a28c0f3da7890d76ab7797a4d6, 1 call(s). An AI comment is not an approval. |
AI review (findings)Review
|
AI review (findings)Reviewing the PR which adds the Finding 1 —
|
AI review (findings)Reviewing the PR, which introduces the
Issue —
{"head": "915b13bd8f54ecb984b399dc4bf240657fdd569c", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/lib.rs", "line": null, "summary": "advance_clock's None branch (system clock) returns \"ConfigRefused\"/\"out_of_range\" — the same code used for numeric range violations with min/max fields — instead of a distinct code for an unsupported-operation condition, producing an inconsistently shaped error payload."}]}Subject: 4159d3c...915b13b, diff digest 81a2c07288e21ae42b5b6bdcb07211215c601ca657fba41beb344ffa93f286db, 1 call(s). An AI comment is not an approval. |
AI review (findings)Reviewing the new
// command_async
let counted = Blocking::enter(self.inner.clone());
self.live()?;But the synchronous pub fn command(&self, ...) -> Result<CommandResult> {
guard(|| {
self.live()?; // no Blocking::enter
...
})
}
The fix is straightforward: each sync method should hold a Everything else looks correct:
{"head": "36dfdcb3fcec6760f13cad942da226f3f46edfb3", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/lib.rs", "line": null, "summary": "Sync `command`, `compile`, and `load` do not call `Blocking::enter`, so `shutdown()`'s drain count excludes them; concurrent calls from Worker threads are invisible to the shutdown-and-drain protocol."}]}Subject: 55df832...36dfdcb, diff digest 44853579f01a59fe4663d0e3d0bf03c023118ac14022b71090d8a782ff76a20d, 1 call(s). An AI comment is not an approval. |
AI review (findings)Reviewing the PR, which introduces
{"head": "3208b9e319357dea6a2a939bd119843df0d64584", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/lib.rs", "line": 329, "summary": "The wildcard arm of `match (definition, plan)` in `prepare_async` emits 'compile takes exactly one of a definition and a plan' for both the (Some, Some) and (None, None) cases, producing a misleading error message when neither argument is provided."}]}Subject: 55df832...3208b9e, diff digest 08e2e7090ae4c5cae743f416f91b66548b5364c6b066c5d61da69f284a4f22f6, 1 call(s). An AI comment is not an approval. |
AI review (findings)Reviewing the new Finding 1 —
A safe fix: count only in Finding 2 —
map_or(0, |c| c.sleepers() as u32)
{"head": "c07be8cddffd67aa4c94208847d02bc289daf04d", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/lib.rs", "line": 321, "summary": "prepare_async increments the blocking counter before spawning, then compile/load each increment it again inside the closure, causing shutdown() to over-report the in-flight count by one for every concurrent prepare_async call."}, {"path": "integrations/rustev-node/src/lib.rs", "line": 385, "summary": "clock_sleepers casts usize to u32 without a bounds check, silently truncating the sleeper count if it exceeds u32::MAX."}]}Subject: 55df832...c07be8c, diff digest ff87cad841a8d826ffd26c1d756476d73e94ce6177b1675c3d32bc279634f40f, 1 call(s). An AI comment is not an approval. |
AI review (findings)ReviewThe PR adds the Finding 1 —
|
AI review (no-findings)Reviewing the PR, which introduces a napi-rs Node.js binding (
No bugs, security problems, or inconsistencies found. {"head": "49c1e26ad9a88b6dea85a29fcea96203576434d9", "verdict": "no-findings", "findings": []}Subject: 55df832...49c1e26, diff digest 70e9068708a0ce6ae8202b8f3881e3f4519a86d3a116f726721defbe069934b8, 1 call(s). An AI comment is not an approval. |
Spec 027, increment 6 (first change): the native Node-API package. Stacked on #130.
integrations/rustev-node(napi 3.14.2, Node-API 8;publish = false, excluded from the crates.io release set): anEngineowning one sized Tokio runtime, rules-program and host backends, a host sink and optional context source;compile(or load a compiled plan) and the pure commands on the blocking pool, with sync variants;decideon the engine's runtime withAbortSignal, deadline, principal handle andtraceparent; manual clock; gauges; shutdown.SeamFailurerejections mapped to permanent / unknown charge / possibly continuing. Context source once before admission;ContextUnavailableon failure, nothing defaulted.index.js,index.d.ts, generated document declarations byte-identical to the wasm package's): the 3.3 API, typedRustevErrorsubclasses and codes (3.4),onGaugesdrop-oldest subscription, drain-then-cancelshutdown, platform-package loader naming a missing package.unsafe: napi-rs's generated glue needs it, so this crate setsunsafe_code = "deny"(reason in the manifest);tests/no_unsafe.rsfails on hand-writtenunsafe.test/negative.test.mjs: each section 5 row of the native package (20 tests, deterministic on a manual clock). A decision through the binding produces the CLI's golden run-record bytes.ManualClock::pending_delays(additive, spec 003's crate) for deterministic clock driving; the conformance adapter that uses it follows in the second change.not_observed(the runtime polls a cancelled attempt once; a host seam answers across threads), and section 5's "output failing the bounded parse" row disagrees with 3.6.5; the binding follows 3.6.5.Review round 1 (5 findings): (1) Under
node -e,process.argv[1]is the first argument after the code (there is no script path), so the copy reads the target directory; it ran that way in local verification, and the Makefile now says so. (2) fixed: a decision is counted in flight by a guard dropped when its task ends, panic included, so shutdown never waits on a panicked task. (3) fixed:compiletakes exactly one of a definition and a plan, otherwiseInvalidDocument; declared and tested. (4, 5) The generated types state what each bounded parser accepts (3.2.2: the schema describes the parser), while a field's description can state a compiler rule beyond it (AddressOverride.tois nevercaller,RemediationDecl.fornevernone: the compiler refuses both). The generated header now says so; both packages' copies regenerated and identical. Restacked on #130.Review round 2 (5 findings): (1) fixed: the no-unsafe check reads source files only and fails on anything else in
src/rather than panicking. (2) fixed: compiles and commands on the blocking pool are counted, and shutdown waits for them as for decisions. (3) fixed: after raising cancellation, shutdown waits at most 30 seconds and reports what still runs (stillRunning). (4) fixed: a local build that does not load is a typedInternalError(local_build_unloadable) naming it; tested. (5) Repeated: the generated types state what each bounded parser accepts and the generated header says a field's description can state a compile rule beyond that;compilerefusescallerforAddressOverride.toin every plan.Review round 3 (6 findings): (1) Repeated, and wrong: under
node -ethe first argument after the code isprocess.argv[1](node -e 'console.log(process.argv.slice(1))' xprints["x"]). To leave no doubt, the copy is now a script,tools/rustev-conformance/js/copy-addon.mjs <target> <package>, run bymake bindingsand locally. (2) fixed: shutdown's local count isactive, no longer shadowing the module'sinFlight. (3) fixed: a seam failure with an empty reason records the status instead (the host seam failed without a reason (...)). (4) Repeated: the generated declarations' header states that the types describe what each parser accepts and that a description can state a compile rule beyond it (the compiler refusescallerforAddressOverride.to); each emitted schema now says the same in a root$comment(#126), which the type generator does not copy. (5, 6) These are the two owner findings already recorded in this spec's implementation record (the host backend's cancellation recordednot_observed, and section 5 against 3.6.5 for an unparseable answer); they need the owner's reading or an amendment, not a code change here. Restacked on #130.Review round 4 (5 findings): (1) fixed, and it exposed a real defect:
compileSynctakes exactly one of a definition and a plan, refusing otherwise withInvalidDocument; the layer's error wrapper also re-typed errors it had thrown itself asInternalError, and now passes aRustevErrorthrough unchanged. Tested. (2) fixed: the no-unsafe check strips a//comment only outside string literals; tested. (3) The diagnostic report is the C-library test napi-rs uses; it runs once, on Linux only, and now without the network section where Node allows leaving it out. (4) fixed:copy-addon.mjsrefuses a platform it has no package for. (5) fixed at the source (#130): the generator gave plan fields the referenced type's description; now every field keeps its own (AddressOverride.to: nevercaller), and this package's declarations are regenerated, byte-identical to the WebAssembly package's.Review round 5 (2 findings, fixed): (1) an installed platform package that does not load is
InternalError(platform_package_unloadable, naming it), and only an absent one isPlatformPackageMissing. (2) the no-unsafe check blanks/* */block comments across lines as well as//comments, string literals staying code; tested.Review round 6 (3 findings, fixed): (1) a command is counted before the shutdown check (both sequentially consistent), so either shutdown waits for it or it refuses; it never runs unseen. (2) the no-unsafe check reads raw strings (
r#"…"#,br"…"), escaped strings and char literals ('"') as code, with lifetimes left alone; tested. (3) a package is missing only when Node cannot find the package itself (Cannot find module '<package>'); a missing dependency of an installed package makes it unloadable.Review round 7 (3 findings, fixed): (1) a decision is counted in flight before the shutdown check, as a command is, so shutdown either waits for it or it refuses. (2) shutdown's count saturates at
u32::MAXinstead of truncating. (3) the no-unsafe check reads an escaped char literal ('\'') whole; tested.Review round 8 (4 findings, fixed): (1) the no-unsafe check blanks string contents (plain, byte and raw) as it blanks comments, so text inside a string is not code; a real
unsafeblock is still found; tested. (2) the missing-package test first asserts that no platform package resolves from its directory (Node also searches ancestors), so it fails rather than passes if one does. (3)advanceClocktakes any integral, non-negative number up to 2^53 - 1 and refuses the rest instead of truncating to 32 bits; tested. (4) the build-time copy script leaves out the report's network section too.Review round 9 (2 findings, fixed): (1)
clockDelaysreports each pending delay as a JavaScript number, exact to 2^53 - 1 ms, the rangeadvanceClockaccepts, instead of capping at 32 bits. (2) the no-unsafe check matches the keywordunsafe, not a longer identifier such asunsafe_code; tested.Split (the AI review was cancelled at its 15-minute limit twice): this PR is now increment 6's first change, the native crate (Rust: engine, seams, commands, errors, the no-unsafe check, the manual clock's pending delays); the JavaScript layer (
index.js, declarations, generated types, package, tests, copy script) moves to a PR stacked on this one, and #132 is restacked on that.Review round 10 (2 findings, fixed): (1) every usage refusal states the requirement (
must be a string,must be a list,must list strings). (2) a compile on the blocking pool is counted and then checked against shutdown before it reaches the pool, as a command is, so both paths behave alike: shutdown waits for it, or it refuses.Review round 11 (2 findings, fixed): (1)
"failure": nullin a host's answer is no failure; only an object is one. (2) the context source's fetch runs on its own task, as a backend's attempt does, so a settlement that arrives after its decision was dropped is discarded and counted (3.6.4). The 23 native tests (#135) and the 34 native conformance cases (#132) pass against this build.Review round 12 (2 findings, fixed): (1) a host answer's
cancel, when present, must bestoppedorunconfirmed; any other value is refused like an unknown charge or remote end, and only an absent one means not requested. (2)compileandloadon the blocking pool run underguard, so a panic crosses asInternalErrorwith its message, as a command's does. Rebased on main after #134 merged.Review round 13 (1 finding, fixed): advancing an engine on the system clock is refused with its own code,
not_a_manual_clock, instead ofout_of_range, which stays for numbers outside the accepted range; #135 tests both.Review round 14 (1 finding, fixed): the synchronous
command,compileandloadare counted and then checked against shutdown, as their blocking-pool forms are, so a synchronous call (from a worker thread too) is one shutdown waits for. The native tests (#135, 27) and native conformance (#132, 34) pass against this build.Review round 15 (1 finding, fixed): a compile given neither a definition nor a plan says so (
neither was given), and one given both saysnot both.Review round 16 (2 findings, fixed): (1)
compileandloadcount themselves and then call uncounted forms (compile_uncounted,load_uncounted), whichprepare_async, already counted, calls directly, so nothing is counted twice. (2)clockSleeperssaturates atu32::MAXinstead of truncating. The native tests (#135, 27) and native conformance (#132, 34) pass against this build.Review round 17 (2 findings): (1) Nothing is dropped: the workspace's only lint is
unsafe_code([workspace.lints.rust]), which this crate overrides todeny; Cargo cannot inherit the workspace table and override one lint, so the manifest now says the table restates the workspace's and must mirror any lint it gains. (2) fixed: a host answer missing its charge or its remote end is refused naming the one that is missing.