@khorsheed/dsh-ankh-guard 0.1.1 → 0.3.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 +33 -0
- package/README.en.md +75 -29
- package/README.i18n.yaml +2 -2
- package/README.md +74 -29
- package/lib/cli.js +2349 -182
- package/lib/client.js +344 -0
- package/lib/exit-agent.js +5 -2
- package/lib/index.js +746 -40
- package/lib/invariant.js +1 -1
- package/lib/preflight-runner.js +125 -47
- package/lib/restart-context-DUyExi9O.js +1245 -0
- package/lib/restart-context-DlaDZWKq.js +1250 -0
- package/lib/{state-Dhx9VG44.js → state-CZMypGkB.js} +97 -13
- package/lib/test-seam-cli.js +24 -0
- package/lib/test-seam-dwvaKjRp.js +459 -0
- package/lib/test-seam.js +2 -0
- package/lib/types/browser-handoff.d.ts +55 -0
- package/lib/types/browser-handoff.js +489 -0
- package/lib/types/cli.d.ts +34 -4
- package/lib/types/cli.js +1421 -166
- package/lib/types/client/index.d.ts +15 -0
- package/lib/types/client/index.js +348 -0
- package/lib/types/deployment-proof.d.ts +24 -0
- package/lib/types/deployment-proof.js +314 -0
- package/lib/types/exit-agent.js +2 -0
- package/lib/types/git.d.ts +12 -3
- package/lib/types/git.js +69 -7
- package/lib/types/index.d.ts +66 -3
- package/lib/types/index.js +192 -41
- package/lib/types/launch-spec.d.ts +263 -0
- package/lib/types/launch-spec.js +823 -0
- package/lib/types/preflight-runner.d.ts +23 -12
- package/lib/types/preflight-runner.js +152 -57
- package/lib/types/processes.d.ts +38 -6
- package/lib/types/processes.js +236 -10
- package/lib/types/restart-context.d.ts +50 -0
- package/lib/types/restart-context.js +117 -6
- package/lib/types/restart-request.d.ts +32 -0
- package/lib/types/restart-request.js +128 -0
- package/lib/types/state-files.d.ts +30 -0
- package/lib/types/state-files.js +55 -0
- package/lib/types/state.d.ts +29 -2
- package/lib/types/state.js +52 -7
- package/lib/types/temp-artifact.d.ts +15 -0
- package/lib/types/temp-artifact.js +17 -0
- package/lib/types/test-seam-cli.d.ts +3 -0
- package/lib/types/test-seam-cli.js +27 -0
- package/lib/types/test-seam.d.ts +55 -0
- package/lib/types/test-seam.js +112 -0
- package/lib/types/transition.d.ts +118 -0
- package/lib/types/transition.js +717 -0
- package/package.json +30 -11
- package/scripts/dsh-watchdog.sh +1388 -80
- package/scripts/install-launchd.sh +43 -5
- package/scripts/install-systemd.sh +43 -5
- package/scripts/on-install.js +1 -1
- package/skills/dsh-self-restart-guard/SKILL.md +38 -12
- package/lib/processes-hCAmwma-.js +0 -127
- package/lib/restart-context-DmnQXNf-.js +0 -421
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** One reversible filesystem operation approved before a cutover. */
|
|
2
|
+
export interface TransitionOperation {
|
|
3
|
+
kind: 'quarantine';
|
|
4
|
+
/** Path relative to the shared previous/target dsh home. */
|
|
5
|
+
path: string;
|
|
6
|
+
/** State that both isolated preflight and live apply must observe. */
|
|
7
|
+
expect: 'present' | 'absent';
|
|
8
|
+
}
|
|
9
|
+
/** Caller-authored transition plan. Unknown operation kinds fail closed. */
|
|
10
|
+
export interface TransitionPlan {
|
|
11
|
+
schemaVersion: 1;
|
|
12
|
+
/** Canonical dsh home containing every operation path. */
|
|
13
|
+
home: string;
|
|
14
|
+
operations: TransitionOperation[];
|
|
15
|
+
}
|
|
16
|
+
/** Immutable reference carried by the durable launch state and receipt. */
|
|
17
|
+
export interface TransitionReference {
|
|
18
|
+
version: 1;
|
|
19
|
+
planPath: string;
|
|
20
|
+
planSha256: string;
|
|
21
|
+
operationCount: number;
|
|
22
|
+
}
|
|
23
|
+
type ApplyState = 'pending' | 'moving' | 'absent' | 'quarantined';
|
|
24
|
+
type RollbackState = 'pending' | 'moving-target' | 'target-retained' | 'target-absent' | 'restoring' | 'restored';
|
|
25
|
+
export type TransitionPhase = 'prepared' | 'applying' | 'applied' | 'rolling-back' | 'rolled-back' | 'failed';
|
|
26
|
+
interface TransitionEntryState {
|
|
27
|
+
path: string;
|
|
28
|
+
original: 'present' | 'absent';
|
|
29
|
+
apply: ApplyState;
|
|
30
|
+
rollback: RollbackState;
|
|
31
|
+
}
|
|
32
|
+
/** Crash-recovery journal for one transition. */
|
|
33
|
+
export interface TransitionRecord {
|
|
34
|
+
version: 1;
|
|
35
|
+
cutoverId: string;
|
|
36
|
+
planSha256: string;
|
|
37
|
+
phase: TransitionPhase;
|
|
38
|
+
entries: TransitionEntryState[];
|
|
39
|
+
updatedAt: number;
|
|
40
|
+
failure?: {
|
|
41
|
+
operation: 'apply' | 'rollback';
|
|
42
|
+
detail: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Result returned after an idempotent transition operation. */
|
|
46
|
+
export interface TransitionResult {
|
|
47
|
+
phase: 'applied' | 'rolled-back';
|
|
48
|
+
changed: string[];
|
|
49
|
+
unchanged: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Validate and normalize an untrusted transition plan.
|
|
53
|
+
* @param raw - Parsed JSON plan.
|
|
54
|
+
* @param expectedHome - Home shared by the previous and target launch specs.
|
|
55
|
+
* @param stateDir - Guard state directory, which no operation may move.
|
|
56
|
+
* @returns A canonical plan safe for durable preparation.
|
|
57
|
+
*/
|
|
58
|
+
export declare function validateTransitionPlan(raw: unknown, expectedHome: string, stateDir?: string): TransitionPlan;
|
|
59
|
+
/**
|
|
60
|
+
* Persist the immutable plan and an empty crash-recovery journal before the previous host stops.
|
|
61
|
+
* @param raw - Validated or untrusted plan JSON.
|
|
62
|
+
* @param expectedHome - Shared launch home.
|
|
63
|
+
* @param stateDir - Guard state directory.
|
|
64
|
+
* @param cutoverId - Unique launch cutover identifier.
|
|
65
|
+
* @returns Reference stored in the launch state and redacted receipt.
|
|
66
|
+
*/
|
|
67
|
+
export declare function prepareTransition(raw: unknown, expectedHome: string, stateDir: string, cutoverId: string): TransitionReference;
|
|
68
|
+
/**
|
|
69
|
+
* Apply a prepared transition after the previous host has stopped.
|
|
70
|
+
* @param reference - Immutable reference from the launch state.
|
|
71
|
+
* @param expectedHome - Shared launch home.
|
|
72
|
+
* @param stateDir - Guard state directory.
|
|
73
|
+
* @param cutoverId - Active cutover identifier.
|
|
74
|
+
* @returns Idempotent apply result.
|
|
75
|
+
*/
|
|
76
|
+
export declare function applyTransition(reference: TransitionReference, expectedHome: string, stateDir: string, cutoverId: string): TransitionResult;
|
|
77
|
+
/**
|
|
78
|
+
* Roll back an applied or partially applied transition before previous starts.
|
|
79
|
+
* Target-created replacements are retained for diagnosis rather than deleted.
|
|
80
|
+
* @param reference - Immutable reference from the launch state.
|
|
81
|
+
* @param expectedHome - Shared launch home.
|
|
82
|
+
* @param stateDir - Guard state directory.
|
|
83
|
+
* @param cutoverId - Active cutover identifier.
|
|
84
|
+
* @returns Idempotent rollback result.
|
|
85
|
+
*/
|
|
86
|
+
export declare function rollbackTransition(reference: TransitionReference, expectedHome: string, stateDir: string, cutoverId: string): TransitionResult;
|
|
87
|
+
/**
|
|
88
|
+
* Read and verify a transition record through its immutable reference.
|
|
89
|
+
* @param reference - Reference stored in launch state.
|
|
90
|
+
* @param expectedHome - Shared launch home.
|
|
91
|
+
* @param stateDir - Guard state directory.
|
|
92
|
+
* @param cutoverId - Cutover identifier.
|
|
93
|
+
* @returns Verified crash-recovery journal.
|
|
94
|
+
*/
|
|
95
|
+
export declare function readTransitionRecord(reference: TransitionReference, expectedHome: string, stateDir: string, cutoverId: string): TransitionRecord;
|
|
96
|
+
/**
|
|
97
|
+
* Clone a live home while retaining a contained package-link graph. Internal
|
|
98
|
+
* links are rebuilt against copied nodes; external targets are deduplicated in
|
|
99
|
+
* a snapshot-owned materialization area. No retained link resolves outside the
|
|
100
|
+
* snapshot root, so writes through pnpm/Cordis links cannot reach live bytes.
|
|
101
|
+
* Runtime entries without copyable content (sockets, FIFOs — and links to
|
|
102
|
+
* them) are skipped and counted, never copied; the top-level scratch/ tree is
|
|
103
|
+
* excluded for size. Device nodes still fail closed.
|
|
104
|
+
* @param sourceHome - Live dsh home to read.
|
|
105
|
+
* @returns Isolated home, an idempotent cleanup callback, and the count of skipped runtime entries.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createPreflightSnapshot(sourceHome: string): {
|
|
108
|
+
home: string;
|
|
109
|
+
root: string;
|
|
110
|
+
skippedRuntimeEntries: number;
|
|
111
|
+
cleanup(): void;
|
|
112
|
+
};
|
|
113
|
+
export declare function createTransitionPreflightSnapshot(plan: TransitionPlan): {
|
|
114
|
+
home: string;
|
|
115
|
+
cleanup(): void;
|
|
116
|
+
};
|
|
117
|
+
export {};
|
|
118
|
+
//# sourceMappingURL=transition.d.ts.map
|