refactor(audit): trim internal input types (#107390)

This commit is contained in:
Peter Steinberger
2026-07-14 03:43:49 -07:00
committed by GitHub
parent 3229fbdc48
commit 26fe6e8ea3
3 changed files with 22 additions and 14 deletions

View File

@@ -485,10 +485,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
"src/audit/agent-event-audit.ts: resetAgentEventAuditForTest",
"src/audit/audit-event-store.ts: auditEventStoreLimits",
"src/audit/audit-event-store.ts: testApi",
"src/audit/audit-event-types.ts: AgentRunAuditEventInput",
"src/audit/audit-event-types.ts: InboundMessageAuditEventInput",
"src/audit/audit-event-types.ts: OutboundMessageAuditEventInput",
"src/audit/audit-event-types.ts: OutboundMessageAuditTerminal",
"src/audit/audit-event-writer.ts: testApi",
"src/audit/message-audit-events.ts: resetMessageAuditEventsForTest",
"src/auto-reply/reply/abort.ts: testing",

View File

@@ -5,16 +5,28 @@ import {
openOpenClawStateDatabase,
} from "../state/openclaw-state-db.js";
import { listAuditEvents, recordAuditEvent } from "./audit-event-store.js";
import type {
AgentRunAuditEventInput,
InboundMessageAuditEventInput,
OutboundMessageAuditEventInput,
OutboundMessageAuditTerminal,
} from "./audit-event-types.js";
import type { AuditEventInput, MessageAuditEventInput } from "./audit-event-types.js";
const tempDirs: string[] = [];
const AUDIT_REF_RE = /^hmac-sha256:v1:[a-f0-9]{32}:[a-f0-9]{64}$/u;
type AgentRunAuditEventInput = Extract<AuditEventInput, { kind: "agent_run" }>;
type InboundMessageAuditEventInput = Extract<MessageAuditEventInput, { direction: "inbound" }>;
type OutboundMessageAuditEventInput = Extract<MessageAuditEventInput, { direction: "outbound" }>;
type OutboundTerminalFields =
| "deliveryKind"
| "errorCode"
| "failureStage"
| "outcome"
| "reasonCode"
| "status";
type OutboundMessageAuditTerminal = {
[Status in OutboundMessageAuditEventInput["status"]]: Pick<
Extract<OutboundMessageAuditEventInput, { status: Status }>,
OutboundTerminalFields
>;
}[OutboundMessageAuditEventInput["status"]];
function createDatabaseOptions() {
return { env: { OPENCLAW_STATE_DIR: makeTempDir(tempDirs, "openclaw-message-audit-") } };
}

View File

@@ -81,7 +81,7 @@ type AgentRunAuditLifecycle =
| { action: "agent.run.started"; status: "started"; errorCode?: never }
| ({ action: "agent.run.finished" } & AgentRunFinishedAuditTerminal);
export type AgentRunAuditEventInput = AuditEventInputBase &
type AgentRunAuditEventInput = AuditEventInputBase &
AgentAuditAttribution &
AgentRunAuditLifecycle & { kind: "agent_run" };
@@ -153,7 +153,7 @@ export type InboundMessageAuditTerminal =
reasonCode?: AuditInboundMessageFailureReasonCode;
};
export type OutboundMessageAuditTerminal =
type OutboundMessageAuditTerminal =
| {
status: "succeeded";
outcome: "sent";
@@ -188,7 +188,7 @@ export type OutboundMessageAuditTerminal =
};
/** Raw identifiers exist only on the trusted producer-to-writer boundary. */
export type InboundMessageAuditEventInput = MessageAuditEventInputBase &
type InboundMessageAuditEventInput = MessageAuditEventInputBase &
InboundMessageAuditAttribution &
InboundMessageAuditTerminal & {
action: "message.inbound.processed";
@@ -198,7 +198,7 @@ export type InboundMessageAuditEventInput = MessageAuditEventInputBase &
};
/** Raw identifiers exist only on the trusted producer-to-writer boundary. */
export type OutboundMessageAuditEventInput = MessageAuditEventInputBase &
type OutboundMessageAuditEventInput = MessageAuditEventInputBase &
OutboundMessageAuditAttribution &
OutboundMessageAuditTerminal & {
action: "message.outbound.finished";