Package Exports
- @intent-driven/bridge-postgres
Readme
@intent-driven/bridge-postgres
Bridge между Postgres БД и IDF Φ event-log: CDC mirror (read-only, БД primary) и gateway-mode (Fold принимает agent calls, валидирует, при confirm пишет в БД).
Status
| Feature | Status |
|---|---|
| pgoutput decoder (INSERT/UPDATE/DELETE/RELATION/BEGIN/COMMIT) | ✅ PR 5a |
createMirror API с DI stream |
✅ PR 5a |
| CDC → Φ effect mapping | ✅ PR 5a |
| Real pg_logical subscriber (node-postgres replication mode) | планируется PR 5b |
| Schema-drift detector (ontology vs live БД) | планируется PR 5c |
| Gateway mode (transactional outbox) | планируется PR 5d |
Mirror API (PR 5a)
import { createMirror } from "@intent-driven/bridge-postgres";
const mirror = createMirror({
stream: someAsyncIterableOfPgoutputBuffers,
async onEffect(effect, ctx) {
// effect: { alpha: "insert"|"replace"|"remove", target, value?, key?, ... }
// ctx: { transaction: { xid, finalLSN, commitTimestamp }, relation }
await foldRuntime.proposeEffect(effect);
},
async onCommit(info) {
// commit batch boundary — flush к Φ event-log
},
});
await mirror.start();
console.log(mirror.stats);
// { decoded: 1234, insert: 100, update: 80, delete: 5, relation: 3, begin: 50, commit: 50 }В PR 5b будет high-level helper:
const mirror = createPgLogicalMirror({
connectionString: "postgres://repluser:pass@host/db",
slotName: "idf_mirror",
publicationName: "idf_pub",
onEffect, onCommit,
});License
MIT.