This guide defines the minimum observability model SQLQueryHelperjs should expose once tracing for planReflect(...) and reflect(...) is implemented.
Teams can already inspect plans and schema history, but that is not the same as operational observability.
Observability should answer:
Without that, schema automation is harder to trust in shared environments.
The first implementation should stay small and structured.
Recommended event families:
plan.startplan.tableplan.completereflect.startreflect.tablereflect.statementreflect.completereflect.errorThe goal is not verbose logging by default. The goal is a stable event schema that higher-level tooling can consume.
type ReflectorEventName =
| "plan.start"
| "plan.table"
| "plan.complete"
| "reflect.start"
| "reflect.table"
| "reflect.statement"
| "reflect.complete"
| "reflect.error";
interface ReflectorTraceEvent {
timestamp: string;
engine: "sqlite" | "postgres" | "mysql";
event: ReflectorEventName;
environment?: string;
table?: string;
phaseDurationMs?: number;
details?: Record<string, unknown>;
}
This shape is intentionally generic so every engine can emit the same envelope first.
plan.startShould include:
plan.tableShould include:
create, alter, rebuild, noop, or destructive-blockedplan.completeShould include:
reflect.startShould include:
reflect.tableShould include:
reflect.statementShould include:
create-table, alter-table, drop-index, recreate-viewThe first version does not need to emit every SQL string by default. Classification and duration are the minimum useful layer.
reflect.completeShould include:
reflect.errorShould include:
The runtime should separate structured events from human-readable logs.
Do not force teams to parse console strings if the runtime already knows the event type.
Schema change history and onSchemaChange are still useful, but they answer a narrower question:
That distinction matters when debugging why a rollout was blocked or why a rebuild path was chosen.
The minimum safe first rollout of observability would be:
That is enough to improve operational trust before exposing detailed SQL traces.
Once the base event model exists, likely next steps are:
Use semantic-change-detection.md as the design reference for future semantic fields such as semanticCategory, renameHintCount, equivalenceNotes, and uncertaintyReason.