/** * Cypher rewrite pass that injects provenance stamps into operator-supplied * write_neo4j_cypher. Sibling to cypher-validate.ts: validate first, * rewrite second, run third. * * Doctrine context: wrapped writers stamp every CREATE node * structurally via writeNodeWithEdges; raw cypher relied on * prompt-internalised discipline. This module closes the asymmetry — the * rewriter appends `SET .createdAt = $__autoStartTimestamp, * .createdByAgent = $__autoAgent, .createdByTool = * 'graph-cypher-write', .createdBySession = $__autoSession` to every * CREATE/MERGE clause that introduces a new labeled node. Caller supplies * the three `$__auto*` params at tx.run time. * * MERGE handling preserves the create-vs-match distinction. CREATE always * stamps (every CREATE introduces a new node by definition). MERGE injects * `ON CREATE SET` so an existing-node match path keeps the original writer's * provenance intact — overwriting it would destroy forensic attribution. * * Node-only stamping. Edge aliases (`[r:R]`) are not auto-stamped — matches * the wrapped writer's writeNodeWithEdges, which stamps the node only. * * Idempotent: re-applying the rewriter to its own output is a no-op. The * marker that proves "already stamped" is `.createdBySession = * $__autoSession` — the unique combination of property name + auto param. * * String literals and comments are redacted (chars replaced with spaces, * offsets preserved) so a `CREATE (fake:Foo)` inside a comment or quoted * string cannot mistakenly trip the rewriter. */ export interface RewriteResult { cypher: string; /** Number of node aliases that received a fresh stamp injection. */ stampsAppended: number; } export declare function rewriteWithProvenanceStamps(cypher: string): RewriteResult; //# sourceMappingURL=cypher-rewrite-stamp.d.ts.map