mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
* feat(process)!: name process capture Evidence by its launched root process
The capture result now carries the launched root process in
`manifest.root_process`: its PID with the start identity that
`observeProcessStartIdentity` read for that PID at launch, bound to the
capture's run token. The harness reads that identity once and shares it
between finalization signalling and the manifest, so the read no longer
depends on a positive finalization interval.
Capture Evidence names the root as its subject,
`{ kind: "process", pid, start_time, executable_sha256 }`. A PID without
its start identity is not an identity, so an unread start identity leaves
the subject `unknown`/`not-observed`. When the caller selects PID
normalization, the raw PID and start identity are not recorded:
`root_process` is `withheld-by-caller` and the subject is
`unknown`/`withheld-by-caller`, a new unknown reason. Capture validation
requires the withheld state exactly when PID normalization is selected.
Refs #11417
BREAKING CHANGE: process capture Evidence IDs change: captures without PID
normalization name `{ kind: "process", pid, start_time, executable_sha256 }`
as their subject, and captures with PID normalization name
`{ kind: "unknown", reason: "withheld-by-caller" }`. Capture results
require `manifest.root_process`; captures without it are refused.
Recreate stored process capture Evidence.
* fix(process): join the launch identity read and let cancellation interrupt its wait
The root's launch identity read now runs for every capture and the
manifest awaits it. The read stays unsignalled, because finalization
signals after a cancellation still need the retained identity, so the
manifest's wait observes cancellation through `waitForAbortable` instead.
`finishProcessRun` and the startup-failure path join the read, so a
capture never returns while it is still running.
* feat(rizin)!: bind Rizin command Evidence to its session and launch file (#11570)
* feat(rizin)!: bind Rizin command Evidence to its session and launch file
Rizin command Evidence was subject-less (`unknown`/`not-observed`). A new
`session` target identity names the debugger session REA minted and the
target it launched: `{ kind: "session", session_kind, id, target }`, where
`target` is a file identity or an explicit unknown. The Evidence subject
validates the nested launch file with the format-owned subject
declaration.
`start_rizin_debug_session` hashes the launch file with the shared stable
file hasher before Rizin starts and binds the session to it (`format:
"file"`, no architecture or selection). Later debugger commands do not
rebind it. A descriptor whose close fails is retained in the startup
resource scope, like the inferior TTY lease, and fails the start, as does
cancellation; any other hash failure leaves the target
`unknown`/`not-observed` and records the reason as a limitation. The
"target identity is not established" limitation is replaced by the
binding's meaning.
Refs #11417
BREAKING CHANGE: `rizin_debug_command` Evidence IDs change: its subject is
`{ kind: "session", session_kind: "rizin", id: <session_id>, target }`
with `target` the launch file hashed at start (`{ kind: "file", sha256,
format: "file", architecture: null, selection: null }`) or
`{ kind: "unknown", reason: "not-observed" }`. Recreate stored Rizin
command Evidence.
* feat(gdb)!: name GDB command Evidence by its debugger session (#11572)
GDB startup and console Evidence was subject-less (`unknown`/`not-observed`).
It now names the session REA minted with the shared `session` identity:
`{ kind: "session", session_kind: "gdb", id, target }`. One projection,
`gdbSessionSubject`, replaces the six `unknownTarget("not-observed")` sites.
`start_gdb_session` launches no program file; programs are loaded or
attached by console commands that REA does not hash, so the session target
stays `unknown`/`not-observed`. REA does not infer a file from a PID or a
path. The existing limitation that the active inferior identity is not
established still applies.
Refs #11417
BREAKING CHANGE: `start_gdb_session` startup Evidence and `gdb_console`
Evidence IDs change: their subject is `{ kind: "session", session_kind:
"gdb", id: <session_id>, target: { kind: "unknown", reason: "not-observed" } }`.
Recreate stored GDB Evidence.
* fix(rizin): keep the launch file read failure when its close also fails
When hashing the launch file failed and closing its descriptor failed
too, the start error kept only the close failure; the retained lease
retries only the close, so the read failure was lost. The cleanup error
now carries it as `launch_file_hash_failure`.
The session-binding test now rewrites the launch file after spawn and
between two commands, and checks that both records keep the digest read
before launch.
* fix(process): keep the descriptor a failed launch identity read could not close
The launch identity read reduced every rejection to an unverified reason, so an inspection-owner failure carrying an unclosed descriptor was dropped and the capture could succeed without retaining it. The retained identity now keeps that owner's failure; startup cleanup and finishProcessRun pass it through the same secondary inspection-failure path as the sampler, which fails the capture and keeps the descriptor owned for cleanup retry.
* refactor(rizin): describe a launch-file hash failure through errorMessage
* test(rizin): create launch-file fixtures through createTestTempDirectory
* fix(process): keep the descriptor a finalization signal's identity check left open (#11603)
* fix(process): keep the descriptor a finalization signal's identity check left open
The root signaller now catches a delivery whose identity check fails through the inspection owner, records the attempt as unverified, and keeps the inspection failure. finishProcessRun joins every delivery (including one that outlasted the finalization grace) and retains those failures through the same secondary inspection-failure path as the launch identity read, so the capture fails with the descriptor still owned for a cleanup retry.
* test(process): release descriptor-retention captures when an assertion fails
Both descriptor-retention regressions register their resource-scope release before the capture starts and use the project deadline instead of a fixed 15 s timeout.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { ProcessOwnershipEvidenceOwner } from "../../../src/process/ProcessOwnershipEvidence.js";
|
|
import { expect, it } from "vitest";
|
|
|
|
import { processScenarioSchema } from "../../../src/domain/process/processScenario.js";
|
|
import {
|
|
createRunManifest,
|
|
observeLaunchedExecutable,
|
|
observeSelectedExecutable,
|
|
observeSettlement,
|
|
} from "../../../src/process/capture/ProcessCaptureLifecycle.js";
|
|
|
|
it("uses one selected host identity for manifest and settlement", async () => {
|
|
const scenario = processScenarioSchema.parse({
|
|
executable: process.execPath,
|
|
working_directory: process.cwd(),
|
|
events: [],
|
|
});
|
|
const selectedHost = {
|
|
platform: "win32" as const,
|
|
architecture: "arm64" as const,
|
|
};
|
|
const selectedExecutable = await observeSelectedExecutable(
|
|
scenario.executable,
|
|
);
|
|
const manifest = await createRunManifest(
|
|
scenario,
|
|
new Date(0),
|
|
new Date(1),
|
|
observeLaunchedExecutable(scenario.executable, selectedExecutable),
|
|
{ state: "withheld-by-caller" },
|
|
selectedHost,
|
|
);
|
|
const settlement = await observeSettlement({
|
|
runId: "run",
|
|
processGroupIds: [],
|
|
settleMs: 0,
|
|
recordEvent: () => undefined,
|
|
platform: selectedHost.platform,
|
|
ownershipEvidence: new ProcessOwnershipEvidenceOwner(),
|
|
});
|
|
|
|
expect(manifest).toMatchObject(selectedHost);
|
|
expect(settlement).toEqual({ state: "unverifiable", elapsed_ms: 0 });
|
|
});
|