Configuration overview
Control how AGINDOW observes integration behavior, detects supported drift and applies eligible verified repairs. Make three choices: which tool operations to inspect, which scoped evidence to compare, and how to handle eligible drift. Start in observe. Construction settings load the engine, detector selection and repair rules. Per-operation settings name the tool, label read/write/unknown and choose call policy. Readiness alone does not activate detection.
Minimal configuration
Runnable setup fixtures: use Node 22.6+ for the native TypeScript command. Install the selected SDK, save the tab as config.mts or config.py and run node --experimental-strip-types config.mts or python config.py. The embedded SDK needs no AGINDOW key or endpoint. All shown options are optional construction values; mode defaults to observe, allowed tools to all and event buffer to 100. The explicit tool/operation describes this callable. Node readiness is a settling Promise; Python readiness is a boolean and load_error retains failure. An unavailable engine bypasses. This example preserves a local read, but meaningful statistical findings require the selection below.
import { createAgindow } from 'agindow';
const sdk = createAgindow({ mode: 'observe', allowedTools: ['crm.read'], buffer: 100 });
await sdk.ready;
const read = sdk.guard(() => ({ id: 'customer-123' }), {
tool: 'crm.read', operation: 'read',
});
console.log(read()); // Local fixture; no vendor call or configured detector.
console.log(sdk.recent()); // Local metadata, not a durable audit archive.from agindow import Agindow
sdk = Agindow(mode="observe", allowed_tools=("crm.read",), buffer=100)
assert sdk.ready, sdk.load_error
@sdk.guard(tool="crm.read", operation="read")
def read() -> dict[str, str]:
return {"id": "customer-123"}
print(read()) # Local fixture; no vendor call or configured detector.
print(sdk.recent()) # Local metadata, not a durable audit archive.
sdk.close()Configure SDK modes
Use observe for initial integration. Enable repair only after reviewing rules and evaluating independent verification. Strict applies the configured halt policy when eligible evidence cannot be resolved; it cannot prevent an already completed upstream operation or make unavailable inspection safe. Infrastructure faults still bypass in every mode.
import { createAgindow } from 'agindow';
const sdk = createAgindow({ mode: 'observe' });
await sdk.ready;
sdk.configure({ mode: 'observe' });
sdk.configure({ mode: 'repair' });
sdk.configure({ mode: 'strict' });
// Policy changes only; no detector or repair rule is supplied here.from agindow import Agindow
sdk = Agindow(mode="observe")
sdk.configure(mode="observe")
sdk.configure(mode="repair")
sdk.configure(mode="strict")
sdk.close()
# Policy changes only; no detector or repair rule is supplied here.| Mode | Purpose and actual behavior |
|---|---|
| observe | Inspect and report selected evidence. Never mutates or policy-blocks the original operation. |
| repair | Apply supported verified repairs at confidence ≥0.97. Unresolved reads degrade and shape drift passes through; semantic writes block. Unknown writes default closed. |
| strict | Apply verified repairs at confidence ≥0.99. Matched unresolved drift halts under strict policy, including incomplete repair; failClosed opt-out is ignored. |
Configure drift detection
Runnable labelled magnitude-shift fixture: save as detect-config.mts or detect_config.py and use the same runtime commands as above. StatisticalSelection scopes tenant, connection, vendor, operation and segment; operation must match the guarded tool name. fields selects a JSON Pointer and request/response phase; baseline and live contain complete raw JSON documents from comparable independent calls. Production windows must come from permitted representative observations, not copies of one call. This small synthetic exercise supplies 128 samples per window and expects a drift event with the original value retained. Eligibility is detector-specific, not a universal 128-sample promise. Too few samples, missing fields, incompatible evidence or exhausted work can make detection ineligible or unavailable; no findings is not proof of a clean integration. Optional materiality sets a floor in (0,1], not repair permission. Keep selection outside configure updates.
import { createAgindow } from 'agindow';
import type { StatisticalSelection } from 'agindow';
// Labelled magnitude-shift fixture; repeated values are not production calibration.
const documents = (value: number): string[] =>
Array.from({ length: 128 }, () => JSON.stringify({ value }));
const selection: StatisticalSelection = {
tenant: 'demo', connection: 'local', vendor: 'synthetic',
operation: 'demo.detect', segment: 'default',
fields: [{ side: 'request', path: '/value', enumeration: true,
baseline: documents(1), live: documents(100) }],
};
const sdk = createAgindow({ mode: 'observe', selection });
await sdk.ready;
const input = { value: 100 };
const result = sdk.guard((body: object) => body, { tool: 'demo.detect', operation: 'read' })(input);
if (result !== input || !sdk.recent().some(event => event.type === 'drift')) {
throw Error('Expected an unchanged result and configured drift event');
}
console.log('Configured drift observed; original value retained');import json
from agindow import Agindow
# Labelled magnitude-shift fixture; repeated values are not production calibration.
def documents(value: int) -> list[str]:
return [json.dumps({"value": value}) for _ in range(128)]
selection: dict[str, object] = {
"tenant": "demo", "connection": "local", "vendor": "synthetic",
"operation": "demo.detect", "segment": "default",
"fields": [{"side": "request", "path": "/value", "enumeration": True,
"baseline": documents(1), "live": documents(100)}],
}
sdk = Agindow(mode="observe", selection=selection)
assert sdk.ready, sdk.load_error
@sdk.guard(tool="demo.detect", operation="read")
def inspect(body: dict[str, int]) -> dict[str, int]:
return body
value = {"value": 100}
assert inspect(value) is value
assert any(event.type == "drift" for event in sdk.recent())
sdk.close()
print("Configured drift observed; original value retained")Enable selective repair
Selective repair is off by default. Supply reviewed top-level rename facts through Node selectiveRepair: {rules, verify}, or Python selective_repair=SelectiveRepair(rules=(RenameRule(...),), verify=verify). The independent synchronous verifier receives immutable RepairCheck before/after JSON and the scoped rule; exactly true/True accepts. The runnable local example below checks a reviewed customer-name snapshot, first observes unchanged input, then applies contact_name → display_name in repair mode and checks a repair event. Run it as repair.mts or repair.py. Replace the fixture data/callable with your reviewed application facts and existing client; prepare authoritative facts off-path, without verifier network/database/LLM calls. It is not arbitrary semantic correction, source rewriting or PR publication.
import { createAgindow } from 'agindow';
import type { RepairCheck } from 'agindow';
// Load authoritative application data and reviewed migration facts outside calls.
const names = new Map([['customer-123', 'Ada']]);
function verify(check: RepairCheck): boolean {
const before = JSON.parse(check.before) as Record<string, unknown>;
const after = JSON.parse(check.after) as Record<string, unknown>;
return check.rule.migration === 'crm-name-v2-reviewed'
&& typeof after['id'] === 'string'
&& names.has(after['id'])
&& before['id'] === after['id']
&& before['contact_name'] === names.get(after['id'])
&& after['display_name'] === names.get(after['id']);
}
const sdk = createAgindow({ mode: 'observe', selectiveRepair: {
rules: [{ tool: 'crm.create', side: 'request', from: 'contact_name', to: 'display_name',
migration: 'crm-name-v2-reviewed', confidence: 1 }], verify,
} });
await sdk.ready;
// Local fixture callable; replace with your existing API client after review.
const create = sdk.guard((payload: object) => payload, { tool: 'crm.create', operation: 'write' });
const input = { id: 'customer-123', contact_name: 'Ada' };
if (create(input) !== input) throw Error('Observe changed the input');
sdk.configure({ mode: 'repair' });
const repaired = create(input) as Record<string, unknown>;
if (repaired['display_name'] !== 'Ada' || 'contact_name' in repaired) throw Error('Repair was not applied');
if (!sdk.recent().some(event => event.type === 'repair')) throw Error('Repair event missing');
console.log('Reviewed local rename verified and applied');import json
from agindow import Agindow, Config, RenameRule, RepairCheck, SelectiveRepair
# Load authoritative application data and reviewed migration facts outside calls.
names = {"customer-123": "Ada"}
def verify(check: RepairCheck) -> bool:
before = json.loads(check.before)
after = json.loads(check.after)
return bool(check.rule.migration == "crm-name-v2-reviewed"
and after.get("id") in names and before.get("id") == after.get("id")
and before.get("contact_name") == names[after["id"]]
and after.get("display_name") == names[after["id"]])
sdk = Agindow(Config(mode="observe"), selective_repair=SelectiveRepair(
rules=(RenameRule(tool="crm.create", side="request", source="contact_name", target="display_name",
migration="crm-name-v2-reviewed", confidence=1.0),), verify=verify))
assert sdk.ready, sdk.load_error
# Local fixture callable; replace with your existing API client after review.
@sdk.guard(tool="crm.create", operation="write")
def create(payload: dict[str, str]) -> dict[str, str]:
return payload
value = {"id": "customer-123", "contact_name": "Ada"}
assert create(value) is value
sdk.configure(mode="repair")
assert create(value) == {"id": "customer-123", "display_name": "Ada"}
assert any(event.type == "repair" for event in sdk.recent())
print("Reviewed local rename verified and applied")Common configuration options
Use the smallest group that meets your task. Node constructor accepts Options (including Config); per-call GuardOptions names the callable boundary. Python accepts a Config or snake_case keywords plus explicit construction-only selection, work and selective_repair.
| Task | Settings and constraints |
|---|---|
| Execution and policy | mode; failClosed / fail_closed; allowedTools / allowed_tools; denyTools / deny_tools. Exclusions skip inspection, not application execution. |
| Detection | Construction-only selection and work. Baseline/live arrays and materiality live inside selection; no automatic collection or hosted refresh. |
| Events | onEvent / on_event or sdk.on; buffer for local retention. Node audit FIFO requires explicit options and off-path drainAudit destination. |
| Remote | Explicit guardRemote or guard_remote options specify endpoint, auth/key and timeout. Embedded endpoint/apiKey metadata does not enable HTTP. |
| Repair | Construction-only selectiveRepair / selective_repair with scoped rules and synchronous verifier. Confidence/policy gates remain in force. |
Precedence and updates
Construction resolves sources once; configure does not reload environment variables or JSON. Both hosts freeze a configuration snapshot for each executing call through completion. selection, work, selective repair and Node audit are construction-only; create another instance to change them.
| Boundary | Order, highest priority first |
|---|---|
| Node construction | Explicit constructor values > environment > nearest JSON .agindowrc > defaults. |
| Python construction | Keyword overrides > explicitly supplied whole Config (when present); otherwise keywords > environment > nearest JSON .agindowrc > defaults. Sources are still validated. |
| Node future calls | Initial guard overrides apply to initial policy. Later sdk.configure revisions can supersede those settings on existing guards. |
| Python future calls | Guard keyword overrides > current task context > instance configuration. configure changes future instance snapshots; active contexts remain scoped to that instance/task. |
| In-flight calls | Continue with the original snapshot; request and response policy do not change mid-call. |
Environment and JSON files
Both hosts search upward from the working directory for the nearest .agindowrc containing JSON; there is no YAML, package.json field or automatic .env loader. A malformed/invalid nearest file warns and is ignored without falling back to a parent file. Invalid environment or explicit values can raise AgindowSetupError even when shadowed by a higher-precedence value. Python rejects unknown Config keywords; its JSON accepts failClosed, apiKey, allowedTools and denyTools aliases and converts list scopes to tuples. Keep callbacks, windows and repair rules in construction code. Store credentials in secret storage or injected environment, never committed JSON.
{
"mode": "observe",
"buffer": 100,
"allowedTools": ["crm.read"]
}| Variable / runtime | Type, default and example |
|---|---|
| AGINDOW_MODE / both | observe | repair | strict; observe. Example: AGINDOW_MODE=observe. |
| AGINDOW_BUFFER / both | Integer 0–100000; 100. Example: AGINDOW_BUFFER=200; 0 disables recent retention. |
| AGINDOW_FAIL_CLOSED / both | Exactly true or false; true. Example: AGINDOW_FAIL_CLOSED=true. Semantic writes remain protected in repair; strict ignores false. |
| AGINDOW_KEY / both | Optional string; absent. Example: inject the host-issued key from secret storage. Embedded metadata, not remote option inheritance. |
| AGINDOW_ENDPOINT / both | Optional HTTP(S) URL; absent. Example: https://guard.example.invalid/v1/guard. Does not switch transport. |
| AGINDOW_SIDECAR / Node | Optional HTTP(S) URL; absent. Example: http://SIDECAR_HOST:8789, replacing SIDECAR_HOST with your configured local hostname. Metadata only. |
| AGINDOW_SPANS / Node | Exactly true or false; true. Example: AGINDOW_SPANS=false disables spans. |
| AGINDOW_DEBUG / Node | Exactly true or false; absent. Example: AGINDOW_DEBUG=true. Accepted metadata. |
Configuration recipes
A — Observe an existing integration: use the minimal configuration and replace the local callable with your existing API client; name the tool and operation. B — Detect a supported field change: add a scoped selection with comparable representative windows; inspect drift events and eligibility, as in the compact detection fixture. C — Enable a reviewed repair: provide reviewed rename rules and independent verifier at construction, observe first, then configure repair after evaluation. Inspect repair events; mere proposals are not applied repairs. D — Control failure behavior: failClosed defaults true. Setting false affects unknown writes in repair mode; it does not opt semantic writes out, and strict ignores the opt-out. Reads in repair degrade rather than block. Internal faults bypass, while upstream exceptions propagate. Request policy halts precede dispatch; response halts retain an already completed outcome. Inspect AgindowDriftError.phase and outcome before any retry. These are configuration recipes; the earlier complete programs are local executable fixtures, not live vendor qualification.
Complete configuration reference
The category-specific tables below retain the exact types, defaults, required fields and repair limits. Use Node type-only imports for Config, Options, GuardOptions, StatisticalSelection, SelectiveRepairOptions, RenameRule and RepairCheck. Python exports Config, SelectiveRepair, RenameRule and RepairCheck; selection is dict[str, object]. Shared Config fields are optional; detector field presence below is required once selection is supplied. Callback and construction objects belong in application code rather than JSON.
Shared call settings
Node uses camelCase; Python keyword settings use snake_case. Defaults below apply before configuration sources and per-call overrides. configure changes future calls; an executing call keeps its snapshot.
| Node / Python | Type and default | Behavior |
|---|---|---|
| mode / mode | observe | repair | strict; observe | Controls handling of findings, not detector selection. |
| failClosed / fail_closed | boolean; true | Opt-out affects unknown writes in repair mode. Semantic writes stay protected; strict ignores the opt-out. |
| allowedTools / allowed_tools | string array / tuple or "*"; "*" | Select tools eligible for inspection. |
| denyTools / deny_tools | string array / tuple; empty | Excludes tools from inspection. |
| buffer / buffer | integer 0–100000; 100 | Maximum recent event metadata retained locally; 0 disables retention. |
| onEvent / on_event | callback; absent | Receives events. Listener errors are contained. |
| apiKey / api_key; endpoint / endpoint | optional strings; absent | Do not switch an embedded guard to HTTP. Use explicit remote helpers for HTTP transport. |
StatisticalSelection
Node exports the StatisticalSelection type. Python accepts the equivalent JSON-compatible dict[str, object] as selection. Required scope strings identify the dataset; they do not provide authentication or vendor credentials.
| Field | Type / presence | Meaning |
|---|---|---|
| tenant, connection, vendor, operation, segment | strings; required | Scope the comparison. operation matches the guarded tool name. |
| fields | array; required | Explicit field comparisons. No inferred selection. |
| fields[].side | request | response; required | Which inspection phase owns the field. |
| fields[].path | string; required | Selected JSON Pointer, for example /value. |
| fields[].baseline; fields[].live | arrays of strings; required | Complete raw JSON documents from comparable independent calls. |
| fields[].enumeration | boolean; required | Whether enumeration comparison is enabled for that field. |
| materiality | optional number in (0, 1] | Explicit materiality floor; not repair authority. |
| work | construction integer u32; 200000000 | Guest work allowance, not milliseconds. Exhaustion does not authorize a finding or repair. |
Repair rule reference
Node RenameRule uses tool, side, from, to, migration and confidence. Python RenameRule uses tool, side, source, target, migration and confidence. Without parents, keys are simple top-level object names of up to 64 ASCII letters, digits or underscores, starting with a letter or underscore. One rule per tool/side, at most 16 rules. Tool and migration IDs contain 1–256 non-control characters. confidence is a required finite number from 0 to 1; side is request or response. The six base fields are required. Optional parents selects concrete RFC 6901 object-parent pointers (including array indices); it requires contract, provenance and expiresAt (Python expires_at), with no wildcards. Root-only legacy rules remain supported. The verifier receives RepairCheck with before, after and rule, returning exactly true/True to approve. It must check independent authoritative meaning or business evidence; copying values or validating a schema alone cannot establish intent. Prepare evidence outside calls; do not perform network or database I/O in the verifier.
Repair decisions and limits
Observe reports matched rules without changing payloads. Repair requires confidence at least 0.97; strict requires 0.99. Source absence preserves identity. Destination collisions, low confidence and verifier refusal leave payloads unchanged; strict halts matched unresolved drift, and repair passes unresolved shape drift through under the shared Rust policy; semantic-write blocks remain in force. Statistical findings or halts, malformed results and bypass are never cleared to permit a repair. Verifier faults, async results and unavailable capture preserve upstream behavior through bypass. Supported payloads are plain JSON objects and Node RawJson boundaries, with complete captures up to 1 MiB. Opt-in repair divides the work allowance across statistical inspection and the two preparation phases. The published pair additionally supports reviewed concrete nested/array renames and ScalarRule recipes for finite string maps, literal empty-string-to-null normalization and bounded exact unit/epoch scaling. ScalarFacts are mandatory, scoped and expiring; semantic repairs require confidence at least 0.99 and independent host preservation/arithmetic verification. Ambiguous paths, collisions, stale facts and lossy projections refuse. Automatic discovery and general array migrations remain unsupported. Node guest audit FIFO cannot be combined with selectiveRepair; use repair events for local observation. This does not provide a durable repair archive or persisted write proof.
Node-specific options
These fields are not Python Config keywords. Types are exported as Config, Options and GuardOptions; use type-only imports in TypeScript. Node defaults spans to true. The headers, transformers, sync, endpoint, sidecar and debug fields are accepted configuration metadata; they do not activate header injection, a transformation pipeline, polling or transport.
| Option | Type / default | Purpose |
|---|---|---|
| spans; debug | optional booleans; true / absent | OTel span emission and debug configuration. |
| headers | string record; absent | Accepted metadata; no automatic header injection. |
| transformers | record of (value: unknown) => unknown; absent | Accepted callback metadata; no automatic transformer pipeline. |
| sidecar; sync | URL string; {contracts?: number, drift?: number} | Configuration metadata; does not select remote execution or provision refresh. |
| audit | {tenant: string, capacity?: number, maxBytes?: number}; absent | Opt-in guest FIFO. Default capacity 64 (1–256); maxBytes 524288 (1024–1048576). Audit tenant must match selection tenant. |
Guard options and operation identity
guard(fn, options) and Python guard(fn, **options) accept tool and operation plus call-policy settings. operation is read, write or unknown; generic callables default to read. Label writes and uncertain operations explicitly. Node also supports toolName for dynamic names and inputShape raw or parsed. A function returning a Promise stays asynchronous; Python coroutine functions stay asynchronous. Unsupported adapter shapes need an explicit supported callable boundary.