@compr/opscontext-mcp 2.10.0 → 2.11.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/CHANGELOG.md +48 -1
- package/dist/audit.d.ts +70 -3
- package/dist/audit.js +664 -82
- package/dist/cli.js +54 -5
- package/dist/fleet-health.d.ts +23 -0
- package/dist/fleet-health.js +56 -0
- package/dist/http-server.js +12 -2
- package/dist/index.js +41 -3
- package/dist/secret-shapes.js +7 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,54 @@ All notable changes to OpsContext for AI Agents (previously ContextEngine — MC
|
|
|
4
4
|
|
|
5
5
|
> Entries for 2.2.0 through 2.4.0 were not backfilled here; see `docs/sessions/SESSION_19` through `SESSION_21` for those releases.
|
|
6
6
|
|
|
7
|
-
## [
|
|
7
|
+
## [2.11.0] 2026-09-27: the end-to-end review, phase B (the evidence stays true when things go wrong)
|
|
8
|
+
|
|
9
|
+
Fixes from the end-to-end review, phase B (`docs/audits/E2E_REVIEW_2026-09.md`, section "Phase B").
|
|
10
|
+
Every finding was replayed in real processes killed at the exact write, and on real full disks.
|
|
11
|
+
|
|
12
|
+
### Audit log
|
|
13
|
+
|
|
14
|
+
- **A log trim no longer keeps entries twice.** It took its size from one read of the file and its
|
|
15
|
+
records from another; entries that arrived in between were archived and kept again (29 copies in
|
|
16
|
+
the test on the old code; 20 real ones on 2026-09-25). The snapshot is now the bytes read.
|
|
17
|
+
LOCK `[ROTATION-SNAPSHOT-IS-THE-BYTES-READ]`. (B2-1)
|
|
18
|
+
- **The verifier names a copy a copy.** A record whose hash already appeared is counted once and
|
|
19
|
+
reported as a duplicate, not as a concurrent-append fork. (B2-1, B2-2)
|
|
20
|
+
- **A record cut short by a full disk no longer stops the log.** Every later append used to be
|
|
21
|
+
refused for good, only on stderr, while the receiver answered "written" and `emit-event` printed
|
|
22
|
+
"Appended". The fragment is now kept in `audit.torn-<time>.partial`, the log continues from its last
|
|
23
|
+
complete record, and an `audit.torn_tail` record says so. LOCK `[TORN-TAIL-IS-KEPT-AND-CHAINED]`. (B1-1)
|
|
24
|
+
- **The verifier reads past a line that is not a record**, names its file and line, and checks every
|
|
25
|
+
other record (it used to say "0 record(s) checked"). LOCK `[VERIFY-READS-PAST-AN-UNREADABLE-LINE]`.
|
|
26
|
+
- **A refused entry is counted and put on the chain.** `safeAppend()` returns whether it wrote; the
|
|
27
|
+
next good append chains an `audit.append_failed` record. The receiver answers 503 with the real
|
|
28
|
+
counts when the log refused entries; `emit-event` exits 1. LOCKs
|
|
29
|
+
`[A-REFUSED-APPEND-IS-COUNTED-AND-CHAINED]`, `[RECEIVER-SAYS-WHAT-WAS-WRITTEN]`. (B1-1, B1-2)
|
|
30
|
+
- **An interrupted trim, restore or scrub is finished, never repeated.** A trim killed after writing its
|
|
31
|
+
archive file used to be archived again by the next one (70,000 copies), a trim or restore killed
|
|
32
|
+
before its record was never recorded, and a leftover temp file kept secrets through a scrub. Each
|
|
33
|
+
move now writes a small note first; the next holder of the lock finishes it and chains the missing
|
|
34
|
+
record (a restore keeps its reason). LOCK `[AN-INTERRUPTED-MOVE-IS-FINISHED]`. (B2-2, B2-3, B3-3)
|
|
35
|
+
- **The scrub acknowledges before it rewrites.** Killed in between, 100 scrubbed records used to read
|
|
36
|
+
as tampering for good. `audit-verify` now lists every altered index in the command it suggests.
|
|
37
|
+
LOCK `[SCRUB-ACKNOWLEDGES-BEFORE-IT-REWRITES]`. (B3-1)
|
|
38
|
+
|
|
39
|
+
### Fleet health
|
|
40
|
+
|
|
41
|
+
- **Health sees the audit chain.** It was green on three broken logs. Every `audit-verify` records its
|
|
42
|
+
result in `~/.contextengine/audit-verify.json`; the indexing server runs a full check once a day in a
|
|
43
|
+
separate low-priority process (a full check costs about 26 s and 3.5 GB on 4.9 million records;
|
|
44
|
+
`CONTEXTENGINE_CHAIN_CHECK=0` turns it off). A failed check, a check older than 48 h, refused entries
|
|
45
|
+
and records cut short are warnings. LOCK `[HEALTH-SEES-THE-CHAIN]`. (B6-1)
|
|
46
|
+
|
|
47
|
+
### Other
|
|
48
|
+
|
|
49
|
+
- Appends cost about 0.03 ms more (one extra read of the log's last byte); measured at 8 processes x 3,000.
|
|
50
|
+
- The bare `pass` name added in 2.10.0 now counts only before an equals sign or before a quoted value
|
|
51
|
+
after a colon (nodemailer's auth block): it also
|
|
52
|
+
took prose (a README's "PII pass" list) and code (a count of passing checks), which the public-release
|
|
53
|
+
scan refused. `SMTP_PASS`, `DB_PASS`, `db.pass` are unchanged. Replayed on 250,539 real strings:
|
|
54
|
+
the one false hit is gone, the real mail password is still caught.
|
|
8
55
|
|
|
9
56
|
## [2.10.0] 2026-09-26: the end-to-end review, phase A (security of what ships)
|
|
10
57
|
|
package/dist/audit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type AuditEvent = "learning.save" | "learning.delete" | "learning.store_unreadable" | "learning.store_shrink_refused" | "learning.store_growth_refused" | "server.start" | "server.role" | "index.write" | "learning.import" | "learning.export" | "session.save" | "session.delete" | "activation.activate" | "activation.deactivate" | "activation.heartbeat" | "activation.signature_reject" | "activation.legacy_signature" | "firewall.escalate" | "hook.block" | "hook.bypass" | "policy.skipped" | "browser.prompt" | "browser.response" | "browser.tool_call" | "browser.session_start" | "browser.session_end" | "browser.capture_miss" | "vscode.prompt_submit" | "vscode.tool_call" | "vscode.session_start" | "ingest.rate_limited" | "drift.detected" | "notification.fired" | "community.sync_ok" | "community.sync_error" | "audit.rotate" | "audit.redact" | "audit.restore";
|
|
1
|
+
export type AuditEvent = "learning.save" | "learning.delete" | "learning.store_unreadable" | "learning.store_shrink_refused" | "learning.store_growth_refused" | "server.start" | "server.role" | "index.write" | "learning.import" | "learning.export" | "session.save" | "session.delete" | "activation.activate" | "activation.deactivate" | "activation.heartbeat" | "activation.signature_reject" | "activation.legacy_signature" | "firewall.escalate" | "hook.block" | "hook.bypass" | "policy.skipped" | "browser.prompt" | "browser.response" | "browser.tool_call" | "browser.session_start" | "browser.session_end" | "browser.capture_miss" | "vscode.prompt_submit" | "vscode.tool_call" | "vscode.session_start" | "ingest.rate_limited" | "drift.detected" | "notification.fired" | "community.sync_ok" | "community.sync_error" | "audit.rotate" | "audit.redact" | "audit.restore" | "audit.torn_tail" | "audit.append_failed";
|
|
2
2
|
export interface AuditRecord {
|
|
3
3
|
ts: string;
|
|
4
4
|
event: AuditEvent;
|
|
@@ -10,6 +10,12 @@ export interface AuditRecord {
|
|
|
10
10
|
export declare function appendAudit(event: AuditEvent, payload: Record<string, unknown>, actor?: string): AuditRecord;
|
|
11
11
|
/** Archived segment filenames in chain order (oldest first). */
|
|
12
12
|
export declare function listSegments(): string[];
|
|
13
|
+
/** A line of the history that is not a record: where it is, and the history index it sits before. */
|
|
14
|
+
export interface UnreadableLine {
|
|
15
|
+
file: string;
|
|
16
|
+
line: number;
|
|
17
|
+
beforeIndex: number;
|
|
18
|
+
}
|
|
13
19
|
export interface ReadOptions {
|
|
14
20
|
/** Include archived segments. Default true — callers asking for "the audit log" mean
|
|
15
21
|
* the whole history. Hot paths that only care about a recent window pass false. */
|
|
@@ -105,10 +111,26 @@ export declare function rotateAuditLog(opts?: RotateOptions): RotationResult;
|
|
|
105
111
|
* command bypassed it. [LOCK] [ROTATION-HOLDS-THE-LOCK-BEFORE-IT-PLANS]
|
|
106
112
|
*/
|
|
107
113
|
export declare const AUTO_ROTATE_TRIGGER: number;
|
|
114
|
+
/** Cheap: is there anything for finishInterruptedMoves() to do? */
|
|
115
|
+
export declare function interruptedMovePending(): boolean;
|
|
116
|
+
export interface FinishReport {
|
|
117
|
+
tempsRemoved: string[];
|
|
118
|
+
rotation: {
|
|
119
|
+
segment: string;
|
|
120
|
+
duplicatesDropped: number;
|
|
121
|
+
recorded: boolean;
|
|
122
|
+
} | null;
|
|
123
|
+
restore: {
|
|
124
|
+
segment: string;
|
|
125
|
+
recorded: boolean;
|
|
126
|
+
} | null;
|
|
127
|
+
}
|
|
128
|
+
/** Run with the rotate lock held. [LOCK] [AN-INTERRUPTED-MOVE-IS-FINISHED] */
|
|
129
|
+
export declare function finishInterruptedMoves(): FinishReport;
|
|
108
130
|
/** Count newline-terminated lines without parsing. The live log is small by construction. */
|
|
109
131
|
export declare function countLiveRecords(): number;
|
|
110
132
|
export interface AutoRotateOutcome {
|
|
111
|
-
action: "disabled" | "below_trigger" | "in_progress" | "rotated" | "refused" | "error";
|
|
133
|
+
action: "disabled" | "below_trigger" | "in_progress" | "rotated" | "refused" | "error" | "finished";
|
|
112
134
|
liveRecords: number;
|
|
113
135
|
detail: string;
|
|
114
136
|
result?: RotationResult;
|
|
@@ -130,6 +152,12 @@ export interface IntegrityReport {
|
|
|
130
152
|
/** Records whose prev_hash names a KNOWN earlier head — a concurrent-append fork.
|
|
131
153
|
* Content is provably intact; only the linkage is non-linear. Not tampering. */
|
|
132
154
|
forkIndices?: number[];
|
|
155
|
+
/** Records whose hash already appeared earlier in the history: a second copy of a record,
|
|
156
|
+
* counted once and never relinked. Not tampering, not a fork. [LOCK] [VERIFY-FORK-IS-NOT-TAMPER] */
|
|
157
|
+
duplicateIndices?: number[];
|
|
158
|
+
/** Lines that are not records: file, line number, and the history index they sit before.
|
|
159
|
+
* Non-empty makes `ok` false; every other record is still checked. [LOCK] [VERIFY-READS-PAST-AN-UNREADABLE-LINE] */
|
|
160
|
+
unreadable?: UnreadableLine[];
|
|
133
161
|
/** Records whose content was altered AND whose alteration is acknowledged by a later, intact
|
|
134
162
|
* `audit.redact` record binding the original hash to the current content. Not counted as
|
|
135
163
|
* tampering. */
|
|
@@ -157,8 +185,45 @@ export interface IntegrityReport {
|
|
|
157
185
|
* `ok` is true when there are no tampered and no orphan records. Forks are surfaced
|
|
158
186
|
* with counts and indices so the report stays honest in both directions — it must
|
|
159
187
|
* never claim a forked log is pristine either.
|
|
188
|
+
* 2026-09-27: a fourth class. A record whose hash was already seen is a DUPLICATE (a second copy
|
|
189
|
+
* of the same record), counted once and skipped for linkage, so the record after a copied
|
|
190
|
+
* block links to the original. Before, the first copy read as a "fork" and the total counted
|
|
191
|
+
* every copy: 190,011 records "verified" for 120,011 real ones after an interrupted rotation
|
|
192
|
+
* (E2E_REVIEW_2026-09 B2-1, B2-2). A copy's content is still checked against its own hash.
|
|
160
193
|
*/
|
|
161
194
|
export declare function verifyChain(): IntegrityReport;
|
|
195
|
+
/**
|
|
196
|
+
* The result of the last full check, kept for fleet health: the check costs seconds and gigabytes
|
|
197
|
+
* (measured 2026-09-27: 26 s and 3.5 GB for 4,927,803 records), so health reads its result and
|
|
198
|
+
* never runs it. [LOCK] [HEALTH-SEES-THE-CHAIN] (src/fleet-health.ts)
|
|
199
|
+
*/
|
|
200
|
+
export interface VerifyState {
|
|
201
|
+
checkedAt: string;
|
|
202
|
+
ms: number;
|
|
203
|
+
by: "cli" | "scheduled";
|
|
204
|
+
ok: boolean;
|
|
205
|
+
total: number;
|
|
206
|
+
unique: number;
|
|
207
|
+
altered: number;
|
|
208
|
+
orphans: number;
|
|
209
|
+
unreadable: number;
|
|
210
|
+
duplicates: number;
|
|
211
|
+
forks: number;
|
|
212
|
+
redacted: number;
|
|
213
|
+
reason: string | null;
|
|
214
|
+
}
|
|
215
|
+
export declare function verifyStatePath(): string;
|
|
216
|
+
/** Keep the result of a full check. Best effort: a check that cannot record still printed its verdict. */
|
|
217
|
+
export declare function recordVerifyState(report: IntegrityReport, ms: number, by: VerifyState["by"]): VerifyState;
|
|
218
|
+
export declare function readVerifyState(): VerifyState | null;
|
|
219
|
+
/** Refusals written by safeAppend() and not chained yet: count, and the newest one. */
|
|
220
|
+
export declare function pendingRefusals(): {
|
|
221
|
+
count: number;
|
|
222
|
+
last: string | null;
|
|
223
|
+
error: string | null;
|
|
224
|
+
};
|
|
225
|
+
/** One scheduled full check at a time across processes: O_EXCL, stale after two hours. */
|
|
226
|
+
export declare function acquireVerifyLock(): (() => void) | null;
|
|
162
227
|
/**
|
|
163
228
|
* Acknowledge that records were deliberately redacted (a secret removed from their content).
|
|
164
229
|
*
|
|
@@ -262,6 +327,8 @@ type Redactor = (payload: Record<string, unknown>) => {
|
|
|
262
327
|
* the live log under the append lock (appends wait, none is lost), then one audit.redact
|
|
263
328
|
* record per 100 rewrites names each original hash and its new content hash
|
|
264
329
|
* ([REDACTION-IS-A-CHAINED-RECORD]). Running it again changes nothing.
|
|
330
|
+
* 2026-09-27 (Yan's GO): the order is now acknowledgement first, rewrite second, for every file.
|
|
331
|
+
* [LOCK] [SCRUB-ACKNOWLEDGES-BEFORE-IT-REWRITES]
|
|
265
332
|
*/
|
|
266
333
|
export declare function scrubAuditLog(opts: {
|
|
267
334
|
apply?: boolean;
|
|
@@ -272,6 +339,6 @@ export declare function scrubAuditLog(opts: {
|
|
|
272
339
|
export declare function filterByRange(records: AuditRecord[], since?: string, until?: string): AuditRecord[];
|
|
273
340
|
export declare function toCsv(records: AuditRecord[]): string;
|
|
274
341
|
export declare function resetCacheForTest(): void;
|
|
275
|
-
export declare function safeAppend(event: AuditEvent, payload: Record<string, unknown>, actor?: string):
|
|
342
|
+
export declare function safeAppend(event: AuditEvent, payload: Record<string, unknown>, actor?: string): boolean;
|
|
276
343
|
export {};
|
|
277
344
|
//# sourceMappingURL=audit.d.ts.map
|