refactor(process): remove duplicate observation and trace entry points
This commit is contained in:
@@ -4,6 +4,7 @@ import type { JsonValue } from "../jsonValue.js";
|
||||
import type { ProcessCapture } from "./processCaptureParsing.js";
|
||||
import { processSourceTruncated } from "./processCaptureCoverage.js";
|
||||
import {
|
||||
comparableProcessObservationPayload,
|
||||
processObservationLocationSchema,
|
||||
projectProcessObservation,
|
||||
type ProcessObservationLocation,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
} from "./processObservation.js";
|
||||
import {
|
||||
canonicalTraceJson,
|
||||
comparableTracePayload,
|
||||
processTraceCardinalityBounds,
|
||||
type ProcessTraceSpecification,
|
||||
} from "./processTraceSpecification.js";
|
||||
@@ -190,7 +190,7 @@ const matchRecords = (
|
||||
ignoredFieldsBySource.set(event.source, ignoredFields);
|
||||
eventsByKey.set(
|
||||
`${event.source}\0${canonicalTraceJson(
|
||||
comparableTracePayload(event.exact, ignoredFields),
|
||||
comparableProcessObservationPayload(event.exact, ignoredFields),
|
||||
)}`,
|
||||
event,
|
||||
);
|
||||
@@ -198,7 +198,7 @@ const matchRecords = (
|
||||
for (const record of records) {
|
||||
const match = eventsByKey.get(
|
||||
`${record.source}\0${canonicalTraceJson(
|
||||
comparableTracePayload(
|
||||
comparableProcessObservationPayload(
|
||||
record.payload,
|
||||
ignoredFieldsBySource.get(record.source),
|
||||
),
|
||||
|
||||
@@ -7,7 +7,6 @@ import { jsonValueSchema } from "../jsonValue.js";
|
||||
import {
|
||||
comparableProcessObservationPayload,
|
||||
processObservationSourceSchema,
|
||||
type ProcessObservationSource,
|
||||
} from "./processObservation.js";
|
||||
|
||||
const identifierSchema = z.string().regex(IDENTIFIER_PATTERN);
|
||||
@@ -114,12 +113,6 @@ export const canonicalTraceJson = (value: unknown): string => {
|
||||
return serialized;
|
||||
};
|
||||
|
||||
/** Remove only explicitly declared schedule metadata before exact matching. */
|
||||
export const comparableTracePayload = (
|
||||
value: unknown,
|
||||
ignoredFields: readonly string[] = [],
|
||||
): unknown => comparableProcessObservationPayload(value, ignoredFields);
|
||||
|
||||
export const processTraceCardinalityBounds = (
|
||||
cardinality: ProcessTraceSpecification["events"][number]["cardinality"],
|
||||
): readonly [number, number] => {
|
||||
@@ -472,7 +465,7 @@ export const processTraceSpecificationSchema =
|
||||
path: ["events", index, "exact"],
|
||||
});
|
||||
const predicate = `${event.source}\0${canonicalTraceJson(
|
||||
comparableTracePayload(event.exact, ignoredFields),
|
||||
comparableProcessObservationPayload(event.exact, ignoredFields),
|
||||
)}`;
|
||||
if (predicates.has(predicate))
|
||||
context.addIssue({
|
||||
|
||||
@@ -16,9 +16,9 @@ import type {
|
||||
} from "./ProcessOwnership.js";
|
||||
|
||||
/** Observe one group without signaling it, failing closed on identity doubt. */
|
||||
export const observeOwnedProcessGroupWithHost = async (
|
||||
export const observeOwnedProcessGroup = async (
|
||||
ownership: OwnedProcessGroup,
|
||||
host: ProcessOwnershipHost,
|
||||
host: ProcessOwnershipHost = systemProcessOwnershipHost,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ProcessGroupObservation> => {
|
||||
signal?.throwIfAborted();
|
||||
@@ -60,10 +60,16 @@ export const observeOwnedProcessGroupWithHost = async (
|
||||
return { state: "alive" };
|
||||
};
|
||||
|
||||
/** Record the live launcher and descendant lineage after run-token validation. */
|
||||
export const observeOwnedProcessLineageWithHost = async (
|
||||
/**
|
||||
* Record the live launcher and descendant lineage after run-token validation.
|
||||
*
|
||||
* The observation is intentionally point-in-time. A verified empty descendant
|
||||
* list means no descendants were live during this observation, not that the
|
||||
* run never created a short-lived child.
|
||||
*/
|
||||
export const observeOwnedProcessLineage = async (
|
||||
ownership: OwnedProcessGroup,
|
||||
host: ProcessOwnershipHost,
|
||||
host: ProcessOwnershipHost = systemProcessOwnershipHost,
|
||||
): Promise<ProcessLineageObservation> => {
|
||||
let processes: readonly ProcessTableEntry[];
|
||||
try {
|
||||
@@ -439,27 +445,6 @@ export const prepareProcessOwnershipInspection = async (
|
||||
await systemProcessOwnershipHost.prepare?.(signal);
|
||||
};
|
||||
|
||||
/** Observe one group without signaling it, failing closed on identity doubt. */
|
||||
export const observeOwnedProcessGroup = async (
|
||||
ownership: OwnedProcessGroup,
|
||||
host: ProcessOwnershipHost = systemProcessOwnershipHost,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ProcessGroupObservation> =>
|
||||
observeOwnedProcessGroupWithHost(ownership, host, signal);
|
||||
|
||||
/**
|
||||
* Record the live launcher and descendant lineage after run-token validation.
|
||||
*
|
||||
* The observation is intentionally point-in-time. A verified empty descendant
|
||||
* list means no descendants were live during this observation, not that the
|
||||
* run never created a short-lived child.
|
||||
*/
|
||||
export const observeOwnedProcessLineage = async (
|
||||
ownership: OwnedProcessGroup,
|
||||
host: ProcessOwnershipHost = systemProcessOwnershipHost,
|
||||
): Promise<ProcessLineageObservation> =>
|
||||
observeOwnedProcessLineageWithHost(ownership, host);
|
||||
|
||||
const processIsGone = async (
|
||||
host: ProcessOwnershipHost,
|
||||
pid: number,
|
||||
|
||||
Reference in New Issue
Block a user