pi-harness-runtime 1.1.394 → 1.1.396
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/AGENTS.md +135 -4
- package/harness/glm-quota-logger.ts +17 -0
- package/harness/langchain/planner-logger.ts +15 -0
- package/harness/service-diagnostics.ts +32 -1
- package/index.ts +92 -3
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/dist/workspace-env-format.d.ts +87 -0
- package/packages/contracts/dist/workspace-env-format.js +174 -6
- package/packages/contracts/dist/workspace-env.js +120 -9
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/src/workspace-env-format.ts +209 -6
- package/packages/contracts/src/workspace-env.ts +128 -7
- package/packages/contracts/test/workspace-env.test.ts +177 -0
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/continuation-controller.d.ts +47 -0
- package/packages/jev-judge/dist/continuation-controller.d.ts.map +1 -1
- package/packages/jev-judge/dist/continuation-controller.js +142 -16
- package/packages/jev-judge/dist/continuation-controller.js.map +1 -1
- package/packages/jev-judge/dist/index.d.ts +6 -0
- package/packages/jev-judge/dist/index.d.ts.map +1 -1
- package/packages/jev-judge/dist/index.js +6 -0
- package/packages/jev-judge/dist/index.js.map +1 -1
- package/packages/jev-judge/dist/validation-ledger.d.ts +129 -0
- package/packages/jev-judge/dist/validation-ledger.d.ts.map +1 -0
- package/packages/jev-judge/dist/validation-ledger.js +234 -0
- package/packages/jev-judge/dist/validation-ledger.js.map +1 -0
- package/packages/jev-judge/dist/validation-plan.d.ts +176 -0
- package/packages/jev-judge/dist/validation-plan.d.ts.map +1 -0
- package/packages/jev-judge/dist/validation-plan.js +293 -0
- package/packages/jev-judge/dist/validation-plan.js.map +1 -0
- package/packages/jev-judge/dist/validation-tie-breaker.d.ts +48 -0
- package/packages/jev-judge/dist/validation-tie-breaker.d.ts.map +1 -0
- package/packages/jev-judge/dist/validation-tie-breaker.js +83 -0
- package/packages/jev-judge/dist/validation-tie-breaker.js.map +1 -0
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/continuation-controller.ts +179 -20
- package/packages/jev-judge/src/index.ts +41 -0
- package/packages/jev-judge/src/validation-ledger.ts +290 -0
- package/packages/jev-judge/src/validation-plan.ts +406 -0
- package/packages/jev-judge/src/validation-tie-breaker.ts +123 -0
- package/packages/jev-judge/tests/continuation-controller.test.ts +167 -0
- package/packages/jev-judge/tests/validation-ledger.test.ts +181 -0
- package/packages/jev-judge/tests/validation-plan.test.ts +170 -0
- package/packages/jev-judge/tests/validation-tie-breaker.test.ts +88 -0
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/README.md +37 -0
- package/packages/logging/dist/buffer.d.ts +33 -0
- package/packages/logging/dist/buffer.d.ts.map +1 -0
- package/packages/logging/dist/buffer.js +60 -0
- package/packages/logging/dist/buffer.js.map +1 -0
- package/packages/logging/dist/config.d.ts +40 -0
- package/packages/logging/dist/config.d.ts.map +1 -0
- package/packages/logging/dist/config.js +114 -0
- package/packages/logging/dist/config.js.map +1 -0
- package/packages/logging/dist/index.d.ts +32 -0
- package/packages/logging/dist/index.d.ts.map +1 -0
- package/packages/logging/dist/index.js +31 -0
- package/packages/logging/dist/index.js.map +1 -0
- package/packages/logging/dist/redact.d.ts +43 -0
- package/packages/logging/dist/redact.d.ts.map +1 -0
- package/packages/logging/dist/redact.js +220 -0
- package/packages/logging/dist/redact.js.map +1 -0
- package/packages/logging/dist/sampler.d.ts +37 -0
- package/packages/logging/dist/sampler.d.ts.map +1 -0
- package/packages/logging/dist/sampler.js +78 -0
- package/packages/logging/dist/sampler.js.map +1 -0
- package/packages/logging/dist/shipper.d.ts +82 -0
- package/packages/logging/dist/shipper.d.ts.map +1 -0
- package/packages/logging/dist/shipper.js +238 -0
- package/packages/logging/dist/shipper.js.map +1 -0
- package/packages/logging/dist/singleton.d.ts +38 -0
- package/packages/logging/dist/singleton.d.ts.map +1 -0
- package/packages/logging/dist/singleton.js +95 -0
- package/packages/logging/dist/singleton.js.map +1 -0
- package/packages/logging/dist/spool.d.ts +39 -0
- package/packages/logging/dist/spool.d.ts.map +1 -0
- package/packages/logging/dist/spool.js +110 -0
- package/packages/logging/dist/spool.js.map +1 -0
- package/packages/logging/dist/transports/r2.d.ts +31 -0
- package/packages/logging/dist/transports/r2.d.ts.map +1 -0
- package/packages/logging/dist/transports/r2.js +60 -0
- package/packages/logging/dist/transports/r2.js.map +1 -0
- package/packages/logging/dist/transports/webhook.d.ts +22 -0
- package/packages/logging/dist/transports/webhook.d.ts.map +1 -0
- package/packages/logging/dist/transports/webhook.js +37 -0
- package/packages/logging/dist/transports/webhook.js.map +1 -0
- package/packages/logging/dist/types.d.ts +73 -0
- package/packages/logging/dist/types.d.ts.map +1 -0
- package/packages/logging/dist/types.js +19 -0
- package/packages/logging/dist/types.js.map +1 -0
- package/packages/logging/package.json +37 -0
- package/packages/logging/src/buffer.ts +77 -0
- package/packages/logging/src/config.ts +163 -0
- package/packages/logging/src/index.ts +87 -0
- package/packages/logging/src/redact.ts +271 -0
- package/packages/logging/src/sampler.ts +97 -0
- package/packages/logging/src/shipper.ts +281 -0
- package/packages/logging/src/singleton.ts +142 -0
- package/packages/logging/src/spool.ts +139 -0
- package/packages/logging/src/transports/r2.ts +86 -0
- package/packages/logging/src/transports/webhook.ts +54 -0
- package/packages/logging/src/types.ts +85 -0
- package/packages/logging/test/buffer.test.ts +44 -0
- package/packages/logging/test/config.test.ts +97 -0
- package/packages/logging/test/integration.test.ts +135 -0
- package/packages/logging/test/redact.test.ts +109 -0
- package/packages/logging/test/sampler.test.ts +57 -0
- package/packages/logging/test/shipper.test.ts +152 -0
- package/packages/logging/test/spool.test.ts +93 -0
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
- package/scripts/unified-webhook-server.ts +102 -0
- package/scripts/validation-run.ts +191 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the validation ledger - the durable record of which tier ran.
|
|
3
|
+
*
|
|
4
|
+
* The ledger is the only mechanical answer to "did the final tier pass?", so
|
|
5
|
+
* it must survive malformed input, report the latest run of a tier and never
|
|
6
|
+
* throw into its caller.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
|
10
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync, existsSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import {
|
|
14
|
+
ValidationLedger,
|
|
15
|
+
defaultLedgerPath,
|
|
16
|
+
parseLedgerContent,
|
|
17
|
+
parseRunRecord,
|
|
18
|
+
} from "../src/validation-ledger.js";
|
|
19
|
+
import type { TodoItem } from "../src/todo-provider.js";
|
|
20
|
+
|
|
21
|
+
let dir: string;
|
|
22
|
+
let path: string;
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
dir = mkdtempSync(join(tmpdir(), "validation-ledger-"));
|
|
26
|
+
path = join(dir, "validation-runs.jsonl");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
rmSync(dir, { recursive: true, force: true });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function itemWithPlan(metadata: Record<string, unknown>): TodoItem {
|
|
34
|
+
return {
|
|
35
|
+
id: 1,
|
|
36
|
+
subject: "staged work",
|
|
37
|
+
status: "in_progress",
|
|
38
|
+
metadata,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const PLAN = {
|
|
43
|
+
validationPlan: {
|
|
44
|
+
fast: { command: "bun test tests/fast", expectedDurationMs: 18_000, datasetSize: 100 },
|
|
45
|
+
full: { command: "bun test tests/full", expectedDurationMs: 2_400_000, datasetSize: 10_000 },
|
|
46
|
+
budgetMinutes: 90,
|
|
47
|
+
finalTierRequired: true,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
describe("parseRunRecord", () => {
|
|
52
|
+
it("reads a complete record", () => {
|
|
53
|
+
const record = parseRunRecord(
|
|
54
|
+
JSON.stringify({
|
|
55
|
+
ts: "2026-10-24T00:00:00.000Z",
|
|
56
|
+
tier: "full",
|
|
57
|
+
status: "passed",
|
|
58
|
+
itemId: 3,
|
|
59
|
+
durationMs: 1200,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
expect(record?.tier).toBe("full");
|
|
63
|
+
expect(record?.status).toBe("passed");
|
|
64
|
+
expect(record?.itemId).toBe(3);
|
|
65
|
+
expect(record?.durationMs).toBe(1200);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("rejects malformed lines", () => {
|
|
69
|
+
expect(parseRunRecord("")).toBeNull();
|
|
70
|
+
expect(parseRunRecord("not json")).toBeNull();
|
|
71
|
+
expect(parseRunRecord("[]")).toBeNull();
|
|
72
|
+
expect(parseRunRecord(JSON.stringify({ tier: "medium", status: "passed" }))).toBeNull();
|
|
73
|
+
expect(parseRunRecord(JSON.stringify({ tier: "fast", status: "weird" }))).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("parseLedgerContent", () => {
|
|
78
|
+
it("skips malformed lines and keeps the rest", () => {
|
|
79
|
+
const content = [
|
|
80
|
+
JSON.stringify({ ts: "2026-10-24T00:00:00.000Z", tier: "fast", status: "passed" }),
|
|
81
|
+
"garbage",
|
|
82
|
+
"",
|
|
83
|
+
JSON.stringify({ ts: "2026-10-24T00:01:00.000Z", tier: "full", status: "failed" }),
|
|
84
|
+
].join("\n");
|
|
85
|
+
const records = parseLedgerContent(content);
|
|
86
|
+
expect(records).toHaveLength(2);
|
|
87
|
+
expect(records[1].tier).toBe("full");
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe("ValidationLedger", () => {
|
|
92
|
+
it("writes NDJSON that can be read back", () => {
|
|
93
|
+
const ledger = new ValidationLedger({ path });
|
|
94
|
+
ledger.record({ tier: "fast", status: "passed", itemId: 1, durationMs: 500 });
|
|
95
|
+
|
|
96
|
+
const raw = readFileSync(path, "utf-8");
|
|
97
|
+
expect(raw.trim().split("\n")).toHaveLength(1);
|
|
98
|
+
expect(JSON.parse(raw.trim()).tier).toBe("fast");
|
|
99
|
+
expect(ledger.read()).toHaveLength(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("keeps only the runs of the requested item", () => {
|
|
103
|
+
const ledger = new ValidationLedger({ path });
|
|
104
|
+
ledger.record({ tier: "fast", status: "passed", itemId: 1 });
|
|
105
|
+
ledger.record({ tier: "fast", status: "passed", itemId: 2 });
|
|
106
|
+
expect(ledger.runsFor(1)).toHaveLength(1);
|
|
107
|
+
expect(ledger.runsFor(3)).toHaveLength(0);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("returns the latest run of a tier", () => {
|
|
111
|
+
const ledger = new ValidationLedger({ path });
|
|
112
|
+
ledger.record({ tier: "fast", status: "failed", itemId: 1, ts: "2026-10-24T00:00:00.000Z" });
|
|
113
|
+
ledger.record({ tier: "fast", status: "passed", itemId: 1, ts: "2026-10-24T00:05:00.000Z" });
|
|
114
|
+
const latest = ledger.latestFor(1, "fast");
|
|
115
|
+
expect(latest?.status).toBe("passed");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("mirrors every record to the sink", () => {
|
|
119
|
+
const mirrored: string[] = [];
|
|
120
|
+
const ledger = new ValidationLedger({ path, onRecord: (r) => mirrored.push(r.tier) });
|
|
121
|
+
ledger.record({ tier: "fast", status: "passed", itemId: 1 });
|
|
122
|
+
ledger.record({ tier: "full", status: "passed", itemId: 1 });
|
|
123
|
+
expect(mirrored).toEqual(["fast", "full"]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("never throws when the sink throws", () => {
|
|
127
|
+
const ledger = new ValidationLedger({
|
|
128
|
+
path,
|
|
129
|
+
onRecord: () => {
|
|
130
|
+
throw new Error("sink is broken");
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
expect(() => ledger.record({ tier: "fast", status: "passed", itemId: 1 })).not.toThrow();
|
|
134
|
+
expect(ledger.read()).toHaveLength(1);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("rotates the file when it grows past the limit", () => {
|
|
138
|
+
const ledger = new ValidationLedger({ path, maxBytes: 200 });
|
|
139
|
+
for (let i = 0; i < 10; i++) {
|
|
140
|
+
ledger.record({ tier: "fast", status: "passed", itemId: i, note: "x".repeat(50) });
|
|
141
|
+
}
|
|
142
|
+
expect(existsSync(`${path}.1`)).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("reports a pending final tier until the full tier passed", () => {
|
|
146
|
+
const ledger = new ValidationLedger({ path });
|
|
147
|
+
const item = itemWithPlan(PLAN);
|
|
148
|
+
|
|
149
|
+
expect(ledger.stateFor(item).finalTierPending).toBe(true);
|
|
150
|
+
expect(ledger.isFinalTierPending(item)).toBe(true);
|
|
151
|
+
|
|
152
|
+
ledger.record({ tier: "fast", status: "passed", itemId: 1 });
|
|
153
|
+
expect(ledger.stateFor(item).finalTierPending).toBe(true);
|
|
154
|
+
|
|
155
|
+
ledger.record({ tier: "full", status: "failed", itemId: 1 });
|
|
156
|
+
expect(ledger.stateFor(item).finalTierPending).toBe(true);
|
|
157
|
+
|
|
158
|
+
ledger.record({ tier: "full", status: "passed", itemId: 1 });
|
|
159
|
+
expect(ledger.stateFor(item).finalTierPending).toBe(false);
|
|
160
|
+
expect(ledger.stateFor(item).full.status).toBe("passed");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("reports no pending tier for an item without a plan", () => {
|
|
164
|
+
const ledger = new ValidationLedger({ path });
|
|
165
|
+
const item: TodoItem = { id: 9, subject: "plain", status: "in_progress" };
|
|
166
|
+
const state = ledger.stateFor(item);
|
|
167
|
+
expect(state.hasPlan).toBe(false);
|
|
168
|
+
expect(state.finalTierPending).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("survives a truncated file", () => {
|
|
172
|
+
writeFileSync(path, '{"ts":"2026-10-24T00:00:00.000Z","tier":"fast","status":"passed"}\n{"ts":"2026-10-2');
|
|
173
|
+
const ledger = new ValidationLedger({ path });
|
|
174
|
+
expect(ledger.read()).toHaveLength(1);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("uses a default path under the harness home", () => {
|
|
178
|
+
expect(defaultLedgerPath()).toContain(".pi-harness-runtime");
|
|
179
|
+
expect(defaultLedgerPath().endsWith("validation-runs.jsonl")).toBe(true);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the staged validation plan.
|
|
3
|
+
*
|
|
4
|
+
* The plan is what lets the harness say "run the cheap tier while the code
|
|
5
|
+
* changes, run the expensive tier once at the end" instead of letting the
|
|
6
|
+
* agent repeat a 40 minute regression after every fix.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from "bun:test";
|
|
10
|
+
import {
|
|
11
|
+
parseValidationPlan,
|
|
12
|
+
formatValidationContext,
|
|
13
|
+
buildValidationSteerSuffix,
|
|
14
|
+
parseDurationMs,
|
|
15
|
+
formatDuration,
|
|
16
|
+
parseTier,
|
|
17
|
+
} from "../src/validation-plan.js";
|
|
18
|
+
import type { TodoItem } from "../src/todo-provider.js";
|
|
19
|
+
|
|
20
|
+
function item(metadata?: Record<string, unknown>): TodoItem {
|
|
21
|
+
return {
|
|
22
|
+
id: 1,
|
|
23
|
+
subject: "seed data",
|
|
24
|
+
status: "in_progress",
|
|
25
|
+
metadata,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe("parseValidationPlan", () => {
|
|
30
|
+
it("returns null when the todo declares no plan", () => {
|
|
31
|
+
expect(parseValidationPlan(item())).toBeNull();
|
|
32
|
+
expect(parseValidationPlan(item({ other: "value" }))).toBeNull();
|
|
33
|
+
expect(parseValidationPlan(null)).toBeNull();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("parses object tiers with cost and dataset size", () => {
|
|
37
|
+
const plan = parseValidationPlan(
|
|
38
|
+
item({
|
|
39
|
+
validationPlan: {
|
|
40
|
+
fast: { command: "bun test fast", expectedDurationMs: 18000, datasetSize: 100 },
|
|
41
|
+
full: { command: "bun test full", expectedDurationMs: 2400000, datasetSize: 10000 },
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
expect(plan?.fast?.command).toBe("bun test fast");
|
|
46
|
+
expect(plan?.fast?.expectedDurationMs).toBe(18000);
|
|
47
|
+
expect(plan?.fast?.datasetSize).toBe(100);
|
|
48
|
+
expect(plan?.full?.expectedDurationMs).toBe(2400000);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("parses plain command strings as tiers", () => {
|
|
52
|
+
const plan = parseValidationPlan(
|
|
53
|
+
item({ validationPlan: { fast: "bun test fast", full: "bun test full" } }),
|
|
54
|
+
);
|
|
55
|
+
expect(plan?.fast?.command).toBe("bun test fast");
|
|
56
|
+
expect(plan?.full?.command).toBe("bun test full");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("parses flat command aliases and duration strings", () => {
|
|
60
|
+
const plan = parseValidationPlan(
|
|
61
|
+
item({ validationPlan: { fastCommand: "bun test fast", fullCommand: "bun test full", budgetMinutes: 90 } }),
|
|
62
|
+
);
|
|
63
|
+
expect(plan?.fast?.command).toBe("bun test fast");
|
|
64
|
+
expect(plan?.full?.command).toBe("bun test full");
|
|
65
|
+
expect(plan?.budgetMinutes).toBe(90);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("reads a duration given as a string", () => {
|
|
69
|
+
const plan = parseValidationPlan(
|
|
70
|
+
item({ validationPlan: { full: { command: "bun test full", expectedDuration: "40m" } } }),
|
|
71
|
+
);
|
|
72
|
+
expect(plan?.full?.expectedDurationMs).toBe(40 * 60 * 1000);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("keeps finalTierRequired and notes", () => {
|
|
76
|
+
const plan = parseValidationPlan(
|
|
77
|
+
item({
|
|
78
|
+
validationPlan: {
|
|
79
|
+
fast: "bun test fast",
|
|
80
|
+
full: "bun test full",
|
|
81
|
+
finalTierRequired: true,
|
|
82
|
+
notes: "fast tier must cover the aggregate query",
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
expect(plan?.finalTierRequired).toBe(true);
|
|
87
|
+
expect(plan?.notes).toBe("fast tier must cover the aggregate query");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("returns null for a plan that declares nothing usable", () => {
|
|
91
|
+
expect(parseValidationPlan(item({ validationPlan: { fast: {} } }))).toBeNull();
|
|
92
|
+
expect(parseValidationPlan(item({ validationPlan: "not an object" }))).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe("duration helpers", () => {
|
|
97
|
+
it("parses explicit units", () => {
|
|
98
|
+
expect(parseDurationMs("45s")).toBe(45_000);
|
|
99
|
+
expect(parseDurationMs("40m")).toBe(2_400_000);
|
|
100
|
+
expect(parseDurationMs("1h")).toBe(3_600_000);
|
|
101
|
+
expect(parseDurationMs("1h30m")).toBe(5_400_000);
|
|
102
|
+
expect(parseDurationMs("garbage")).toBeUndefined();
|
|
103
|
+
expect(parseDurationMs("")).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("treats a bare number below 1000 as seconds", () => {
|
|
107
|
+
expect(parseDurationMs(45)).toBe(45_000);
|
|
108
|
+
expect(parseDurationMs(45_000)).toBe(45_000);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("formats durations for a status line", () => {
|
|
112
|
+
expect(formatDuration(18_000)).toBe("18s");
|
|
113
|
+
expect(formatDuration(2_400_000)).toBe("40m");
|
|
114
|
+
expect(formatDuration(5_400_000)).toBe("1h 30m");
|
|
115
|
+
expect(formatDuration(3_600_000)).toBe("1h");
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("parseTier", () => {
|
|
120
|
+
it("ignores empty tiers", () => {
|
|
121
|
+
expect(parseTier("", "fast")).toBeUndefined();
|
|
122
|
+
expect(parseTier({}, "fast")).toBeUndefined();
|
|
123
|
+
expect(parseTier(undefined, "fast")).toBeUndefined();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("keeps a label-only tier", () => {
|
|
127
|
+
const tier = parseTier({ label: "unit tests" }, "fast");
|
|
128
|
+
expect(tier?.label).toBe("unit tests");
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("formatValidationContext", () => {
|
|
133
|
+
it("is empty when there is no plan", () => {
|
|
134
|
+
expect(formatValidationContext({})).toBe("");
|
|
135
|
+
expect(buildValidationSteerSuffix(item())).toBe("");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("states both tiers and the staged rule", () => {
|
|
139
|
+
const plan = parseValidationPlan(
|
|
140
|
+
item({
|
|
141
|
+
validationPlan: {
|
|
142
|
+
fast: { command: "bun test fast", expectedDurationMs: 18_000, datasetSize: 100 },
|
|
143
|
+
full: { command: "bun test full", expectedDurationMs: 2_400_000, datasetSize: 10_000 },
|
|
144
|
+
finalTierRequired: true,
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
const text = formatValidationContext(plan!);
|
|
149
|
+
expect(text).toContain("fast=");
|
|
150
|
+
expect(text).toContain("full=");
|
|
151
|
+
expect(text).toContain("bun test fast");
|
|
152
|
+
expect(text).toContain("~18s");
|
|
153
|
+
expect(text).toContain("100 records");
|
|
154
|
+
expect(text).toContain("bun test full");
|
|
155
|
+
expect(text).toContain("~40m");
|
|
156
|
+
expect(text).toContain("10000 records");
|
|
157
|
+
expect(text).toContain("Run the fast tier after every edit");
|
|
158
|
+
expect(text).toContain("do not complete this todo");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("reports the remaining budget", () => {
|
|
162
|
+
const plan = parseValidationPlan(
|
|
163
|
+
item({ validationPlan: { fast: "bun test fast", budgetMinutes: 90 } }),
|
|
164
|
+
);
|
|
165
|
+
const text = formatValidationContext(plan!, { elapsedMs: 12 * 60 * 1000 });
|
|
166
|
+
expect(text).toContain("Time budget: 90m");
|
|
167
|
+
expect(text).toContain("elapsed 12m");
|
|
168
|
+
expect(text).toContain("remaining 1h 18m");
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the validation tie-breaker - the typed verdict that decides
|
|
3
|
+
* whether an item may count as done.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect } from "bun:test";
|
|
7
|
+
import { tieBreakValidation, formatTieBreaker } from "../src/validation-tie-breaker.js";
|
|
8
|
+
import { summarizeValidationState } from "../src/validation-plan.js";
|
|
9
|
+
import type { TodoItem } from "../src/todo-provider.js";
|
|
10
|
+
|
|
11
|
+
const item: TodoItem = {
|
|
12
|
+
id: 4,
|
|
13
|
+
subject: "staged work",
|
|
14
|
+
status: "in_progress",
|
|
15
|
+
metadata: {
|
|
16
|
+
validationPlan: {
|
|
17
|
+
fast: { command: "bun test tests/fast" },
|
|
18
|
+
full: { command: "bun test tests/full" },
|
|
19
|
+
finalTierRequired: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const plan = {
|
|
25
|
+
fast: { kind: "fast" as const, command: "bun test tests/fast" },
|
|
26
|
+
full: { kind: "full" as const, command: "bun test tests/full" },
|
|
27
|
+
finalTierRequired: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe("tieBreakValidation", () => {
|
|
31
|
+
it("reports no-plan for an item without a plan", () => {
|
|
32
|
+
const state = summarizeValidationState(null, []);
|
|
33
|
+
const verdict = tieBreakValidation({ id: 1, subject: "plain", status: "in_progress" }, state);
|
|
34
|
+
expect(verdict.verdict).toBe("no-plan");
|
|
35
|
+
expect(verdict.blocksCompletion).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("blocks the completion while the final tier did not run", () => {
|
|
39
|
+
const state = summarizeValidationState(plan, []);
|
|
40
|
+
const verdict = tieBreakValidation(item, state);
|
|
41
|
+
expect(verdict.verdict).toBe("final-tier-pending");
|
|
42
|
+
expect(verdict.blocksCompletion).toBe(true);
|
|
43
|
+
expect(verdict.reason).toContain("has not run");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("blocks the completion when the final tier failed", () => {
|
|
47
|
+
const state = summarizeValidationState(plan, [
|
|
48
|
+
{ ts: "2026-10-24T00:00:00.000Z", tier: "full", status: "failed" },
|
|
49
|
+
]);
|
|
50
|
+
const verdict = tieBreakValidation(item, state);
|
|
51
|
+
expect(verdict.verdict).toBe("final-tier-failed");
|
|
52
|
+
expect(verdict.blocksCompletion).toBe(true);
|
|
53
|
+
expect(verdict.tierStatus).toBe("failed");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("allows the completion when the final tier passed", () => {
|
|
57
|
+
const state = summarizeValidationState(plan, [
|
|
58
|
+
{ ts: "2026-10-24T00:00:00.000Z", tier: "full", status: "passed" },
|
|
59
|
+
]);
|
|
60
|
+
const verdict = tieBreakValidation(item, state);
|
|
61
|
+
expect(verdict.verdict).toBe("complete");
|
|
62
|
+
expect(verdict.blocksCompletion).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("allows the completion when no final tier is required", () => {
|
|
66
|
+
const state = summarizeValidationState(
|
|
67
|
+
{ fast: { kind: "fast", command: "bun test tests/fast" } },
|
|
68
|
+
[],
|
|
69
|
+
);
|
|
70
|
+
const verdict = tieBreakValidation(item, state);
|
|
71
|
+
expect(verdict.verdict).toBe("complete");
|
|
72
|
+
expect(verdict.blocksCompletion).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("flags a plan that requires a final tier but declares none", () => {
|
|
76
|
+
const state = summarizeValidationState({ finalTierRequired: true }, []);
|
|
77
|
+
const verdict = tieBreakValidation(item, state);
|
|
78
|
+
expect(verdict.verdict).toBe("plan-incomplete");
|
|
79
|
+
expect(verdict.blocksCompletion).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("formats the verdict for a log line", () => {
|
|
83
|
+
const state = summarizeValidationState(plan, []);
|
|
84
|
+
const verdict = tieBreakValidation(item, state);
|
|
85
|
+
expect(formatTieBreaker(verdict)).toContain("staged work");
|
|
86
|
+
expect(formatTieBreaker(verdict)).toContain("final-tier-pending");
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @pi-harness/logging
|
|
2
|
+
|
|
3
|
+
Centralized structured application logging for pi-harness.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
producer -> redact -> sample -> buffer -> R2 -> webhook -> local spool
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- **Redaction**: credential-looking keys, bearer tokens, JWTs and long token runs are
|
|
10
|
+
replaced; strings are truncated and structures are depth limited.
|
|
11
|
+
- **Sampling**: minimum level, a deterministic sample rate for `debug` records and a
|
|
12
|
+
per source+event rate limit. Errors are never sampled away.
|
|
13
|
+
- **Buffering**: bounded in-memory buffer; when it is full the least severe record is
|
|
14
|
+
dropped and the drop is counted.
|
|
15
|
+
- **Delivery**: transports are tried in order (R2, webhook). If all of them fail the
|
|
16
|
+
batch is spooled to disk as NDJSON and retried on the next flush.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { centralInfo, centralWarn, initCentralLogging } from "./packages/logging/dist/index.js";
|
|
22
|
+
|
|
23
|
+
initCentralLogging(); // reads the environment and the key files
|
|
24
|
+
centralInfo("harness", "startup", "ready", { pid: process.pid });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Transports
|
|
28
|
+
|
|
29
|
+
| Transport | Purpose |
|
|
30
|
+
|-----------|---------|
|
|
31
|
+
| `createR2Transport` | Cloudflare R2 (S3 API), gzipped NDJSON under a date prefix |
|
|
32
|
+
| `createWebhookTransport` | HTTP POST to the unified webhook server (`/api/logs`) |
|
|
33
|
+
| `LogSpool` | Local NDJSON fallback, rotated by size, with retention |
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
See the "Centralized Application Logging" section in the repository `AGENTS.md`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory batching buffer for the centralized log pipeline.
|
|
3
|
+
*
|
|
4
|
+
* The buffer is bounded on purpose: a logging subsystem must never be the
|
|
5
|
+
* reason a process runs out of memory. When the buffer is full the LEAST
|
|
6
|
+
* severe record is dropped first, and the drop is counted so the loss is
|
|
7
|
+
* visible instead of silent.
|
|
8
|
+
*/
|
|
9
|
+
import { type LogRecord } from "./types.js";
|
|
10
|
+
export interface LogBufferOptions {
|
|
11
|
+
/** Maximum number of records held in memory. Default 1000. */
|
|
12
|
+
maxSize?: number;
|
|
13
|
+
/** Maximum number of records per batch. Default 100. */
|
|
14
|
+
maxBatchSize?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare class LogBuffer {
|
|
17
|
+
private readonly records;
|
|
18
|
+
private readonly maxSize;
|
|
19
|
+
private readonly maxBatchSize;
|
|
20
|
+
private droppedCount;
|
|
21
|
+
constructor(options?: LogBufferOptions);
|
|
22
|
+
get size(): number;
|
|
23
|
+
get dropped(): number;
|
|
24
|
+
get batchSize(): number;
|
|
25
|
+
push(record: LogRecord): void;
|
|
26
|
+
/** Remove and return up to `maxBatchSize` of the oldest records. */
|
|
27
|
+
takeBatch(maxBatchSize?: number): LogRecord[];
|
|
28
|
+
/** Peek without removing (used by the synchronous exit path). */
|
|
29
|
+
peekAll(): LogRecord[];
|
|
30
|
+
clear(): void;
|
|
31
|
+
private dropLowestSeverity;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAChC,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,YAAY,CAAK;IAEzB,YAAY,OAAO,GAAE,gBAAqB,EAGzC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAK5B;IAED,oEAAoE;IACpE,SAAS,CAAC,YAAY,GAAE,MAA0B,GAAG,SAAS,EAAE,CAG/D;IAED,iEAAiE;IACjE,OAAO,IAAI,SAAS,EAAE,CAErB;IAED,KAAK,IAAI,IAAI,CAEZ;IAED,OAAO,CAAC,kBAAkB;CAa1B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory batching buffer for the centralized log pipeline.
|
|
3
|
+
*
|
|
4
|
+
* The buffer is bounded on purpose: a logging subsystem must never be the
|
|
5
|
+
* reason a process runs out of memory. When the buffer is full the LEAST
|
|
6
|
+
* severe record is dropped first, and the drop is counted so the loss is
|
|
7
|
+
* visible instead of silent.
|
|
8
|
+
*/
|
|
9
|
+
import { LOG_LEVEL_SEVERITY } from "./types.js";
|
|
10
|
+
export class LogBuffer {
|
|
11
|
+
records = [];
|
|
12
|
+
maxSize;
|
|
13
|
+
maxBatchSize;
|
|
14
|
+
droppedCount = 0;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.maxSize = Math.max(1, options.maxSize ?? 1000);
|
|
17
|
+
this.maxBatchSize = Math.max(1, options.maxBatchSize ?? 100);
|
|
18
|
+
}
|
|
19
|
+
get size() {
|
|
20
|
+
return this.records.length;
|
|
21
|
+
}
|
|
22
|
+
get dropped() {
|
|
23
|
+
return this.droppedCount;
|
|
24
|
+
}
|
|
25
|
+
get batchSize() {
|
|
26
|
+
return this.maxBatchSize;
|
|
27
|
+
}
|
|
28
|
+
push(record) {
|
|
29
|
+
if (this.records.length >= this.maxSize) {
|
|
30
|
+
this.dropLowestSeverity();
|
|
31
|
+
}
|
|
32
|
+
this.records.push(record);
|
|
33
|
+
}
|
|
34
|
+
/** Remove and return up to `maxBatchSize` of the oldest records. */
|
|
35
|
+
takeBatch(maxBatchSize = this.maxBatchSize) {
|
|
36
|
+
const count = Math.min(Math.max(0, maxBatchSize), this.records.length);
|
|
37
|
+
return this.records.splice(0, count);
|
|
38
|
+
}
|
|
39
|
+
/** Peek without removing (used by the synchronous exit path). */
|
|
40
|
+
peekAll() {
|
|
41
|
+
return [...this.records];
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
this.records.length = 0;
|
|
45
|
+
}
|
|
46
|
+
dropLowestSeverity() {
|
|
47
|
+
let index = 0;
|
|
48
|
+
let lowest = Number.POSITIVE_INFINITY;
|
|
49
|
+
for (let i = 0; i < this.records.length; i++) {
|
|
50
|
+
const severity = LOG_LEVEL_SEVERITY[this.records[i].level];
|
|
51
|
+
if (severity < lowest) {
|
|
52
|
+
lowest = severity;
|
|
53
|
+
index = i;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
this.records.splice(index, 1);
|
|
57
|
+
this.droppedCount++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAkB,MAAM,YAAY,CAAC;AAShE,MAAM,OAAO,SAAS;IACJ,OAAO,GAAgB,EAAE,CAAC;IAC1B,OAAO,CAAS;IAChB,YAAY,CAAS;IAC9B,YAAY,GAAG,CAAC,CAAC;IAEzB,YAAY,OAAO,GAAqB,EAAE;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,MAAiB;QACrB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACzC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,oEAAoE;IACpE,SAAS,CAAC,YAAY,GAAW,IAAI,CAAC,YAAY;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,iEAAiE;IACjE,OAAO;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAEO,kBAAkB;QACzB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC3D,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC;gBACvB,MAAM,GAAG,QAAQ,CAAC;gBAClB,KAAK,GAAG,CAAC,CAAC;YACX,CAAC;QACF,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,EAAE,CAAC;IACrB,CAAC;CACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the centralized log pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order for credentials:
|
|
5
|
+
* environment variable -> key file in ~/.pi-harness-runtime/keys
|
|
6
|
+
*
|
|
7
|
+
* Secrets are never hardcoded here. A key file that is missing simply means
|
|
8
|
+
* the corresponding transport is not configured.
|
|
9
|
+
*/
|
|
10
|
+
import type { LogBufferOptions } from "./buffer.js";
|
|
11
|
+
import type { SamplingPolicy } from "./sampler.js";
|
|
12
|
+
import type { LogTransport } from "./types.js";
|
|
13
|
+
export type LogSinkMode = "off" | "auto" | "r2" | "webhook" | "r2+webhook";
|
|
14
|
+
export interface LogSinkConfig {
|
|
15
|
+
/** False when nothing should be shipped (no transports, no spool). */
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Application name reported with every batch. */
|
|
18
|
+
app: string;
|
|
19
|
+
/** Transports in delivery priority order. */
|
|
20
|
+
transports: LogTransport[];
|
|
21
|
+
/** Directory of the local spool (undefined when logging is off). */
|
|
22
|
+
spoolDir?: string;
|
|
23
|
+
sampling: Partial<SamplingPolicy>;
|
|
24
|
+
buffer: LogBufferOptions;
|
|
25
|
+
flushIntervalMs: number;
|
|
26
|
+
/** Human readable notes about what was enabled and why. */
|
|
27
|
+
notes: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface ResolveConfigOptions {
|
|
30
|
+
env?: Record<string, string | undefined>;
|
|
31
|
+
/** Directory holding the credential key files. */
|
|
32
|
+
keysDir?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function defaultKeysDir(): string;
|
|
35
|
+
export declare function defaultSpoolDir(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Build the log sink configuration from the environment and the key files.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveLogSinkConfig(options?: ResolveConfigOptions): LogSinkConfig;
|
|
40
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC7B,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAClC,MAAM,EAAE,gBAAgB,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAoBD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CA0FtF"}
|