@atbash/sdk 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1111,6 +1111,8 @@ interface GuardMemoryWriteInput extends ClassifyMemoryWriteOptions {
1111
1111
  verifyPubKey?: string;
1112
1112
  /** Org name for chain resolution (public vs org-private chain). */
1113
1113
  orgName?: string;
1114
+ /** Explicit chain target when the host already resolved and verified it. */
1115
+ chainOpts?: ChainOpts;
1114
1116
  /** LLM confidence threshold for yellow escalation. Default 0.6. */
1115
1117
  threshold?: number;
1116
1118
  /** When false, red verdicts log but don't block. Default true. */
@@ -1133,7 +1135,7 @@ interface GuardMemoryWriteResult {
1133
1135
  decision?: GuardMemoryDecision;
1134
1136
  /** Present when handled and scan ran. Absent when scan threw. */
1135
1137
  scanResult?: MemoryScanResult;
1136
- /** Present when handled. True when a chain-commit was dispatched (fire-and-forget). */
1138
+ /** Present when handled. True only after the chain transaction confirms. */
1137
1139
  committed?: boolean;
1138
1140
  }
1139
1141
  /**
@@ -1143,12 +1145,13 @@ interface GuardMemoryWriteResult {
1143
1145
  *
1144
1146
  * Verdict handling:
1145
1147
  * - `red` → not persisted to chain; decision blocks (unless `enforce: false`)
1146
- * - `yellow` → persisted with LLM score; decision allows
1147
- * - `green` → persisted with LLM score; decision allows
1148
+ * - `yellow` → persisted with its LLM score; decision allows once the chain confirms
1149
+ * - `green` → persisted with its LLM score; decision allows once the chain confirms
1150
+ * - anything else → not persisted; decision blocks (unless `enforce: false`)
1148
1151
  *
1149
- * Chain commit is fire-and-forget: network errors are logged via
1150
- * `logger.warn` but never surfaced to the caller. This mirrors the
1151
- * existing plugin behaviour — chain is for audit/recovery, not gating.
1152
+ * A write is acknowledged only after the chain transaction confirms, for
1153
+ * yellow exactly as for green. An unconfirmed write blocks in enforce mode
1154
+ * and remains unaudited in observe mode.
1152
1155
  */
1153
1156
  declare function guardMemoryWrite(input: GuardMemoryWriteInput): Promise<GuardMemoryWriteResult>;
1154
1157
 
@@ -1178,6 +1181,8 @@ interface SyncMemoryOptions {
1178
1181
  /** Skip the TTL gate and force a chain check this call. Default false. */
1179
1182
  force?: boolean;
1180
1183
  chainOpts?: ChainOpts;
1184
+ /** Exact chain slot for the managed file; omission keeps the cross-file API behavior. */
1185
+ filePath?: string;
1181
1186
  }
1182
1187
  /**
1183
1188
  * `drifted: false` — pointer is still valid; caller can keep serving the local copy.
@@ -1226,6 +1231,8 @@ declare function defaultPointerPath(workspaceDir?: string): string;
1226
1231
  interface WrappedLogger {
1227
1232
  info(message: string, meta?: Record<string, unknown>): void;
1228
1233
  warn(message: string, meta?: Record<string, unknown>): void;
1234
+ /** Wait for queued writes and surface any lost log entry. */
1235
+ flush(): Promise<void>;
1229
1236
  }
1230
1237
  interface UpstreamLogger {
1231
1238
  info: (...args: unknown[]) => void;
@@ -1285,10 +1292,10 @@ interface HookDecision {
1285
1292
  * failure, a rolled-back version), and a host must never re-judge its way past
1286
1293
  * one.
1287
1294
  *
1288
- * Absent or false means the guard reached no decision — it was inside its cache
1289
- * window, chain was unreachable, the scan never ran, the file it can vouch for
1290
- * is not the file being read, or it is in observe mode. Those calls are
1291
- * unaudited: fall through to your own judge exactly as for a `null` return.
1295
+ * Absent or false means the guard reached no decision — for example, the scan
1296
+ * never ran or this manager does not own the requested file. In enforce mode,
1297
+ * failed chain verification of the managed file is a block, never an unaudited
1298
+ * allow. In observe mode unverified calls remain unaudited.
1292
1299
  *
1293
1300
  * So the host rule is:
1294
1301
  * `if (d.block) deny; else if (d.audited) allow; else judge it yourself;`
@@ -1388,9 +1395,9 @@ declare class MemoryGuardManager {
1388
1395
  runBootProbe(): Promise<void>;
1389
1396
  /**
1390
1397
  * Returns a `HookDecision` when the guard reached a decision about this event.
1391
- * Returns `null` when it did not — either the event isn't memory-related, or it
1392
- * is but the guard could not check it. In both cases the host falls through to
1393
- * its own audit.
1398
+ * Returns `null` for non-memory events, other files this manager does not
1399
+ * own, or unverified observe-mode reads. An enforced read of the managed
1400
+ * file blocks when verification cannot complete.
1394
1401
  *
1395
1402
  * A returned decision carries `audited` (see `HookDecision`). Only
1396
1403
  * `{ allow: true, audited: true }` means "checked and cleared"; anything else
@@ -1415,6 +1422,9 @@ declare class MemoryGuardManager {
1415
1422
  */
1416
1423
  private vouchesForTarget;
1417
1424
  private handleMemoryRead;
1425
+ /** Complete queued audit-log writes before a host shuts down or removes its workspace. */
1426
+ flushLogs(): Promise<void>;
1427
+ private unverifiedRead;
1418
1428
  private writeMemoryAtomic;
1419
1429
  }
1420
1430
  declare function createMemoryGuardManager(opts: MemoryGuardManagerOptions): MemoryGuardManager;