@directive-run/core 1.21.0 → 1.23.0
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.
- package/README.md +2 -2
- package/dist/adapter-utils.cjs +1 -1
- package/dist/adapter-utils.d.cts +1 -1
- package/dist/adapter-utils.d.ts +1 -1
- package/dist/adapter-utils.js +1 -1
- package/dist/chunk-AFPLATPV.js +16 -0
- package/dist/chunk-AFPLATPV.js.map +1 -0
- package/dist/{chunk-4OXCKDKS.cjs → chunk-FCCJUQB2.cjs} +3 -3
- package/dist/chunk-FCCJUQB2.cjs.map +1 -0
- package/dist/chunk-IZNOPHPL.js +3 -0
- package/dist/chunk-IZNOPHPL.js.map +1 -0
- package/dist/chunk-LN5H74CU.js +2 -0
- package/dist/{chunk-RBF653NR.js.map → chunk-LN5H74CU.js.map} +1 -1
- package/dist/chunk-PJIIBQTK.js +2 -0
- package/dist/chunk-PJIIBQTK.js.map +1 -0
- package/dist/chunk-PTT4MWNL.cjs +3 -0
- package/dist/chunk-PTT4MWNL.cjs.map +1 -0
- package/dist/{chunk-GKMJ7NMP.cjs → chunk-RD2HO5NZ.cjs} +2 -2
- package/dist/{chunk-GKMJ7NMP.cjs.map → chunk-RD2HO5NZ.cjs.map} +1 -1
- package/dist/{chunk-GACC2DMS.cjs → chunk-S6W6Y44G.cjs} +2 -2
- package/dist/{chunk-GACC2DMS.cjs.map → chunk-S6W6Y44G.cjs.map} +1 -1
- package/dist/{chunk-6PF2FRBG.js → chunk-WD47DB52.js} +2 -2
- package/dist/{chunk-6PF2FRBG.js.map → chunk-WD47DB52.js.map} +1 -1
- package/dist/chunk-WKGNK4QK.cjs +2 -0
- package/dist/chunk-WKGNK4QK.cjs.map +1 -0
- package/dist/chunk-WVP3GOY2.js +3 -0
- package/dist/chunk-WVP3GOY2.js.map +1 -0
- package/dist/chunk-XKXTRVJF.cjs +3 -0
- package/dist/chunk-XKXTRVJF.cjs.map +1 -0
- package/dist/{index-CvQuu0tu.d.cts → index-DpvgHVHR.d.cts} +29 -2
- package/dist/{index-DUbpbGw8.d.ts → index-n8oQmdOZ.d.ts} +29 -2
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -164
- package/dist/index.d.ts +46 -164
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +1 -1
- package/dist/internals.d.cts +45 -25
- package/dist/internals.d.ts +45 -25
- package/dist/internals.js +1 -1
- package/dist/plugins/index.cjs +2 -2
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +358 -3
- package/dist/plugins/index.d.ts +358 -3
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/index.js.map +1 -1
- package/dist/{plugins-4IfhJV32.d.cts → plugins-CaPMTICa.d.cts} +400 -31
- package/dist/{plugins-4IfhJV32.d.ts → plugins-CaPMTICa.d.ts} +400 -31
- package/dist/{predicate-DBTPnlg6.d.cts → predicate-CU0YC1i6.d.cts} +1 -1
- package/dist/{predicate-BW05x5el.d.ts → predicate-CgpwJqf4.d.ts} +1 -1
- package/dist/system-HOP37Z4V.js +2 -0
- package/dist/{system-SJBP4TO5.js.map → system-HOP37Z4V.js.map} +1 -1
- package/dist/system-VZUHL56W.cjs +2 -0
- package/dist/{system-SB7JYMRB.cjs.map → system-VZUHL56W.cjs.map} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4OXCKDKS.cjs.map +0 -1
- package/dist/chunk-6QAUJFQH.js +0 -3
- package/dist/chunk-6QAUJFQH.js.map +0 -1
- package/dist/chunk-E53A4NHM.js +0 -16
- package/dist/chunk-E53A4NHM.js.map +0 -1
- package/dist/chunk-GBCWXTXW.cjs +0 -3
- package/dist/chunk-GBCWXTXW.cjs.map +0 -1
- package/dist/chunk-KGTBTGOY.js +0 -2
- package/dist/chunk-KGTBTGOY.js.map +0 -1
- package/dist/chunk-M5PEB553.cjs +0 -3
- package/dist/chunk-M5PEB553.cjs.map +0 -1
- package/dist/chunk-MARZI3EY.cjs +0 -2
- package/dist/chunk-MARZI3EY.cjs.map +0 -1
- package/dist/chunk-RBF653NR.js +0 -2
- package/dist/chunk-SFUVPP4L.js +0 -3
- package/dist/chunk-SFUVPP4L.js.map +0 -1
- package/dist/system-SB7JYMRB.cjs +0 -2
- package/dist/system-SJBP4TO5.js +0 -2
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AuditEntry, a as AuditEntryKind, b as AuditLedger, c as AuditLedgerOptions, d as AuditLedgerSink, Q as QueryFilter, e as createAuditLedger, m as memorySink } from '../index-
|
|
2
|
-
import { M as ModuleSchema, P as Plugin,
|
|
1
|
+
export { A as AuditEntry, a as AuditEntryKind, b as AuditLedger, c as AuditLedgerOptions, d as AuditLedgerSink, Q as QueryFilter, e as createAuditLedger, m as memorySink } from '../index-n8oQmdOZ.js';
|
|
2
|
+
import { M as ModuleSchema, P as Plugin, aA as System, ak as PredicateOverlapProof } from '../plugins-CaPMTICa.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Logging Plugin - Console logging for Directive events
|
|
@@ -845,4 +845,359 @@ declare class CircuitBreakerOpenError extends Error {
|
|
|
845
845
|
*/
|
|
846
846
|
declare function createCircuitBreaker(config?: CircuitBreakerConfig): CircuitBreaker;
|
|
847
847
|
|
|
848
|
-
|
|
848
|
+
/**
|
|
849
|
+
* Clobber Alert Plugin – default high-severity alerting for
|
|
850
|
+
* `resolver.write.rejected { reason: "clobbered" }` events landing on
|
|
851
|
+
* facts tagged irreversible.
|
|
852
|
+
*
|
|
853
|
+
* The audit ledger already records every clobber event with full
|
|
854
|
+
* forensic detail (fact, expected, actual, resolver, requirementId).
|
|
855
|
+
* But a clobber on a fact tagged `"money"` / `"pii"` / `"irreversible"`
|
|
856
|
+
* is operationally far more urgent than a clobber on a UI status fact.
|
|
857
|
+
* Without this plugin, a consumer has to write their own SIEM rule to
|
|
858
|
+
* separate "noise" from "page an engineer NOW."
|
|
859
|
+
*
|
|
860
|
+
* Default behaviour: fire `console.error` on every clobber whose fact's
|
|
861
|
+
* schema meta carries any tag in `irreversibleTags`. Replace the
|
|
862
|
+
* `onAlert` callback to route to PagerDuty / Slack / Sentry / your SIEM
|
|
863
|
+
* of choice.
|
|
864
|
+
*
|
|
865
|
+
* @public
|
|
866
|
+
*/
|
|
867
|
+
|
|
868
|
+
/** Configuration for the {@link clobberAlertPlugin}. */
|
|
869
|
+
interface ClobberAlertPluginOptions {
|
|
870
|
+
/**
|
|
871
|
+
* Fact-meta tags that promote a clobber event from "noise" to
|
|
872
|
+
* "high-severity alert." A clobber whose fact's schema meta carries
|
|
873
|
+
* ANY of these tags fires `onAlert`.
|
|
874
|
+
*
|
|
875
|
+
* **Why tag the fact, not the resolver?** A clobber is detected at
|
|
876
|
+
* fact-write time. The audit event payload (`fact`, `expected`,
|
|
877
|
+
* `actual`) names the fact, not the side effect — the fact is the
|
|
878
|
+
* trigger surface for any irreversible work the resolver is about
|
|
879
|
+
* to do (a charge, a send, a delete). Tagging `payment.amount` with
|
|
880
|
+
* `"money"` marks the fact whose race-loss should page someone.
|
|
881
|
+
*
|
|
882
|
+
* If your model puts the irreversibility on the resolver rather than
|
|
883
|
+
* the fact, use `irreversibleResolvers` — both filters OR.
|
|
884
|
+
*
|
|
885
|
+
* Default: `["money", "pii", "irreversible"]`.
|
|
886
|
+
*/
|
|
887
|
+
irreversibleTags?: readonly string[];
|
|
888
|
+
/**
|
|
889
|
+
* Resolver IDs whose clobbered writes should always alert, regardless
|
|
890
|
+
* of fact tags. Use this when irreversibility is modeled on the
|
|
891
|
+
* resolver (e.g. `stripeCharge`) rather than on the trigger fact.
|
|
892
|
+
* Defaults to empty — the fact-tag path covers most cases.
|
|
893
|
+
*/
|
|
894
|
+
irreversibleResolvers?: readonly string[];
|
|
895
|
+
/**
|
|
896
|
+
* Callback fired when a clobber lands on a fact whose tags overlap
|
|
897
|
+
* `irreversibleTags`, or whose resolver is in `irreversibleResolvers`.
|
|
898
|
+
* Default: `console.error(...)`.
|
|
899
|
+
*/
|
|
900
|
+
onAlert?: (event: ClobberAlertEvent) => void;
|
|
901
|
+
/**
|
|
902
|
+
* Callback fired when the engine's per-resolver rate limit aggregates
|
|
903
|
+
* multiple per-write clobber events into a single
|
|
904
|
+
* `kind: "summary"` event (default cap: 10 per-resolver-instance).
|
|
905
|
+
* The summary names the resolver + dropped count but loses per-fact
|
|
906
|
+
* attribution — the engine has no way to enumerate every dropped
|
|
907
|
+
* write inside the cap.
|
|
908
|
+
*
|
|
909
|
+
* Only fires when EITHER:
|
|
910
|
+
* - the resolver is listed in `irreversibleResolvers`, OR
|
|
911
|
+
* - this plugin has previously fired `onAlert` for the resolver
|
|
912
|
+
* (i.e. the resolver has touched an irreversible fact in this
|
|
913
|
+
* session, so a follow-on burst is operationally relevant)
|
|
914
|
+
*
|
|
915
|
+
* Default: undefined (no summary alerts). Set this to preserve
|
|
916
|
+
* SIEM telemetry past the engine's rate-limit cap on a hot
|
|
917
|
+
* resolver fighting an irreversible fact.
|
|
918
|
+
*/
|
|
919
|
+
onSummary?: (event: ClobberSummaryEvent) => void;
|
|
920
|
+
/**
|
|
921
|
+
* Cooldown window keyed by `(fact, resolver)` pair. A second clobber
|
|
922
|
+
* from the same resolver on the same fact within this window does not
|
|
923
|
+
* re-fire `onAlert`. A clobber from a *different* resolver on the
|
|
924
|
+
* same fact still fires — fighting writers are a different
|
|
925
|
+
* operational incident than a single resolver retrying.
|
|
926
|
+
*
|
|
927
|
+
* The audit ledger records every clobber regardless of cooldown.
|
|
928
|
+
*
|
|
929
|
+
* Default: `0` (no cooldown — every event alerts).
|
|
930
|
+
*/
|
|
931
|
+
cooldownMs?: number;
|
|
932
|
+
}
|
|
933
|
+
/** Payload passed to {@link ClobberAlertPluginOptions.onAlert}. */
|
|
934
|
+
interface ClobberAlertEvent {
|
|
935
|
+
readonly fact: string;
|
|
936
|
+
/**
|
|
937
|
+
* Fact-meta tags that matched `irreversibleTags`. Empty when the alert
|
|
938
|
+
* fired only because the resolver matched `irreversibleResolvers`.
|
|
939
|
+
* Use {@link matchedBy} to distinguish without checking length.
|
|
940
|
+
*/
|
|
941
|
+
readonly tags: readonly string[];
|
|
942
|
+
/**
|
|
943
|
+
* Which filter triggered the alert:
|
|
944
|
+
* - `"tag"` — fact-meta tags overlapped `irreversibleTags`
|
|
945
|
+
* - `"resolver"` — resolver ID matched `irreversibleResolvers`
|
|
946
|
+
* - `"both"` — both filters matched
|
|
947
|
+
*/
|
|
948
|
+
readonly matchedBy: "tag" | "resolver" | "both";
|
|
949
|
+
readonly resolver: string;
|
|
950
|
+
readonly requirementId: string;
|
|
951
|
+
readonly expected: unknown;
|
|
952
|
+
readonly actual: unknown;
|
|
953
|
+
/** `Date.now()` at the moment the alert fired. */
|
|
954
|
+
readonly timestamp: number;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Payload passed to {@link ClobberAlertPluginOptions.onSummary}.
|
|
958
|
+
*
|
|
959
|
+
* Fired when the engine's per-resolver clobber rate-limit aggregates
|
|
960
|
+
* multiple per-write events into one summary. Per-fact attribution is
|
|
961
|
+
* lost (the engine cannot enumerate every dropped write inside the
|
|
962
|
+
* cap), but the resolver + dropped count are preserved so SIEM can
|
|
963
|
+
* page on "this resolver is still fighting an irreversible fact
|
|
964
|
+
* past the cap."
|
|
965
|
+
*/
|
|
966
|
+
interface ClobberSummaryEvent {
|
|
967
|
+
readonly resolver: string;
|
|
968
|
+
readonly requirementId: string;
|
|
969
|
+
/** Number of per-write clobber events the engine suppressed under the cap. */
|
|
970
|
+
readonly dropped: number;
|
|
971
|
+
/**
|
|
972
|
+
* Why the summary surfaced from this plugin's filter:
|
|
973
|
+
* - `"resolver-listed"` — the resolver was in `irreversibleResolvers`
|
|
974
|
+
* - `"prior-irreversible-alert"` — the resolver had already fired
|
|
975
|
+
* `onAlert` on an irreversible fact in this session
|
|
976
|
+
*/
|
|
977
|
+
readonly matchedBy: "resolver-listed" | "prior-irreversible-alert";
|
|
978
|
+
/** `Date.now()` at the moment the summary fired. */
|
|
979
|
+
readonly timestamp: number;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Create a plugin that fires high-severity alerts for clobber events
|
|
983
|
+
* landing on irreversible-tagged facts.
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* ```ts
|
|
987
|
+
* createSystem({
|
|
988
|
+
* module: myModule,
|
|
989
|
+
* plugins: [
|
|
990
|
+
* clobberAlertPlugin({
|
|
991
|
+
* irreversibleTags: ["money", "pii"],
|
|
992
|
+
* onAlert: (e) => pagerduty.trigger({
|
|
993
|
+
* severity: "critical",
|
|
994
|
+
* summary: `Clobber on ${e.fact} (${e.tags.join(", ")})`,
|
|
995
|
+
* details: e,
|
|
996
|
+
* }),
|
|
997
|
+
* }),
|
|
998
|
+
* ],
|
|
999
|
+
* });
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
declare function clobberAlertPlugin<M extends ModuleSchema>(options?: ClobberAlertPluginOptions): Plugin<M>;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Clobber Loop Detector Plugin – fires a structured warning when the
|
|
1006
|
+
* same set of resolvers clobber the same fact above threshold within a
|
|
1007
|
+
* time window. A single clobber is fine — the `abortOn:` binding caught
|
|
1008
|
+
* the race and the audit ledger recorded it. A *loop* is two or more
|
|
1009
|
+
* resolvers whose `when:` predicates both satisfy a shared state and
|
|
1010
|
+
* keep rewriting the fact every reconcile tick, indefinitely.
|
|
1011
|
+
*
|
|
1012
|
+
* Today the symptom surfaces as a value flapping between two states in
|
|
1013
|
+
* a customer screenshot. The audit ledger holds the forensic evidence
|
|
1014
|
+
* (800 clobbers/sec on `cart.discount`), but nobody looks until a
|
|
1015
|
+
* customer complains. This plugin closes the loop: one structured
|
|
1016
|
+
* warning per detected loop, with a **predicate-overlap proof** built
|
|
1017
|
+
* from the participants' `whenSpec` so the warning points at the
|
|
1018
|
+
* specific clauses that co-fire instead of stopping at "these resolvers
|
|
1019
|
+
* fight."
|
|
1020
|
+
*
|
|
1021
|
+
* @public
|
|
1022
|
+
*/
|
|
1023
|
+
|
|
1024
|
+
/** Configuration for the {@link clobberLoopPlugin}. */
|
|
1025
|
+
interface ClobberLoopPluginOptions {
|
|
1026
|
+
/**
|
|
1027
|
+
* Window over which clobber-rejection events are aggregated. A loop
|
|
1028
|
+
* fires when `threshold` distinct-requirement rejections involving
|
|
1029
|
+
* ≥2 distinct resolvers land on the same fact within `windowMs`.
|
|
1030
|
+
*
|
|
1031
|
+
* Default: 1000ms. Catches the canonical "5 clobbers in <500ms" case
|
|
1032
|
+
* while sitting well outside tick-boundary noise.
|
|
1033
|
+
*/
|
|
1034
|
+
windowMs?: number;
|
|
1035
|
+
/**
|
|
1036
|
+
* Minimum distinct-requirement rejection count within `windowMs` to
|
|
1037
|
+
* trigger a loop event. Distinct by `requirement.id`, so a single
|
|
1038
|
+
* resolver's retry storm (which shares one requirement id) counts as
|
|
1039
|
+
* one rejection and never crosses the threshold alone — only true
|
|
1040
|
+
* multi-participant contention does.
|
|
1041
|
+
*
|
|
1042
|
+
* Default: 5.
|
|
1043
|
+
*/
|
|
1044
|
+
threshold?: number;
|
|
1045
|
+
/**
|
|
1046
|
+
* After a loop fires on a `(fact, participantSet)`, suppress same-key
|
|
1047
|
+
* re-fire for this duration. Mirrors `clobberAlertPlugin`'s
|
|
1048
|
+
* cooldown precedent.
|
|
1049
|
+
*
|
|
1050
|
+
* Default: 5000ms.
|
|
1051
|
+
*/
|
|
1052
|
+
cooldownMs?: number;
|
|
1053
|
+
/**
|
|
1054
|
+
* Quiet window after the last contributing clobber rejection before
|
|
1055
|
+
* the loop is considered closed and a `resolver.clobber.loop.resolved`
|
|
1056
|
+
* event fires. The resolver may have shipped a fix (priority added,
|
|
1057
|
+
* `when:` narrowed), or the surrounding state changed enough that
|
|
1058
|
+
* both participants no longer co-fire.
|
|
1059
|
+
*
|
|
1060
|
+
* Default: 30000ms.
|
|
1061
|
+
*/
|
|
1062
|
+
resolvedAfterMs?: number;
|
|
1063
|
+
/**
|
|
1064
|
+
* Global LRU cap on the number of facts the detector tracks. A
|
|
1065
|
+
* hot-then-cold attacker fact key can churn the map, but LRU
|
|
1066
|
+
* eviction ensures the legitimate hot fact stays resident. Memory
|
|
1067
|
+
* bound: ~32 ring-buffer entries × `maxTrackedFacts` slim records.
|
|
1068
|
+
*
|
|
1069
|
+
* Default: 256.
|
|
1070
|
+
*/
|
|
1071
|
+
maxTrackedFacts?: number;
|
|
1072
|
+
/**
|
|
1073
|
+
* Per-fact cap on participant resolver tracking. Above this, a single
|
|
1074
|
+
* "N-way contention on fact X" event fires once and detailed
|
|
1075
|
+
* participant tracking pauses for the cooldown window.
|
|
1076
|
+
*
|
|
1077
|
+
* Default: 16.
|
|
1078
|
+
*/
|
|
1079
|
+
maxParticipantsPerFact?: number;
|
|
1080
|
+
/**
|
|
1081
|
+
* Global emission cap (loop-events per second across all facts). A
|
|
1082
|
+
* storm where every fact enters a loop simultaneously should not blow
|
|
1083
|
+
* up the observation bus or pager. Above-cap detections increment a
|
|
1084
|
+
* counter and surface in the next emitted event's
|
|
1085
|
+
* `suppressedSinceLastEmit` field.
|
|
1086
|
+
*
|
|
1087
|
+
* Default: 10.
|
|
1088
|
+
*/
|
|
1089
|
+
maxEmissionsPerSec?: number;
|
|
1090
|
+
/**
|
|
1091
|
+
* Callback fired when a loop is detected. The payload is the
|
|
1092
|
+
* fully-constructed event including PII-redacted `predicateOverlap`
|
|
1093
|
+
* (when applicable).
|
|
1094
|
+
*
|
|
1095
|
+
* Default in dev mode: `console.warn` with the structured warning
|
|
1096
|
+
* text. Default in production: `console.error` to stderr — NOT noop,
|
|
1097
|
+
* so the signal still lands in CloudWatch/Loki/Datadog log pipelines
|
|
1098
|
+
* even when consumers haven't explicitly wired routing.
|
|
1099
|
+
*/
|
|
1100
|
+
onLoop?: (event: ClobberLoopDetectedEvent) => void;
|
|
1101
|
+
/**
|
|
1102
|
+
* Callback fired when a previously-detected loop is considered
|
|
1103
|
+
* resolved (quiet window elapsed, participant unregistered, or
|
|
1104
|
+
* predicate narrowed).
|
|
1105
|
+
*
|
|
1106
|
+
* Default: no-op. Wire when monitoring needs "5 active loops" rather
|
|
1107
|
+
* than "47 historical loops."
|
|
1108
|
+
*/
|
|
1109
|
+
onResolved?: (event: ClobberLoopResolvedEvent) => void;
|
|
1110
|
+
/**
|
|
1111
|
+
* Opt-out of PII redaction in the emitted event's `predicateOverlap`
|
|
1112
|
+
* clauses. The default (`false`) routes `whenSpec` operand pointers
|
|
1113
|
+
* through `redactWhenSpec` against `system.meta.byTag("pii")` BEFORE
|
|
1114
|
+
* the event is constructed, so downstream sinks see `[redacted]` in
|
|
1115
|
+
* place of the literal operand.
|
|
1116
|
+
*
|
|
1117
|
+
* Set to `true` only when the deployment has a data-processing
|
|
1118
|
+
* addendum that permits unredacted operand capture.
|
|
1119
|
+
*
|
|
1120
|
+
* Default: `false`.
|
|
1121
|
+
*/
|
|
1122
|
+
capturePII?: boolean;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Emitted payload for {@link ClobberLoopPluginOptions.onLoop}. Identical
|
|
1126
|
+
* shape to the `"resolver.clobber.loop.detected"` ObservationEvent so
|
|
1127
|
+
* consumers can route the same code path through either surface.
|
|
1128
|
+
*
|
|
1129
|
+
* @public
|
|
1130
|
+
*/
|
|
1131
|
+
interface ClobberLoopDetectedEvent {
|
|
1132
|
+
readonly systemId: string;
|
|
1133
|
+
readonly fact: string;
|
|
1134
|
+
readonly participants: readonly string[];
|
|
1135
|
+
readonly participantModules: readonly string[];
|
|
1136
|
+
readonly count: number;
|
|
1137
|
+
readonly windowMs: number;
|
|
1138
|
+
readonly firstAt: number;
|
|
1139
|
+
readonly lastAt: number;
|
|
1140
|
+
readonly predicateOverlap?: PredicateOverlapProof;
|
|
1141
|
+
readonly severity: "warn" | "error";
|
|
1142
|
+
readonly factTags: readonly string[];
|
|
1143
|
+
readonly suppressedSinceLastEmit: number;
|
|
1144
|
+
readonly rejectionSeqs: readonly number[];
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Emitted payload for {@link ClobberLoopPluginOptions.onResolved}.
|
|
1148
|
+
*
|
|
1149
|
+
* @public
|
|
1150
|
+
*/
|
|
1151
|
+
interface ClobberLoopResolvedEvent {
|
|
1152
|
+
readonly systemId: string;
|
|
1153
|
+
readonly fact: string;
|
|
1154
|
+
readonly participants: readonly string[];
|
|
1155
|
+
readonly durationMs: number;
|
|
1156
|
+
readonly resolution: "no-recurrence-in-window" | "participant-disabled" | "predicate-narrowed";
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Runtime kill-switch handle returned alongside the plugin. Lets an SRE
|
|
1160
|
+
* flip the detector off during incident response without redeploying.
|
|
1161
|
+
* `disable()` stops emission but preserves buffer state so `enable()`
|
|
1162
|
+
* resumes cleanly without warm-up drift.
|
|
1163
|
+
*
|
|
1164
|
+
* @public
|
|
1165
|
+
*/
|
|
1166
|
+
interface ClobberLoopPluginHandle<M extends ModuleSchema> {
|
|
1167
|
+
readonly plugin: Plugin<M>;
|
|
1168
|
+
disable(): void;
|
|
1169
|
+
enable(): void;
|
|
1170
|
+
isEnabled(): boolean;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Create a clobber-loop detector plugin. Returns a {@link
|
|
1174
|
+
* ClobberLoopPluginHandle} so callers can flip the detector off at
|
|
1175
|
+
* runtime without redeploying. The `.plugin` field is the value to
|
|
1176
|
+
* pass into `createSystem({ plugins: [...] })`.
|
|
1177
|
+
*
|
|
1178
|
+
* @example
|
|
1179
|
+
* ```ts
|
|
1180
|
+
* const loopDetector = clobberLoopPlugin({
|
|
1181
|
+
* threshold: 5,
|
|
1182
|
+
* windowMs: 1000,
|
|
1183
|
+
* onLoop: (e) => pagerduty.trigger({
|
|
1184
|
+
* severity: e.severity,
|
|
1185
|
+
* summary: `Clobber loop on ${e.fact}: ${e.participants.join(" vs ")}`,
|
|
1186
|
+
* details: e,
|
|
1187
|
+
* }),
|
|
1188
|
+
* });
|
|
1189
|
+
*
|
|
1190
|
+
* createSystem({
|
|
1191
|
+
* module: myModule,
|
|
1192
|
+
* plugins: [loopDetector.plugin],
|
|
1193
|
+
* });
|
|
1194
|
+
*
|
|
1195
|
+
* // During incident response:
|
|
1196
|
+
* loopDetector.disable();
|
|
1197
|
+
* ```
|
|
1198
|
+
*
|
|
1199
|
+
* @public
|
|
1200
|
+
*/
|
|
1201
|
+
declare function clobberLoopPlugin<M extends ModuleSchema>(options?: ClobberLoopPluginOptions): ClobberLoopPluginHandle<M>;
|
|
1202
|
+
|
|
1203
|
+
export { type AggregatedMetric, type AlertConfig, type AlertEvent, type CircuitBreaker, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitBreakerStats, type CircuitState, type ClobberAlertEvent, type ClobberAlertPluginOptions, type ClobberLoopDetectedEvent, type ClobberLoopPluginHandle, type ClobberLoopPluginOptions, type ClobberLoopResolvedEvent, type ConstraintMetrics, DEVTOOLS_EVENT_NAME, type DashboardData, type DevtoolsPluginOptions, type EffectMetrics, type HistogramBucket, type LoggingPluginOptions, type MetricDataPoint, type MetricType, type OTLPExporter, type OTLPExporterConfig, type ObservabilityConfig, type ObservabilityInstance, type PerformancePluginOptions, type PerformanceSnapshot, type PersistencePluginOptions, type ReconcileMetrics, type ResolverMetrics, type TraceEvent, type TraceSpan, clobberAlertPlugin, clobberLoopPlugin, createAgentMetrics, createCircuitBreaker, createOTLPExporter, createObservability, devtoolsPlugin, emitDevToolsEvent, loggingPlugin, performancePlugin, persistencePlugin };
|