harnery 0.45.2 → 0.46.1
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/dist/commander.d.ts +13 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commands/admission.d.ts.map +1 -1
- package/dist/commands/admission.js +214 -27
- package/dist/commands/agents.d.ts +4 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +102 -25
- package/dist/commands/browse.d.ts +3 -0
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +172 -8
- package/dist/commands/fetch.js +1 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +8 -2
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +40 -0
- package/dist/commands/qa-run.d.ts.map +1 -1
- package/dist/commands/qa-run.js +4 -3
- package/dist/commands/review-pack.d.ts.map +1 -1
- package/dist/commands/review-pack.js +33 -6
- package/dist/core/agents/index.d.ts +1 -0
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +1 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +11 -4
- package/dist/core/agents/render/session-context.d.ts +0 -6
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +1 -6
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +36 -16
- package/dist/core/agents/rules/stop-hook.d.ts +6 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +20 -1
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +12 -4
- package/dist/core/agents/state/heartbeat-reader.d.ts +3 -0
- package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.d.ts +3 -1
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +6 -2
- package/dist/core/agents/state/parent-reference-contract.d.ts +16 -0
- package/dist/core/agents/state/parent-reference-contract.d.ts.map +1 -0
- package/dist/core/agents/state/parent-reference-contract.js +1 -0
- package/dist/core/agents/state/parent-reference.d.ts +18 -0
- package/dist/core/agents/state/parent-reference.d.ts.map +1 -0
- package/dist/core/agents/state/parent-reference.js +119 -0
- package/dist/core/config.d.ts +39 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +63 -0
- package/dist/core/diagnostics/path-identity.d.ts +1 -1
- package/dist/core/diagnostics/path-identity.d.ts.map +1 -1
- package/dist/core/diagnostics/path-identity.js +51 -6
- package/dist/core/events/v3/canonical.js +43 -14
- package/dist/core/events/v3/index.d.ts +1 -1
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +1 -1
- package/dist/core/events/v3/producers/recorder.d.ts +34 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +117 -13
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +53 -13
- package/dist/core/events/v3/validate.d.ts.map +1 -1
- package/dist/core/events/v3/validate.js +36 -1
- package/dist/core/hooks/adapter/native-parent.d.ts +23 -0
- package/dist/core/hooks/adapter/native-parent.d.ts.map +1 -0
- package/dist/core/hooks/adapter/native-parent.js +91 -0
- package/dist/core/hooks/cli.js +103 -5
- package/dist/core/hooks/resolve/owner.d.ts +0 -11
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +0 -23
- package/dist/core/hooks/resolve/transcript.d.ts +12 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +54 -0
- package/dist/core/hooks/shell-admission.d.ts +84 -0
- package/dist/core/hooks/shell-admission.d.ts.map +1 -0
- package/dist/core/hooks/shell-admission.js +622 -0
- package/dist/core/hooks/shell-commit-tree.d.ts +2 -0
- package/dist/core/hooks/shell-commit-tree.d.ts.map +1 -0
- package/dist/core/hooks/shell-commit-tree.js +104 -0
- package/dist/core/inbox/contract.d.ts +12 -0
- package/dist/core/inbox/contract.d.ts.map +1 -1
- package/dist/core/inbox/contract.js +16 -0
- package/dist/core/inbox/peer-messages.d.ts +41 -16
- package/dist/core/inbox/peer-messages.d.ts.map +1 -1
- package/dist/core/inbox/peer-messages.js +372 -15
- package/dist/core/inbox/service.d.ts +8 -1
- package/dist/core/inbox/service.d.ts.map +1 -1
- package/dist/core/inbox/service.js +83 -3
- package/dist/core/inbox/targets.d.ts +17 -3
- package/dist/core/inbox/targets.d.ts.map +1 -1
- package/dist/core/inbox/targets.js +77 -2
- package/dist/core/presence/git.d.ts +18 -12
- package/dist/core/presence/git.d.ts.map +1 -1
- package/dist/core/presence/git.js +32 -38
- package/dist/core/presence/index.d.ts +2 -2
- package/dist/core/presence/index.d.ts.map +1 -1
- package/dist/core/presence/index.js +8 -6
- package/dist/core/presence/mail.d.ts +133 -0
- package/dist/core/presence/mail.d.ts.map +1 -0
- package/dist/core/presence/mail.js +464 -0
- package/dist/core/semantic/contract.d.ts +5 -5
- package/dist/core/storage/modes.d.ts +4 -0
- package/dist/core/storage/modes.d.ts.map +1 -1
- package/dist/core/storage/modes.js +4 -0
- package/dist/core/storage/segments.d.ts.map +1 -1
- package/dist/core/storage/segments.js +5 -4
- package/dist/lib/admission-history.d.ts +96 -0
- package/dist/lib/admission-history.d.ts.map +1 -0
- package/dist/lib/admission-history.js +196 -0
- package/dist/lib/admission.d.ts +56 -7
- package/dist/lib/admission.d.ts.map +1 -1
- package/dist/lib/admission.js +161 -19
- package/dist/lib/browser/client.d.ts +18 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +100 -12
- package/dist/lib/browser/content-checks.d.ts +3 -1
- package/dist/lib/browser/content-checks.d.ts.map +1 -1
- package/dist/lib/browser/content-checks.js +10 -2
- package/dist/lib/browser/critique.d.ts +32 -0
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +72 -3
- package/dist/lib/browser/geometry.d.ts +2 -0
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +61 -15
- package/dist/lib/browser/index.d.ts +1 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +1 -1
- package/dist/lib/browser/page-review-contracts.d.ts +6 -1
- package/dist/lib/browser/page-review-contracts.d.ts.map +1 -1
- package/dist/lib/browser/page-review-contracts.js +6 -1
- package/dist/lib/browser/page-review-judge.d.ts +3 -1
- package/dist/lib/browser/page-review-judge.d.ts.map +1 -1
- package/dist/lib/browser/page-review-judge.js +41 -11
- package/dist/lib/browser/page-review-pack.d.ts +3 -0
- package/dist/lib/browser/page-review-pack.d.ts.map +1 -1
- package/dist/lib/browser/page-review-pack.js +5 -2
- package/dist/lib/browser/qa-run-contracts.d.ts +11 -0
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -1
- package/dist/lib/browser/qa-run-contracts.js +11 -4
- package/dist/lib/browser/qa-run.d.ts.map +1 -1
- package/dist/lib/browser/qa-run.js +73 -16
- package/dist/lib/browser/runts.d.ts +4 -2
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +84 -33
- package/dist/lib/browser/windows-chrome.d.ts +14 -0
- package/dist/lib/browser/windows-chrome.d.ts.map +1 -1
- package/dist/lib/browser/windows-chrome.js +42 -0
- package/dist/lib/browser/windows-login-sync.d.ts +110 -0
- package/dist/lib/browser/windows-login-sync.d.ts.map +1 -0
- package/dist/lib/browser/windows-login-sync.js +171 -0
- package/dist/lib/cookies/client.d.ts +30 -5
- package/dist/lib/cookies/client.d.ts.map +1 -1
- package/dist/lib/cookies/client.js +55 -10
- package/dist/lib/cookies/index.d.ts +1 -1
- package/dist/lib/cookies/index.d.ts.map +1 -1
- package/dist/lib/cookies/index.js +1 -1
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -1
- package/dist/lib/docs-metadata-sync.js +41 -2
- package/dist/lib/durable-job.d.ts +8 -0
- package/dist/lib/durable-job.d.ts.map +1 -1
- package/dist/lib/durable-job.js +10 -0
- package/dist/lib/http/client.d.ts +9 -8
- package/dist/lib/http/client.d.ts.map +1 -1
- package/dist/lib/http/client.js +44 -2
- package/dist/lib/instructions/templates.js +4 -4
- package/package.json +2 -2
- package/src/commander.ts +13 -0
- package/src/commands/admission.ts +272 -29
- package/src/commands/agents.ts +132 -27
- package/src/commands/browse.ts +208 -6
- package/src/commands/fetch.ts +1 -0
- package/src/commands/ledger-v3.ts +8 -2
- package/src/commands/presence.ts +49 -0
- package/src/commands/qa-run.ts +4 -3
- package/src/commands/review-pack.ts +41 -5
- package/src/core/agents/index.ts +6 -0
- package/src/core/agents/live-authority-v3.ts +11 -4
- package/src/core/agents/render/session-context.ts +1 -7
- package/src/core/agents/rules/claim-conflict.ts +50 -18
- package/src/core/agents/rules/stop-hook.ts +28 -1
- package/src/core/agents/session-events.ts +18 -3
- package/src/core/agents/state/heartbeat-reader.ts +3 -0
- package/src/core/agents/state/live-coordination-view.ts +13 -6
- package/src/core/agents/state/parent-reference-contract.ts +14 -0
- package/src/core/agents/state/parent-reference.ts +179 -0
- package/src/core/config.ts +85 -0
- package/src/core/diagnostics/path-identity.ts +52 -6
- package/src/core/events/v3/canonical.ts +46 -13
- package/src/core/events/v3/index.ts +3 -0
- package/src/core/events/v3/producers/recorder.ts +151 -13
- package/src/core/events/v3/reader.ts +55 -11
- package/src/core/events/v3/validate.ts +42 -1
- package/src/core/hooks/adapter/native-parent.ts +109 -0
- package/src/core/hooks/cli.ts +110 -4
- package/src/core/hooks/resolve/owner.ts +0 -23
- package/src/core/hooks/resolve/transcript.ts +61 -0
- package/src/core/hooks/shell-admission.ts +634 -0
- package/src/core/hooks/shell-commit-tree.ts +102 -0
- package/src/core/inbox/contract.ts +18 -0
- package/src/core/inbox/peer-messages.ts +501 -15
- package/src/core/inbox/service.ts +108 -3
- package/src/core/inbox/targets.ts +94 -3
- package/src/core/presence/git.ts +45 -37
- package/src/core/presence/index.ts +16 -8
- package/src/core/presence/mail.ts +620 -0
- package/src/core/storage/modes.ts +6 -0
- package/src/core/storage/segments.ts +5 -4
- package/src/lib/admission-history.ts +267 -0
- package/src/lib/admission.ts +217 -19
- package/src/lib/browser/client.ts +147 -35
- package/src/lib/browser/content-checks.ts +14 -3
- package/src/lib/browser/critique.ts +113 -3
- package/src/lib/browser/geometry.ts +63 -14
- package/src/lib/browser/index.ts +5 -0
- package/src/lib/browser/page-review-contracts.ts +6 -1
- package/src/lib/browser/page-review-judge.ts +58 -13
- package/src/lib/browser/page-review-pack.ts +13 -2
- package/src/lib/browser/qa-run-contracts.ts +30 -4
- package/src/lib/browser/qa-run.ts +78 -17
- package/src/lib/browser/runts.ts +85 -37
- package/src/lib/browser/windows-chrome.ts +50 -0
- package/src/lib/browser/windows-login-sync.ts +275 -0
- package/src/lib/cookies/client.ts +62 -10
- package/src/lib/cookies/index.ts +3 -0
- package/src/lib/docs-metadata-sync.ts +44 -2
- package/src/lib/durable-job.ts +15 -0
- package/src/lib/http/client.ts +63 -1
- package/src/lib/instructions/templates.ts +4 -4
|
@@ -23,6 +23,10 @@ export function stateSharing() {
|
|
|
23
23
|
}
|
|
24
24
|
return resolved;
|
|
25
25
|
}
|
|
26
|
+
/** Directory mode for personal state in the user's home, which never follows project sharing. */
|
|
27
|
+
export const PERSONAL_DIR_MODE = 0o700;
|
|
28
|
+
/** File mode for personal state in the user's home, such as a per-install secret key. */
|
|
29
|
+
export const PERSONAL_FILE_MODE = 0o600;
|
|
26
30
|
export function resetStorageSharing() {
|
|
27
31
|
resolved = undefined;
|
|
28
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../../src/core/storage/segments.ts"],"names":[],"mappings":"AAqBA,OAAO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C,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC,CAuExC;AAED,wBAAsB,eAAe,CAAC,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,EACpF,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,CA+BZ"}
|
|
@@ -35,15 +35,16 @@ export class FileSegmentSink {
|
|
|
35
35
|
write_sync: options.write_sync ?? nativeWriteSync,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
async append(records, metrics = {}, durable = false, now
|
|
38
|
+
async append(records, metrics = {}, durable = false, now) {
|
|
39
|
+
const requestedAt = now ?? new Date();
|
|
39
40
|
if (records.length === 0)
|
|
40
41
|
return { appended_records: 0, appended_bytes: 0, rotated: false, synced: false };
|
|
41
42
|
return withFamilyLease(this.#options.directory, this.#options, async () => {
|
|
42
43
|
const directory = ensurePrivateDirectory(this.#options.directory);
|
|
43
44
|
const active = join(this.#options.directory, "active.jsonl");
|
|
44
45
|
let rotated = false;
|
|
45
|
-
if (existsSync(active) && shouldRotate(active, records, this.#options,
|
|
46
|
-
sealActive(active, this.#options, now);
|
|
46
|
+
if (existsSync(active) && shouldRotate(active, records, this.#options, requestedAt)) {
|
|
47
|
+
sealActive(active, this.#options, now ?? new Date());
|
|
47
48
|
rotated = true;
|
|
48
49
|
}
|
|
49
50
|
rejectExistingSymlink(active);
|
|
@@ -69,7 +70,7 @@ export class FileSegmentSink {
|
|
|
69
70
|
bytes_appended: (metrics.bytes_appended ?? 0) + bytes,
|
|
70
71
|
rotations: (metrics.rotations ?? 0) + (rotated ? 1 : 0),
|
|
71
72
|
synced: (metrics.synced ?? 0) + (durable ? records.length : 0),
|
|
72
|
-
},
|
|
73
|
+
}, requestedAt);
|
|
73
74
|
return { appended_records: records.length, appended_bytes: bytes, rotated, synced: durable };
|
|
74
75
|
});
|
|
75
76
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export declare const ADMISSION_HISTORY_SCHEMA_VERSION = 1;
|
|
2
|
+
/**
|
|
3
|
+
* How a ticket ended.
|
|
4
|
+
* - `released`: the holder ran and gave the slot back.
|
|
5
|
+
* - `timeout`: no slot freed before the waiter's deadline.
|
|
6
|
+
* - `abandoned`: the process died while waiting or holding; a peer pruned it.
|
|
7
|
+
* - `expired`: the entry outlived the queue TTL and a peer pruned it.
|
|
8
|
+
*/
|
|
9
|
+
export type AdmissionHistoryOutcome = "released" | "timeout" | "abandoned" | "expired";
|
|
10
|
+
export interface AdmissionHistoryRecord {
|
|
11
|
+
v: typeof ADMISSION_HISTORY_SCHEMA_VERSION;
|
|
12
|
+
resource: string;
|
|
13
|
+
label: string;
|
|
14
|
+
pid: number;
|
|
15
|
+
/** Working directory of the process that queued, when known. */
|
|
16
|
+
cwd?: string;
|
|
17
|
+
capacity?: number;
|
|
18
|
+
outcome: AdmissionHistoryOutcome;
|
|
19
|
+
enqueued_at: string;
|
|
20
|
+
acquired_at?: string;
|
|
21
|
+
/** When the slot was released, the wait gave up, or a peer pruned the entry. */
|
|
22
|
+
ended_at: string;
|
|
23
|
+
/** Time spent in the queue. For an entry pruned while waiting, an upper bound. */
|
|
24
|
+
wait_ms: number;
|
|
25
|
+
/** Time the slot was held. For an entry pruned while holding, an upper bound. */
|
|
26
|
+
hold_ms?: number;
|
|
27
|
+
/** Labels of the holders when this ticket first had to wait. */
|
|
28
|
+
waited_behind?: string[];
|
|
29
|
+
/** Time spent deferring for memory pressure before joining the queue. */
|
|
30
|
+
pressure_wait_ms?: number;
|
|
31
|
+
exit_code?: number | null;
|
|
32
|
+
signal?: string | null;
|
|
33
|
+
}
|
|
34
|
+
/** Outcome details a caller can attach when it releases its slot. */
|
|
35
|
+
export interface AdmissionReleaseResult {
|
|
36
|
+
exitCode?: number | null;
|
|
37
|
+
signal?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Persistent machine-wide history directory used for the default admission
|
|
41
|
+
* queue root. The queues live in tmpdir and correctly vanish at reboot; the
|
|
42
|
+
* history is evidence and must survive one.
|
|
43
|
+
*/
|
|
44
|
+
export declare function defaultAdmissionHistoryDir(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Where history for a given queue root is written, or null when disabled.
|
|
47
|
+
* HARNERY_ADMISSION_HISTORY=off disables recording; HARNERY_ADMISSION_HISTORY_DIR
|
|
48
|
+
* overrides the location. A machine-wide queue root, named `harnery-admission`
|
|
49
|
+
* under any temp directory, records to the persistent state directory. Any
|
|
50
|
+
* other root (an isolated test queue, for example) records beside itself as
|
|
51
|
+
* `<root>-history`, so isolated queues never write into the
|
|
52
|
+
* machine-wide history and the history directory is never listed as a resource.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveAdmissionHistoryDir(queueDir: string): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Append one record. History is diagnostic: a write failure never fails the
|
|
57
|
+
* caller's admission, so errors are swallowed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function appendAdmissionHistory(dir: string | null, record: AdmissionHistoryRecord): void;
|
|
60
|
+
/** Resources with recorded history in a history directory. */
|
|
61
|
+
export declare function listAdmissionHistoryResources(dir: string): string[];
|
|
62
|
+
export interface AdmissionHistoryQuery {
|
|
63
|
+
resource?: string;
|
|
64
|
+
/** Keep records that ended at or after this epoch-ms. */
|
|
65
|
+
sinceMs?: number;
|
|
66
|
+
/** Keep records whose label contains this text (case-insensitive). */
|
|
67
|
+
labelContains?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Read history records, oldest first, across the current and rotated files. */
|
|
70
|
+
export declare function readAdmissionHistory(dir: string | null, query?: AdmissionHistoryQuery): AdmissionHistoryRecord[];
|
|
71
|
+
export interface AdmissionHistoryGroup {
|
|
72
|
+
resource: string;
|
|
73
|
+
label: string;
|
|
74
|
+
count: number;
|
|
75
|
+
/** Records that waited at least one second for a slot. */
|
|
76
|
+
queued: number;
|
|
77
|
+
wait_ms: {
|
|
78
|
+
p50: number;
|
|
79
|
+
p90: number;
|
|
80
|
+
max: number;
|
|
81
|
+
total: number;
|
|
82
|
+
};
|
|
83
|
+
/** Hold statistics over released records only. */
|
|
84
|
+
hold_ms: {
|
|
85
|
+
p50: number;
|
|
86
|
+
p90: number;
|
|
87
|
+
max: number;
|
|
88
|
+
} | null;
|
|
89
|
+
outcomes: Partial<Record<AdmissionHistoryOutcome, number>>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Group records by resource and label, most total wait first, so the work
|
|
93
|
+
* that spends the longest queueing leads the report.
|
|
94
|
+
*/
|
|
95
|
+
export declare function summarizeAdmissionHistory(records: AdmissionHistoryRecord[]): AdmissionHistoryGroup[];
|
|
96
|
+
//# sourceMappingURL=admission-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission-history.d.ts","sourceRoot":"","sources":["../../src/lib/admission-history.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAKlD;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEvF,MAAM,WAAW,sBAAsB;IACrC,CAAC,EAAE,OAAO,gCAAgC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,uBAAuB,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,OAAO,EAAE,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M,CAAC;IACf,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,kDAAkD;IAClD,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1D,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5D;AASD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,sBAAsB,EAAE,GAChC,qBAAqB,EAAE,CAyCzB"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// Append-only history of admission slot use. The queue files in admission.ts
|
|
2
|
+
// describe only the present: a waiter or holder disappears the moment it is
|
|
3
|
+
// admitted, released, or pruned. This module keeps one JSON line per finished
|
|
4
|
+
// ticket so a later reader can answer how long work queued, behind what, and
|
|
5
|
+
// how long each holder kept its slot.
|
|
6
|
+
//
|
|
7
|
+
// Layout: <history dir>/<resource>.jsonl, rotated to <resource>.1.jsonl once
|
|
8
|
+
// it passes HISTORY_ROTATE_BYTES. Each line is a complete record appended in a
|
|
9
|
+
// single write, so concurrent writers on one machine never interleave.
|
|
10
|
+
//
|
|
11
|
+
// Toolkit tier: this module must not import src/core (layering check).
|
|
12
|
+
import { appendFileSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, } from "node:fs";
|
|
13
|
+
import { homedir } from "node:os";
|
|
14
|
+
import { basename, join } from "node:path";
|
|
15
|
+
import { coordEnv } from "./env.js";
|
|
16
|
+
export const ADMISSION_HISTORY_SCHEMA_VERSION = 1;
|
|
17
|
+
/** Rotate a resource's history once it passes this size; one older file is kept. */
|
|
18
|
+
const HISTORY_ROTATE_BYTES = 8 * 1024 * 1024;
|
|
19
|
+
/**
|
|
20
|
+
* Persistent machine-wide history directory used for the default admission
|
|
21
|
+
* queue root. The queues live in tmpdir and correctly vanish at reboot; the
|
|
22
|
+
* history is evidence and must survive one.
|
|
23
|
+
*/
|
|
24
|
+
export function defaultAdmissionHistoryDir() {
|
|
25
|
+
const stateHome = process.env.XDG_STATE_HOME || join(homedir(), ".local", "state");
|
|
26
|
+
return join(stateHome, "harnery", "admission-history");
|
|
27
|
+
}
|
|
28
|
+
/** Directory name of a machine-wide queue root (see admissionBaseDir). */
|
|
29
|
+
const SHARED_QUEUE_DIRNAME = "harnery-admission";
|
|
30
|
+
/**
|
|
31
|
+
* Where history for a given queue root is written, or null when disabled.
|
|
32
|
+
* HARNERY_ADMISSION_HISTORY=off disables recording; HARNERY_ADMISSION_HISTORY_DIR
|
|
33
|
+
* overrides the location. A machine-wide queue root, named `harnery-admission`
|
|
34
|
+
* under any temp directory, records to the persistent state directory. Any
|
|
35
|
+
* other root (an isolated test queue, for example) records beside itself as
|
|
36
|
+
* `<root>-history`, so isolated queues never write into the
|
|
37
|
+
* machine-wide history and the history directory is never listed as a resource.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveAdmissionHistoryDir(queueDir) {
|
|
40
|
+
const toggle = coordEnv("ADMISSION_HISTORY")?.trim().toLowerCase();
|
|
41
|
+
if (toggle === "off" || toggle === "0" || toggle === "false")
|
|
42
|
+
return null;
|
|
43
|
+
const override = coordEnv("ADMISSION_HISTORY_DIR");
|
|
44
|
+
if (override)
|
|
45
|
+
return override;
|
|
46
|
+
return basename(queueDir) === SHARED_QUEUE_DIRNAME
|
|
47
|
+
? defaultAdmissionHistoryDir()
|
|
48
|
+
: `${queueDir}-history`;
|
|
49
|
+
}
|
|
50
|
+
function historyFile(dir, resource, generation = 0) {
|
|
51
|
+
return join(dir, generation === 0 ? `${resource}.jsonl` : `${resource}.${generation}.jsonl`);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Append one record. History is diagnostic: a write failure never fails the
|
|
55
|
+
* caller's admission, so errors are swallowed.
|
|
56
|
+
*/
|
|
57
|
+
export function appendAdmissionHistory(dir, record) {
|
|
58
|
+
if (!dir)
|
|
59
|
+
return;
|
|
60
|
+
try {
|
|
61
|
+
mkdirSync(dir, { recursive: true });
|
|
62
|
+
const path = historyFile(dir, record.resource);
|
|
63
|
+
try {
|
|
64
|
+
if (statSync(path).size > HISTORY_ROTATE_BYTES) {
|
|
65
|
+
renameSync(path, historyFile(dir, record.resource, 1));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// no file yet, or a peer rotated it first
|
|
70
|
+
}
|
|
71
|
+
appendFileSync(path, `${JSON.stringify(record)}\n`);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// diagnostic only
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Resources with recorded history in a history directory. */
|
|
78
|
+
export function listAdmissionHistoryResources(dir) {
|
|
79
|
+
try {
|
|
80
|
+
const names = new Set();
|
|
81
|
+
for (const name of readdirSync(dir)) {
|
|
82
|
+
const match = /^(.+?)(?:\.1)?\.jsonl$/.exec(name);
|
|
83
|
+
if (match?.[1])
|
|
84
|
+
names.add(match[1]);
|
|
85
|
+
}
|
|
86
|
+
return [...names].sort();
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function parseRecord(line) {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(line);
|
|
95
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
96
|
+
return undefined;
|
|
97
|
+
const record = parsed;
|
|
98
|
+
if (typeof record.resource !== "string" ||
|
|
99
|
+
typeof record.outcome !== "string" ||
|
|
100
|
+
typeof record.enqueued_at !== "string" ||
|
|
101
|
+
typeof record.ended_at !== "string" ||
|
|
102
|
+
typeof record.wait_ms !== "number") {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return record;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Read history records, oldest first, across the current and rotated files. */
|
|
112
|
+
export function readAdmissionHistory(dir, query = {}) {
|
|
113
|
+
if (!dir)
|
|
114
|
+
return [];
|
|
115
|
+
const resources = query.resource !== undefined ? [query.resource] : listAdmissionHistoryResources(dir);
|
|
116
|
+
const needle = query.labelContains?.toLowerCase();
|
|
117
|
+
const records = [];
|
|
118
|
+
for (const resource of resources) {
|
|
119
|
+
for (const path of [historyFile(dir, resource, 1), historyFile(dir, resource)]) {
|
|
120
|
+
let text;
|
|
121
|
+
try {
|
|
122
|
+
text = readFileSync(path, "utf8");
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
for (const line of text.split("\n")) {
|
|
128
|
+
if (!line)
|
|
129
|
+
continue;
|
|
130
|
+
const record = parseRecord(line);
|
|
131
|
+
if (!record)
|
|
132
|
+
continue;
|
|
133
|
+
if (query.sinceMs !== undefined && Date.parse(record.ended_at) < query.sinceMs)
|
|
134
|
+
continue;
|
|
135
|
+
if (needle && !record.label.toLowerCase().includes(needle))
|
|
136
|
+
continue;
|
|
137
|
+
records.push(record);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return records.sort((a, b) => Date.parse(a.ended_at) - Date.parse(b.ended_at));
|
|
142
|
+
}
|
|
143
|
+
function percentile(sorted, p) {
|
|
144
|
+
if (sorted.length === 0)
|
|
145
|
+
return 0;
|
|
146
|
+
return sorted[Math.min(sorted.length - 1, Math.ceil(p * sorted.length) - 1)] ?? 0;
|
|
147
|
+
}
|
|
148
|
+
const QUEUED_THRESHOLD_MS = 1_000;
|
|
149
|
+
/**
|
|
150
|
+
* Group records by resource and label, most total wait first, so the work
|
|
151
|
+
* that spends the longest queueing leads the report.
|
|
152
|
+
*/
|
|
153
|
+
export function summarizeAdmissionHistory(records) {
|
|
154
|
+
const groups = new Map();
|
|
155
|
+
for (const record of records) {
|
|
156
|
+
const key = `${record.resource}\u0000${record.label}`;
|
|
157
|
+
const bucket = groups.get(key);
|
|
158
|
+
if (bucket)
|
|
159
|
+
bucket.push(record);
|
|
160
|
+
else
|
|
161
|
+
groups.set(key, [record]);
|
|
162
|
+
}
|
|
163
|
+
const summaries = [];
|
|
164
|
+
for (const bucket of groups.values()) {
|
|
165
|
+
const first = bucket[0];
|
|
166
|
+
const waits = bucket.map((record) => record.wait_ms).sort((a, b) => a - b);
|
|
167
|
+
const holds = bucket
|
|
168
|
+
.filter((record) => record.outcome === "released" && typeof record.hold_ms === "number")
|
|
169
|
+
.map((record) => record.hold_ms)
|
|
170
|
+
.sort((a, b) => a - b);
|
|
171
|
+
const outcomes = {};
|
|
172
|
+
for (const record of bucket)
|
|
173
|
+
outcomes[record.outcome] = (outcomes[record.outcome] ?? 0) + 1;
|
|
174
|
+
summaries.push({
|
|
175
|
+
resource: first.resource,
|
|
176
|
+
label: first.label,
|
|
177
|
+
count: bucket.length,
|
|
178
|
+
queued: waits.filter((wait) => wait >= QUEUED_THRESHOLD_MS).length,
|
|
179
|
+
wait_ms: {
|
|
180
|
+
p50: percentile(waits, 0.5),
|
|
181
|
+
p90: percentile(waits, 0.9),
|
|
182
|
+
max: waits[waits.length - 1] ?? 0,
|
|
183
|
+
total: waits.reduce((sum, wait) => sum + wait, 0),
|
|
184
|
+
},
|
|
185
|
+
hold_ms: holds.length > 0
|
|
186
|
+
? {
|
|
187
|
+
p50: percentile(holds, 0.5),
|
|
188
|
+
p90: percentile(holds, 0.9),
|
|
189
|
+
max: holds[holds.length - 1] ?? 0,
|
|
190
|
+
}
|
|
191
|
+
: null,
|
|
192
|
+
outcomes,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return summaries.sort((a, b) => b.wait_ms.total - a.wait_ms.total);
|
|
196
|
+
}
|
package/dist/lib/admission.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type AdmissionReleaseResult } from "./admission-history.js";
|
|
2
|
+
export type { AdmissionReleaseResult } from "./admission-history.js";
|
|
1
3
|
export interface AdmissionConfig {
|
|
2
4
|
/** Base directory holding one subdirectory per resource. */
|
|
3
5
|
dir: string;
|
|
@@ -9,6 +11,11 @@ export interface AdmissionConfig {
|
|
|
9
11
|
pollMs?: number;
|
|
10
12
|
/** Entries older than this are pruned regardless of PID (default 6h). */
|
|
11
13
|
ttlMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Directory for the slot-use history. Omitted: resolved from the queue
|
|
16
|
+
* directory (see resolveAdmissionHistoryDir). null: record nothing.
|
|
17
|
+
*/
|
|
18
|
+
historyDir?: string | null;
|
|
12
19
|
}
|
|
13
20
|
export interface AdmissionEntry {
|
|
14
21
|
pid: number;
|
|
@@ -16,6 +23,12 @@ export interface AdmissionEntry {
|
|
|
16
23
|
created_at: string;
|
|
17
24
|
/** Set on holders once admitted. */
|
|
18
25
|
acquired_at?: string;
|
|
26
|
+
/** Working directory of the queueing process. */
|
|
27
|
+
cwd?: string;
|
|
28
|
+
/** Capacity the queueing process asked for. */
|
|
29
|
+
capacity?: number;
|
|
30
|
+
/** Set on holders that had to wait: the holder labels they first waited behind. */
|
|
31
|
+
waited_behind?: string[];
|
|
19
32
|
}
|
|
20
33
|
export interface AdmissionWaitInfo {
|
|
21
34
|
/** 1-based position in the ticket queue. */
|
|
@@ -29,14 +42,19 @@ export interface AdmissionAcquireOptions {
|
|
|
29
42
|
timeoutMs?: number;
|
|
30
43
|
/** Progress callback, invoked at most once per poll while waiting. */
|
|
31
44
|
onWait?: (info: AdmissionWaitInfo) => void;
|
|
45
|
+
/** Time the caller already spent deferring for memory pressure, for the history. */
|
|
46
|
+
pressureWaitMs?: number;
|
|
32
47
|
}
|
|
33
48
|
export interface AdmissionHandle {
|
|
34
49
|
/** The held entry's filename (diagnostics). */
|
|
35
50
|
entry: string;
|
|
36
51
|
/** Milliseconds spent waiting in the queue. */
|
|
37
52
|
waitedMs: number;
|
|
38
|
-
/**
|
|
39
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Give the slot back and record the slot use in the history. Safe to call
|
|
55
|
+
* more than once; only the first call records.
|
|
56
|
+
*/
|
|
57
|
+
release: (result?: AdmissionReleaseResult) => void;
|
|
40
58
|
}
|
|
41
59
|
export declare class AdmissionTimeoutError extends Error {
|
|
42
60
|
readonly holders: AdmissionEntry[];
|
|
@@ -58,14 +76,45 @@ export interface AdmissionStatus {
|
|
|
58
76
|
waiters: AdmissionEntry[];
|
|
59
77
|
}
|
|
60
78
|
/** Snapshot the queue for one resource, pruning dead entries on the way. */
|
|
61
|
-
export declare function admissionStatus(config: Pick<AdmissionConfig, "dir" | "resource" | "ttlMs">): AdmissionStatus;
|
|
79
|
+
export declare function admissionStatus(config: Pick<AdmissionConfig, "dir" | "resource" | "ttlMs" | "historyDir">): AdmissionStatus;
|
|
62
80
|
/**
|
|
63
|
-
* Base directory for admission queue state.
|
|
64
|
-
* is correct
|
|
65
|
-
* HARNERY_ADMISSION_DIR. Host CLIs and harn commands must share
|
|
66
|
-
* so they join the same machine-wide queues.
|
|
81
|
+
* Base directory for admission queue state. The temp directory clears on
|
|
82
|
+
* reboot, which is correct: stale queue state must not outlive the boot.
|
|
83
|
+
* Override with HARNERY_ADMISSION_DIR. Host CLIs and harn commands must share
|
|
84
|
+
* this helper so they join the same machine-wide queues.
|
|
85
|
+
*
|
|
86
|
+
* On POSIX the default is the literal /tmp, not os.tmpdir(): agent sandboxes
|
|
87
|
+
* often set a private TMPDIR per session, and a queue under it would admit
|
|
88
|
+
* every session on its own.
|
|
67
89
|
*/
|
|
68
90
|
export declare function admissionBaseDir(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Linux memory pressure: the `full avg10` figure from /proc/pressure/memory,
|
|
93
|
+
* the share of the last ten seconds in which every runnable task stalled on
|
|
94
|
+
* memory. Undefined where pressure stall information is unavailable.
|
|
95
|
+
*/
|
|
96
|
+
export declare function memoryPressureFullAvg10(): number | undefined;
|
|
97
|
+
export interface PressureWaitOptions {
|
|
98
|
+
/** Defer while `full avg10` is above this value. */
|
|
99
|
+
threshold: number;
|
|
100
|
+
/** Give up deferring after this long and let the caller start anyway. */
|
|
101
|
+
maxWaitMs: number;
|
|
102
|
+
pollMs?: number;
|
|
103
|
+
/** Pressure reader; tests inject one. */
|
|
104
|
+
read?: () => number | undefined;
|
|
105
|
+
/** Called once when deferral starts and once if it gives up. */
|
|
106
|
+
onWait?: (event: {
|
|
107
|
+
pressure: number;
|
|
108
|
+
waitedMs: number;
|
|
109
|
+
gaveUp: boolean;
|
|
110
|
+
}) => void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Wait, holding no slot, while the machine is already stalling on memory, so
|
|
114
|
+
* a heavy job does not start into a storm. Never blocks forever: after
|
|
115
|
+
* maxWaitMs it returns and the caller starts anyway. Returns the time waited.
|
|
116
|
+
*/
|
|
117
|
+
export declare function waitForMemoryPressure(options: PressureWaitOptions): Promise<number>;
|
|
69
118
|
/** Resources present under an admission base directory. */
|
|
70
119
|
export declare function listAdmissionResources(dir: string): string[];
|
|
71
120
|
//# sourceMappingURL=admission.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/lib/admission.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/lib/admission.ts"],"names":[],"mappings":"AAoCA,OAAO,EAGL,KAAK,sBAAsB,EAG5B,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,QAAQ,EAAE,MAA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