@skillcap/gdh 0.22.0 → 0.24.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/INSTALL-BUNDLE.json +1 -1
- package/RELEASE-SPAN-UPDATE-CONTRACTS.json +129 -0
- package/node_modules/@gdh/adapters/dist/authoring-hook-render.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/authoring-hook-render.js +9 -2
- package/node_modules/@gdh/adapters/dist/authoring-hook-render.js.map +1 -1
- package/node_modules/@gdh/adapters/dist/claude-statusline-render.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/claude-statusline-render.js +2 -1
- package/node_modules/@gdh/adapters/dist/claude-statusline-render.js.map +1 -1
- package/node_modules/@gdh/adapters/dist/claude-update-hook-render.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/claude-update-hook-render.js +2 -1
- package/node_modules/@gdh/adapters/dist/claude-update-hook-render.js.map +1 -1
- package/node_modules/@gdh/adapters/dist/claude-update-worker-render.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/claude-update-worker-render.js +2 -1
- package/node_modules/@gdh/adapters/dist/claude-update-worker-render.js.map +1 -1
- package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.d.ts +71 -0
- package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.d.ts.map +1 -0
- package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.js +89 -0
- package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.js.map +1 -0
- package/node_modules/@gdh/adapters/dist/durable-backup.d.ts +209 -0
- package/node_modules/@gdh/adapters/dist/durable-backup.d.ts.map +1 -0
- package/node_modules/@gdh/adapters/dist/durable-backup.js +346 -0
- package/node_modules/@gdh/adapters/dist/durable-backup.js.map +1 -0
- package/node_modules/@gdh/adapters/dist/index.d.ts +10 -1
- package/node_modules/@gdh/adapters/dist/index.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/index.js +24 -2
- package/node_modules/@gdh/adapters/dist/index.js.map +1 -1
- package/node_modules/@gdh/adapters/dist/inventory-sweep.d.ts +53 -0
- package/node_modules/@gdh/adapters/dist/inventory-sweep.d.ts.map +1 -0
- package/node_modules/@gdh/adapters/dist/inventory-sweep.js +98 -0
- package/node_modules/@gdh/adapters/dist/inventory-sweep.js.map +1 -0
- package/node_modules/@gdh/adapters/dist/process-orchestration.d.ts +223 -0
- package/node_modules/@gdh/adapters/dist/process-orchestration.d.ts.map +1 -0
- package/node_modules/@gdh/adapters/dist/process-orchestration.js +368 -0
- package/node_modules/@gdh/adapters/dist/process-orchestration.js.map +1 -0
- package/node_modules/@gdh/adapters/dist/self-update-mechanics.d.ts +157 -14
- package/node_modules/@gdh/adapters/dist/self-update-mechanics.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/self-update-mechanics.js +570 -89
- package/node_modules/@gdh/adapters/dist/self-update-mechanics.js.map +1 -1
- package/node_modules/@gdh/adapters/dist/skill-rendering.d.ts.map +1 -1
- package/node_modules/@gdh/adapters/dist/skill-rendering.js +25 -0
- package/node_modules/@gdh/adapters/dist/skill-rendering.js.map +1 -1
- package/node_modules/@gdh/adapters/package.json +8 -8
- package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.d.ts +112 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.d.ts.map +1 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.js +264 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.js.map +1 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker.d.ts +92 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker.d.ts.map +1 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker.js +532 -0
- package/node_modules/@gdh/authoring/dist/diagnostics-broker.js.map +1 -0
- package/node_modules/@gdh/authoring/dist/index.d.ts +1 -0
- package/node_modules/@gdh/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@gdh/authoring/dist/index.js +1 -0
- package/node_modules/@gdh/authoring/dist/index.js.map +1 -1
- package/node_modules/@gdh/authoring/dist/lsp-client.d.ts +16 -0
- package/node_modules/@gdh/authoring/dist/lsp-client.d.ts.map +1 -1
- package/node_modules/@gdh/authoring/dist/lsp-client.js +24 -0
- package/node_modules/@gdh/authoring/dist/lsp-client.js.map +1 -1
- package/node_modules/@gdh/authoring/dist/lsp.d.ts.map +1 -1
- package/node_modules/@gdh/authoring/dist/lsp.js +123 -2
- package/node_modules/@gdh/authoring/dist/lsp.js.map +1 -1
- package/node_modules/@gdh/authoring/package.json +2 -2
- package/node_modules/@gdh/cli/dist/index.d.ts +9 -0
- package/node_modules/@gdh/cli/dist/index.d.ts.map +1 -1
- package/node_modules/@gdh/cli/dist/index.js +423 -5
- package/node_modules/@gdh/cli/dist/index.js.map +1 -1
- package/node_modules/@gdh/cli/dist/migrate.d.ts +152 -1
- package/node_modules/@gdh/cli/dist/migrate.d.ts.map +1 -1
- package/node_modules/@gdh/cli/dist/migrate.js +295 -9
- package/node_modules/@gdh/cli/dist/migrate.js.map +1 -1
- package/node_modules/@gdh/cli/dist/self-update.d.ts +14 -0
- package/node_modules/@gdh/cli/dist/self-update.d.ts.map +1 -1
- package/node_modules/@gdh/cli/dist/self-update.js +197 -15
- package/node_modules/@gdh/cli/dist/self-update.js.map +1 -1
- package/node_modules/@gdh/cli/package.json +10 -10
- package/node_modules/@gdh/core/dist/index.d.ts +209 -6
- package/node_modules/@gdh/core/dist/index.d.ts.map +1 -1
- package/node_modules/@gdh/core/dist/index.js +28 -5
- package/node_modules/@gdh/core/dist/index.js.map +1 -1
- package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.d.ts +3 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.js +247 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.d.ts +3 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.js +152 -0
- package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.d.ts +3 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.js +67 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/index.d.ts +37 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/index.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/index.js +60 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/index.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/types.d.ts +121 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/types.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/types.js +2 -0
- package/node_modules/@gdh/core/dist/migrations/envelopes/types.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/golden-harness.d.ts +40 -0
- package/node_modules/@gdh/core/dist/migrations/golden-harness.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/golden-harness.js +71 -0
- package/node_modules/@gdh/core/dist/migrations/golden-harness.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.d.ts +322 -0
- package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.js +384 -0
- package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/probes.d.ts +58 -0
- package/node_modules/@gdh/core/dist/migrations/probes.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/probes.js +112 -0
- package/node_modules/@gdh/core/dist/migrations/probes.js.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/registry.d.ts +205 -0
- package/node_modules/@gdh/core/dist/migrations/registry.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/migrations/registry.js +214 -0
- package/node_modules/@gdh/core/dist/migrations/registry.js.map +1 -0
- package/node_modules/@gdh/core/dist/state/atomic-write.d.ts +19 -0
- package/node_modules/@gdh/core/dist/state/atomic-write.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/state/atomic-write.js +34 -0
- package/node_modules/@gdh/core/dist/state/atomic-write.js.map +1 -0
- package/node_modules/@gdh/core/dist/state/migration-state.d.ts +135 -0
- package/node_modules/@gdh/core/dist/state/migration-state.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/state/migration-state.js +186 -0
- package/node_modules/@gdh/core/dist/state/migration-state.js.map +1 -0
- package/node_modules/@gdh/core/dist/state/processes-snapshot.d.ts +72 -0
- package/node_modules/@gdh/core/dist/state/processes-snapshot.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/state/processes-snapshot.js +113 -0
- package/node_modules/@gdh/core/dist/state/processes-snapshot.js.map +1 -0
- package/node_modules/@gdh/core/dist/state/render-inventory.d.ts +54 -0
- package/node_modules/@gdh/core/dist/state/render-inventory.d.ts.map +1 -0
- package/node_modules/@gdh/core/dist/state/render-inventory.js +77 -0
- package/node_modules/@gdh/core/dist/state/render-inventory.js.map +1 -0
- package/node_modules/@gdh/core/package.json +1 -1
- package/node_modules/@gdh/docs/dist/agent-contract.d.ts.map +1 -1
- package/node_modules/@gdh/docs/dist/agent-contract.js +2 -1
- package/node_modules/@gdh/docs/dist/agent-contract.js.map +1 -1
- package/node_modules/@gdh/docs/dist/guidance.d.ts.map +1 -1
- package/node_modules/@gdh/docs/dist/guidance.js +14 -7
- package/node_modules/@gdh/docs/dist/guidance.js.map +1 -1
- package/node_modules/@gdh/docs/package.json +2 -2
- package/node_modules/@gdh/mcp/dist/index.d.ts.map +1 -1
- package/node_modules/@gdh/mcp/dist/index.js +77 -1
- package/node_modules/@gdh/mcp/dist/index.js.map +1 -1
- package/node_modules/@gdh/mcp/package.json +8 -8
- package/node_modules/@gdh/observability/package.json +2 -2
- package/node_modules/@gdh/runtime/dist/bridge-surface.js +63 -2
- package/node_modules/@gdh/runtime/dist/bridge-surface.js.map +1 -1
- package/node_modules/@gdh/runtime/package.json +2 -2
- package/node_modules/@gdh/scan/package.json +3 -3
- package/node_modules/@gdh/verify/package.json +7 -7
- package/package.json +11 -11
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { type GdhMigrationVersionPair } from "@gdh/core";
|
|
2
|
+
/**
|
|
3
|
+
* Workspace-relative directory for the durable update backup.
|
|
4
|
+
*
|
|
5
|
+
* Single durable backup per STA-01 / D-14: this directory is overwritten
|
|
6
|
+
* (rm -rf semantics) on every successful backup write. Multi-backup retention
|
|
7
|
+
* is explicitly deferred (see 72-CONTEXT.md "Deferred Ideas").
|
|
8
|
+
*/
|
|
9
|
+
export declare const BACKUP_RELATIVE_PATH = ".gdh-state/backup";
|
|
10
|
+
/**
|
|
11
|
+
* Workspace-relative staging directory used to make the backup write atomic
|
|
12
|
+
* at the directory level (Pitfall 6 / T-72-04-03). The staged tree is built
|
|
13
|
+
* here, then renamed onto BACKUP_RELATIVE_PATH so the prior backup is never
|
|
14
|
+
* absent from disk between rm-rf and write.
|
|
15
|
+
*/
|
|
16
|
+
export declare const BACKUP_STAGING_RELATIVE_PATH = ".gdh-state/backup.new";
|
|
17
|
+
/** Workspace-relative path to the per-backup manifest. */
|
|
18
|
+
export declare const BACKUP_MANIFEST_RELATIVE_PATH = ".gdh-state/backup/manifest.json";
|
|
19
|
+
export type GdhBackupPreservationReason = "class_1_backup_then_overwrite";
|
|
20
|
+
export type GdhBackupMarkerState = "absent" | "present" | "not_applicable";
|
|
21
|
+
/**
|
|
22
|
+
* WFL-02 / D-24 preservation note attached to the backup manifest. Emitted
|
|
23
|
+
* when a class-1 file's GDH ownership marker is absent (user-edited drift)
|
|
24
|
+
* and the file is captured into the backup BEFORE re-rendering.
|
|
25
|
+
*/
|
|
26
|
+
export interface GdhBackupPreservationNote {
|
|
27
|
+
readonly path: string;
|
|
28
|
+
readonly reason: GdhBackupPreservationReason;
|
|
29
|
+
readonly marker_state: GdhBackupMarkerState;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Per-path capture entry recorded in the backup manifest. `existed: false`
|
|
33
|
+
* matches the legacy in-memory rollbackOriginals null-content semantics: the
|
|
34
|
+
* file did not exist pre-update, so restore must `rm` the original path.
|
|
35
|
+
*/
|
|
36
|
+
export interface GdhBackupCapturedPath {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
readonly existed: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Backup manifest schema (D-13). Version-locked at 1; readers reject any
|
|
42
|
+
* other backup_version with `null` (degraded fallback) so a future schema
|
|
43
|
+
* bump does not silently corrupt restore.
|
|
44
|
+
*/
|
|
45
|
+
export interface GdhBackupManifest {
|
|
46
|
+
readonly backup_version: 1;
|
|
47
|
+
readonly applied_at: string;
|
|
48
|
+
readonly from_pair: GdhMigrationVersionPair;
|
|
49
|
+
readonly to_pair: GdhMigrationVersionPair;
|
|
50
|
+
readonly from_pin: string;
|
|
51
|
+
readonly to_pin: string;
|
|
52
|
+
readonly captured_paths: readonly GdhBackupCapturedPath[];
|
|
53
|
+
readonly preservation_notes: readonly GdhBackupPreservationNote[];
|
|
54
|
+
}
|
|
55
|
+
export interface GdhWriteDurableBackupInput {
|
|
56
|
+
readonly targetPath: string;
|
|
57
|
+
readonly fromPair: GdhMigrationVersionPair;
|
|
58
|
+
readonly toPair: GdhMigrationVersionPair;
|
|
59
|
+
readonly fromPin: string;
|
|
60
|
+
readonly toPin: string;
|
|
61
|
+
/** Workspace-relative POSIX paths to capture (planned action paths + .gdh/project.yaml). */
|
|
62
|
+
readonly plannedPaths: readonly string[];
|
|
63
|
+
/** WFL-02 preservation notes attached to the manifest. */
|
|
64
|
+
readonly preservationNotes?: readonly GdhBackupPreservationNote[];
|
|
65
|
+
/** Optional clock for tests; defaults to () => new Date().toISOString(). */
|
|
66
|
+
readonly nowIso?: () => string;
|
|
67
|
+
}
|
|
68
|
+
export interface GdhWriteDurableBackupSkipped {
|
|
69
|
+
readonly path: string;
|
|
70
|
+
readonly reason: "path_traversal_blocked";
|
|
71
|
+
}
|
|
72
|
+
export type GdhWriteDurableBackupResult = {
|
|
73
|
+
readonly state: "written";
|
|
74
|
+
readonly backupPath: string;
|
|
75
|
+
readonly manifest: GdhBackupManifest;
|
|
76
|
+
readonly skipped: readonly GdhWriteDurableBackupSkipped[];
|
|
77
|
+
} | {
|
|
78
|
+
readonly state: "skipped_no_planned_paths";
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Write a single durable backup at .gdh-state/backup/ (STA-01 / D-13 / D-14).
|
|
82
|
+
*
|
|
83
|
+
* Staged-write strategy (T-72-04-03 mitigation, Pitfall 6):
|
|
84
|
+
* 1. Pre-clean .gdh-state/backup.new/ from any prior interrupted run.
|
|
85
|
+
* 2. Capture every plannedPaths entry into .gdh-state/backup.new/, mirroring
|
|
86
|
+
* the workspace-relative directory structure. Missing files are recorded
|
|
87
|
+
* in the manifest with existed: false but no file is written.
|
|
88
|
+
* 3. Write manifest.json into the staging directory via writeFileAtomic.
|
|
89
|
+
* 4. Remove the prior .gdh-state/backup/ (if any) and rename the staging
|
|
90
|
+
* directory onto it.
|
|
91
|
+
*
|
|
92
|
+
* If interrupted between steps 2 and 4, the prior .gdh-state/backup/ is
|
|
93
|
+
* unchanged and the next call's pre-clean (step 1) removes the partial
|
|
94
|
+
* staging tree before it can corrupt anything.
|
|
95
|
+
*
|
|
96
|
+
* Path-traversal candidates (failing isWorkspaceRelativePath) are recorded
|
|
97
|
+
* in `skipped` with `path_traversal_blocked` and never written or captured.
|
|
98
|
+
*/
|
|
99
|
+
export declare function writeDurableBackup(input: GdhWriteDurableBackupInput): Promise<GdhWriteDurableBackupResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Read the backup manifest from .gdh-state/backup/manifest.json.
|
|
102
|
+
*
|
|
103
|
+
* Returns null on any failure (missing file, JSON parse error, schema
|
|
104
|
+
* mismatch). Never throws — degraded fallback so callers can branch on
|
|
105
|
+
* "no backup present" without try/catch ceremony, and so a corrupted
|
|
106
|
+
* manifest cannot trigger a partial restore (T-72-04-06).
|
|
107
|
+
*/
|
|
108
|
+
export declare function readBackupManifest(targetPath: string): Promise<GdhBackupManifest | null>;
|
|
109
|
+
export type GdhRestoreFromDurableBackupResult = {
|
|
110
|
+
readonly state: "restored";
|
|
111
|
+
readonly restored: readonly string[];
|
|
112
|
+
readonly removed: readonly string[];
|
|
113
|
+
readonly skipped: readonly {
|
|
114
|
+
readonly path: string;
|
|
115
|
+
readonly reason: string;
|
|
116
|
+
}[];
|
|
117
|
+
/**
|
|
118
|
+
* WR-06: Count of captured_paths entries that failed to restore (i.e.,
|
|
119
|
+
* the length of `skipped`). Surfaced as a top-level field so callers
|
|
120
|
+
* can branch on actual restoration success without re-scanning the
|
|
121
|
+
* `skipped` array. When `restored.length === 0 && removed.length === 0
|
|
122
|
+
* && failedCount > 0`, the rollback is effectively a NO-RESTORE: every
|
|
123
|
+
* captured path failed (e.g., disk full, EROFS, EACCES) and the
|
|
124
|
+
* caller should NOT report this as a clean rollback. Pre-existing
|
|
125
|
+
* "best-effort" semantics are preserved (the function still returns
|
|
126
|
+
* \`state: "restored"\` to keep the discriminated-union contract
|
|
127
|
+
* stable for existing callers); the new field is additive.
|
|
128
|
+
*/
|
|
129
|
+
readonly failedCount: number;
|
|
130
|
+
} | {
|
|
131
|
+
readonly state: "no_backup_present";
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Restore byte-equal content for every captured_paths entry in the backup
|
|
135
|
+
* manifest. Mirrors the legacy in-memory rollbackOriginals semantics:
|
|
136
|
+
*
|
|
137
|
+
* - existed: true → atomic-write the backup content over the original path
|
|
138
|
+
* - existed: false → fs.rm the original path (file did not exist pre-update)
|
|
139
|
+
*
|
|
140
|
+
* The backup directory itself is read-only during restore (T-72-04 contract):
|
|
141
|
+
* each restore is a fresh copy from .gdh-state/backup/, so running restore
|
|
142
|
+
* twice produces the same final state.
|
|
143
|
+
*
|
|
144
|
+
* Path-traversal candidates in captured_paths are skipped with a structured
|
|
145
|
+
* warning (T-72-04-01); the rest of the restore still completes. If the
|
|
146
|
+
* backup content for an existed:true entry is missing on disk, that entry
|
|
147
|
+
* is skipped with reason "backup_content_missing" rather than aborting.
|
|
148
|
+
*/
|
|
149
|
+
export declare function restoreFromDurableBackup(input: {
|
|
150
|
+
readonly targetPath: string;
|
|
151
|
+
}): Promise<GdhRestoreFromDurableBackupResult>;
|
|
152
|
+
export interface GdhClass1MarkerDriftInput {
|
|
153
|
+
readonly targetPath: string;
|
|
154
|
+
/**
|
|
155
|
+
* Workspace-relative POSIX paths of class-1 (deterministic) managed files
|
|
156
|
+
* that the planned action set will re-render.
|
|
157
|
+
*/
|
|
158
|
+
readonly plannedClass1Paths: readonly string[];
|
|
159
|
+
/**
|
|
160
|
+
* Optional per-path expected markers. Overrides KNOWN_GDH_MARKERS for
|
|
161
|
+
* files whose format ships its own marker convention. Use for class-1
|
|
162
|
+
* file types not covered by the default list (rare).
|
|
163
|
+
*/
|
|
164
|
+
readonly expectedMarkersByPath?: ReadonlyMap<string, readonly string[]>;
|
|
165
|
+
}
|
|
166
|
+
export interface GdhClass1MarkerDriftEntry {
|
|
167
|
+
readonly path: string;
|
|
168
|
+
readonly markerState: GdhBackupMarkerState;
|
|
169
|
+
}
|
|
170
|
+
export interface GdhClass1MarkerDriftResult {
|
|
171
|
+
readonly driftedPaths: readonly GdhClass1MarkerDriftEntry[];
|
|
172
|
+
readonly absentPaths: readonly string[];
|
|
173
|
+
readonly skipped: readonly {
|
|
174
|
+
readonly path: string;
|
|
175
|
+
readonly reason: string;
|
|
176
|
+
}[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Detect WFL-02 / D-24 class-1 marker drift.
|
|
180
|
+
*
|
|
181
|
+
* For each `plannedClass1Paths` entry that exists on disk, check whether the
|
|
182
|
+
* file contains any of its expected GDH ownership markers:
|
|
183
|
+
* - Marker present → file is GDH-rendered; no drift; not flagged.
|
|
184
|
+
* - Marker absent (but file exists) → user-edited drift; flagged with
|
|
185
|
+
* marker_state: "absent".
|
|
186
|
+
* - Per-path override supplied but no marker matches → conservative
|
|
187
|
+
* marker_state: "not_applicable" + flagged as drifted (T-72-04-07: err on
|
|
188
|
+
* the side of preservation when the marker convention is uncertain).
|
|
189
|
+
* - File does not exist on disk → no drift; reported in absentPaths so
|
|
190
|
+
* the caller knows the file will be rendered fresh (no preservation).
|
|
191
|
+
*
|
|
192
|
+
* Path-traversal candidates (failing isWorkspaceRelativePath) are skipped
|
|
193
|
+
* with structured warnings (T-72-04-01); never read.
|
|
194
|
+
*
|
|
195
|
+
* Pair the result with `driftResultToPreservationNotes` to produce the
|
|
196
|
+
* preservation-notes payload for `writeDurableBackup`.
|
|
197
|
+
*/
|
|
198
|
+
export declare function detectClass1MarkerDrift(input: GdhClass1MarkerDriftInput): Promise<GdhClass1MarkerDriftResult>;
|
|
199
|
+
/**
|
|
200
|
+
* Convert a drift-detection result into preservation notes ready to attach
|
|
201
|
+
* to a `writeDurableBackup` call.
|
|
202
|
+
*
|
|
203
|
+
* Per D-24, every drifted path is preserved with reason
|
|
204
|
+
* `class_1_backup_then_overwrite`; the marker_state propagates from the
|
|
205
|
+
* drift entry so the manifest carries an audit trail of the detection
|
|
206
|
+
* outcome (absent vs not_applicable).
|
|
207
|
+
*/
|
|
208
|
+
export declare function driftResultToPreservationNotes(drift: GdhClass1MarkerDriftResult): readonly GdhBackupPreservationNote[];
|
|
209
|
+
//# sourceMappingURL=durable-backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-backup.d.ts","sourceRoot":"","sources":["../src/durable-backup.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,WAAW,CAAC;AAEnB;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AACpE,0DAA0D;AAC1D,eAAO,MAAM,6BAA6B,oCAAoC,CAAC;AAE/E,MAAM,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAE3E;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,2BAA2B,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;CAC7C;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cA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AC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAgCrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,0BAA0B,GAChC,SAAS,yBAAyB,EAAE,CAMtC"}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isWorkspaceRelativePath, writeFileAtomic, } from "@gdh/core";
|
|
4
|
+
/**
|
|
5
|
+
* Workspace-relative directory for the durable update backup.
|
|
6
|
+
*
|
|
7
|
+
* Single durable backup per STA-01 / D-14: this directory is overwritten
|
|
8
|
+
* (rm -rf semantics) on every successful backup write. Multi-backup retention
|
|
9
|
+
* is explicitly deferred (see 72-CONTEXT.md "Deferred Ideas").
|
|
10
|
+
*/
|
|
11
|
+
export const BACKUP_RELATIVE_PATH = ".gdh-state/backup";
|
|
12
|
+
/**
|
|
13
|
+
* Workspace-relative staging directory used to make the backup write atomic
|
|
14
|
+
* at the directory level (Pitfall 6 / T-72-04-03). The staged tree is built
|
|
15
|
+
* here, then renamed onto BACKUP_RELATIVE_PATH so the prior backup is never
|
|
16
|
+
* absent from disk between rm-rf and write.
|
|
17
|
+
*/
|
|
18
|
+
export const BACKUP_STAGING_RELATIVE_PATH = ".gdh-state/backup.new";
|
|
19
|
+
/** Workspace-relative path to the per-backup manifest. */
|
|
20
|
+
export const BACKUP_MANIFEST_RELATIVE_PATH = ".gdh-state/backup/manifest.json";
|
|
21
|
+
/**
|
|
22
|
+
* Write a single durable backup at .gdh-state/backup/ (STA-01 / D-13 / D-14).
|
|
23
|
+
*
|
|
24
|
+
* Staged-write strategy (T-72-04-03 mitigation, Pitfall 6):
|
|
25
|
+
* 1. Pre-clean .gdh-state/backup.new/ from any prior interrupted run.
|
|
26
|
+
* 2. Capture every plannedPaths entry into .gdh-state/backup.new/, mirroring
|
|
27
|
+
* the workspace-relative directory structure. Missing files are recorded
|
|
28
|
+
* in the manifest with existed: false but no file is written.
|
|
29
|
+
* 3. Write manifest.json into the staging directory via writeFileAtomic.
|
|
30
|
+
* 4. Remove the prior .gdh-state/backup/ (if any) and rename the staging
|
|
31
|
+
* directory onto it.
|
|
32
|
+
*
|
|
33
|
+
* If interrupted between steps 2 and 4, the prior .gdh-state/backup/ is
|
|
34
|
+
* unchanged and the next call's pre-clean (step 1) removes the partial
|
|
35
|
+
* staging tree before it can corrupt anything.
|
|
36
|
+
*
|
|
37
|
+
* Path-traversal candidates (failing isWorkspaceRelativePath) are recorded
|
|
38
|
+
* in `skipped` with `path_traversal_blocked` and never written or captured.
|
|
39
|
+
*/
|
|
40
|
+
export async function writeDurableBackup(input) {
|
|
41
|
+
if (input.plannedPaths.length === 0) {
|
|
42
|
+
return { state: "skipped_no_planned_paths" };
|
|
43
|
+
}
|
|
44
|
+
const stagingPath = path.join(input.targetPath, BACKUP_STAGING_RELATIVE_PATH);
|
|
45
|
+
const finalPath = path.join(input.targetPath, BACKUP_RELATIVE_PATH);
|
|
46
|
+
// Step 1: pre-clean staging from any prior interrupted run, then re-create it
|
|
47
|
+
await fs.rm(stagingPath, { recursive: true, force: true });
|
|
48
|
+
await fs.mkdir(stagingPath, { recursive: true });
|
|
49
|
+
// Step 2: capture each planned-path file into the staging tree
|
|
50
|
+
const capturedPaths = [];
|
|
51
|
+
const skipped = [];
|
|
52
|
+
// Deduplicate planned paths and sort for deterministic manifest ordering
|
|
53
|
+
const uniquePaths = [...new Set(input.plannedPaths)].sort();
|
|
54
|
+
for (const relPath of uniquePaths) {
|
|
55
|
+
if (!isWorkspaceRelativePath(relPath)) {
|
|
56
|
+
skipped.push({ path: relPath, reason: "path_traversal_blocked" });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const sourceAbs = path.join(input.targetPath, relPath);
|
|
60
|
+
const destAbs = path.join(stagingPath, relPath);
|
|
61
|
+
let content;
|
|
62
|
+
try {
|
|
63
|
+
content = await fs.readFile(sourceAbs, "utf8");
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
content = null;
|
|
67
|
+
}
|
|
68
|
+
if (content !== null) {
|
|
69
|
+
await fs.mkdir(path.dirname(destAbs), { recursive: true });
|
|
70
|
+
await fs.writeFile(destAbs, content);
|
|
71
|
+
capturedPaths.push({ path: relPath, existed: true });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
capturedPaths.push({ path: relPath, existed: false });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Step 3: write manifest into the staging directory
|
|
78
|
+
const nowIso = input.nowIso ?? (() => new Date().toISOString());
|
|
79
|
+
const manifest = {
|
|
80
|
+
backup_version: 1,
|
|
81
|
+
applied_at: nowIso(),
|
|
82
|
+
from_pair: input.fromPair,
|
|
83
|
+
to_pair: input.toPair,
|
|
84
|
+
from_pin: input.fromPin,
|
|
85
|
+
to_pin: input.toPin,
|
|
86
|
+
captured_paths: capturedPaths,
|
|
87
|
+
preservation_notes: input.preservationNotes ?? [],
|
|
88
|
+
};
|
|
89
|
+
await writeFileAtomic(path.join(stagingPath, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
90
|
+
// Step 4: remove the old backup, then rename staging into place. The rename
|
|
91
|
+
// is atomic on POSIX filesystems for directories on the same device, and
|
|
92
|
+
// .gdh-state/ is always on the same device as itself by construction.
|
|
93
|
+
await fs.rm(finalPath, { recursive: true, force: true });
|
|
94
|
+
await fs.rename(stagingPath, finalPath);
|
|
95
|
+
return {
|
|
96
|
+
state: "written",
|
|
97
|
+
backupPath: finalPath,
|
|
98
|
+
manifest,
|
|
99
|
+
skipped,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// Manifest read + restore (T-72-04-06 schema guard; D-10 step rollback)
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
function isBackupCapturedPath(value) {
|
|
106
|
+
if (typeof value !== "object" || value === null)
|
|
107
|
+
return false;
|
|
108
|
+
const v = value;
|
|
109
|
+
return typeof v["path"] === "string" && typeof v["existed"] === "boolean";
|
|
110
|
+
}
|
|
111
|
+
function isBackupPreservationNote(value) {
|
|
112
|
+
if (typeof value !== "object" || value === null)
|
|
113
|
+
return false;
|
|
114
|
+
const v = value;
|
|
115
|
+
if (typeof v["path"] !== "string")
|
|
116
|
+
return false;
|
|
117
|
+
if (v["reason"] !== "class_1_backup_then_overwrite")
|
|
118
|
+
return false;
|
|
119
|
+
const ms = v["marker_state"];
|
|
120
|
+
return ms === "absent" || ms === "present" || ms === "not_applicable";
|
|
121
|
+
}
|
|
122
|
+
function isMigrationVersionPair(value) {
|
|
123
|
+
if (typeof value !== "object" || value === null)
|
|
124
|
+
return false;
|
|
125
|
+
const v = value;
|
|
126
|
+
return (typeof v["schema"] === "number" && typeof v["agentContract"] === "number");
|
|
127
|
+
}
|
|
128
|
+
function isBackupManifest(value) {
|
|
129
|
+
if (typeof value !== "object" || value === null)
|
|
130
|
+
return false;
|
|
131
|
+
const v = value;
|
|
132
|
+
if (v["backup_version"] !== 1)
|
|
133
|
+
return false;
|
|
134
|
+
if (typeof v["applied_at"] !== "string")
|
|
135
|
+
return false;
|
|
136
|
+
if (typeof v["from_pin"] !== "string")
|
|
137
|
+
return false;
|
|
138
|
+
if (typeof v["to_pin"] !== "string")
|
|
139
|
+
return false;
|
|
140
|
+
if (!isMigrationVersionPair(v["from_pair"]))
|
|
141
|
+
return false;
|
|
142
|
+
if (!isMigrationVersionPair(v["to_pair"]))
|
|
143
|
+
return false;
|
|
144
|
+
const captured = v["captured_paths"];
|
|
145
|
+
if (!Array.isArray(captured) || !captured.every(isBackupCapturedPath)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
const notes = v["preservation_notes"];
|
|
149
|
+
if (!Array.isArray(notes) || !notes.every(isBackupPreservationNote)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Read the backup manifest from .gdh-state/backup/manifest.json.
|
|
156
|
+
*
|
|
157
|
+
* Returns null on any failure (missing file, JSON parse error, schema
|
|
158
|
+
* mismatch). Never throws — degraded fallback so callers can branch on
|
|
159
|
+
* "no backup present" without try/catch ceremony, and so a corrupted
|
|
160
|
+
* manifest cannot trigger a partial restore (T-72-04-06).
|
|
161
|
+
*/
|
|
162
|
+
export async function readBackupManifest(targetPath) {
|
|
163
|
+
const manifestPath = path.join(targetPath, BACKUP_MANIFEST_RELATIVE_PATH);
|
|
164
|
+
const raw = await fs.readFile(manifestPath, "utf8").catch(() => null);
|
|
165
|
+
if (raw === null)
|
|
166
|
+
return null;
|
|
167
|
+
let parsed;
|
|
168
|
+
try {
|
|
169
|
+
parsed = JSON.parse(raw);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return isBackupManifest(parsed) ? parsed : null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Restore byte-equal content for every captured_paths entry in the backup
|
|
178
|
+
* manifest. Mirrors the legacy in-memory rollbackOriginals semantics:
|
|
179
|
+
*
|
|
180
|
+
* - existed: true → atomic-write the backup content over the original path
|
|
181
|
+
* - existed: false → fs.rm the original path (file did not exist pre-update)
|
|
182
|
+
*
|
|
183
|
+
* The backup directory itself is read-only during restore (T-72-04 contract):
|
|
184
|
+
* each restore is a fresh copy from .gdh-state/backup/, so running restore
|
|
185
|
+
* twice produces the same final state.
|
|
186
|
+
*
|
|
187
|
+
* Path-traversal candidates in captured_paths are skipped with a structured
|
|
188
|
+
* warning (T-72-04-01); the rest of the restore still completes. If the
|
|
189
|
+
* backup content for an existed:true entry is missing on disk, that entry
|
|
190
|
+
* is skipped with reason "backup_content_missing" rather than aborting.
|
|
191
|
+
*/
|
|
192
|
+
export async function restoreFromDurableBackup(input) {
|
|
193
|
+
const manifest = await readBackupManifest(input.targetPath);
|
|
194
|
+
if (manifest === null) {
|
|
195
|
+
return { state: "no_backup_present" };
|
|
196
|
+
}
|
|
197
|
+
const backupRoot = path.join(input.targetPath, BACKUP_RELATIVE_PATH);
|
|
198
|
+
const restored = [];
|
|
199
|
+
const removed = [];
|
|
200
|
+
const skipped = [];
|
|
201
|
+
for (const entry of manifest.captured_paths) {
|
|
202
|
+
if (!isWorkspaceRelativePath(entry.path)) {
|
|
203
|
+
skipped.push({ path: entry.path, reason: "path_traversal_blocked" });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const originalAbs = path.join(input.targetPath, entry.path);
|
|
207
|
+
if (entry.existed) {
|
|
208
|
+
const backupAbs = path.join(backupRoot, entry.path);
|
|
209
|
+
const content = await fs.readFile(backupAbs, "utf8").catch(() => null);
|
|
210
|
+
if (content === null) {
|
|
211
|
+
skipped.push({ path: entry.path, reason: "backup_content_missing" });
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
await writeFileAtomic(originalAbs, content);
|
|
216
|
+
restored.push(entry.path);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
// Best-effort restore: a destination-collision (e.g. directory at the
|
|
220
|
+
// expected file path, EACCES, EROFS) becomes a skipped entry rather
|
|
221
|
+
// than aborting the rest of the restore. Mirrors legacy
|
|
222
|
+
// rollbackOriginals semantics — partial recovery is preferable to
|
|
223
|
+
// halting mid-rollback. T-72-04-04 (single-backup contract) is
|
|
224
|
+
// unchanged; this only widens which failure modes degrade gracefully.
|
|
225
|
+
skipped.push({
|
|
226
|
+
path: entry.path,
|
|
227
|
+
reason: `restore_failed:${error instanceof Error ? error.message : String(error)}`,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
try {
|
|
233
|
+
await fs.rm(originalAbs, { force: true });
|
|
234
|
+
removed.push(entry.path);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
// Same best-effort posture: fs.rm without recursive on a directory
|
|
238
|
+
// throws EISDIR; recursive removal of an unexpected directory at a
|
|
239
|
+
// file path is destructive (could surprise an operator who created
|
|
240
|
+
// the directory deliberately). Skip with a structured reason.
|
|
241
|
+
skipped.push({
|
|
242
|
+
path: entry.path,
|
|
243
|
+
reason: `remove_failed:${error instanceof Error ? error.message : String(error)}`,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
state: "restored",
|
|
250
|
+
restored,
|
|
251
|
+
removed,
|
|
252
|
+
skipped,
|
|
253
|
+
// WR-06: surface aggregate restore failure as a typed scalar so callers
|
|
254
|
+
// can branch on actual restoration success without re-scanning `skipped`.
|
|
255
|
+
failedCount: skipped.length,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
// ---------------------------------------------------------------------------
|
|
259
|
+
// WFL-02 / D-24 — class-1 marker-drift detection
|
|
260
|
+
// ---------------------------------------------------------------------------
|
|
261
|
+
/**
|
|
262
|
+
* Known GDH ownership markers (per 72-RESEARCH.md "Established Patterns").
|
|
263
|
+
*
|
|
264
|
+
* Each class-1 file format ships at least one of these markers in its
|
|
265
|
+
* GDH-rendered output. The first match in a file proves "GDH-rendered,
|
|
266
|
+
* untouched" — no preservation needed. Absence of every marker (when the
|
|
267
|
+
* file otherwise exists at a class-1 path) proves user-edited drift and
|
|
268
|
+
* triggers WFL-02 backup-then-overwrite.
|
|
269
|
+
*
|
|
270
|
+
* Adding a new marker convention requires updating both this list AND the
|
|
271
|
+
* renderer that ships it; tests in `detectClass1MarkerDrift` cover each
|
|
272
|
+
* marker variant explicitly.
|
|
273
|
+
*/
|
|
274
|
+
const KNOWN_GDH_MARKERS = [
|
|
275
|
+
"<codex_skill_adapter>",
|
|
276
|
+
"<!-- gdh managed -->",
|
|
277
|
+
"# gdh:managed-hook",
|
|
278
|
+
"<!-- GDH-MANAGED -->",
|
|
279
|
+
];
|
|
280
|
+
/**
|
|
281
|
+
* Detect WFL-02 / D-24 class-1 marker drift.
|
|
282
|
+
*
|
|
283
|
+
* For each `plannedClass1Paths` entry that exists on disk, check whether the
|
|
284
|
+
* file contains any of its expected GDH ownership markers:
|
|
285
|
+
* - Marker present → file is GDH-rendered; no drift; not flagged.
|
|
286
|
+
* - Marker absent (but file exists) → user-edited drift; flagged with
|
|
287
|
+
* marker_state: "absent".
|
|
288
|
+
* - Per-path override supplied but no marker matches → conservative
|
|
289
|
+
* marker_state: "not_applicable" + flagged as drifted (T-72-04-07: err on
|
|
290
|
+
* the side of preservation when the marker convention is uncertain).
|
|
291
|
+
* - File does not exist on disk → no drift; reported in absentPaths so
|
|
292
|
+
* the caller knows the file will be rendered fresh (no preservation).
|
|
293
|
+
*
|
|
294
|
+
* Path-traversal candidates (failing isWorkspaceRelativePath) are skipped
|
|
295
|
+
* with structured warnings (T-72-04-01); never read.
|
|
296
|
+
*
|
|
297
|
+
* Pair the result with `driftResultToPreservationNotes` to produce the
|
|
298
|
+
* preservation-notes payload for `writeDurableBackup`.
|
|
299
|
+
*/
|
|
300
|
+
export async function detectClass1MarkerDrift(input) {
|
|
301
|
+
const drifted = [];
|
|
302
|
+
const absent = [];
|
|
303
|
+
const skipped = [];
|
|
304
|
+
for (const relPath of input.plannedClass1Paths) {
|
|
305
|
+
if (!isWorkspaceRelativePath(relPath)) {
|
|
306
|
+
skipped.push({ path: relPath, reason: "path_traversal_blocked" });
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const absolute = path.join(input.targetPath, relPath);
|
|
310
|
+
const content = await fs.readFile(absolute, "utf8").catch(() => null);
|
|
311
|
+
if (content === null) {
|
|
312
|
+
absent.push(relPath);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const customMarkers = input.expectedMarkersByPath?.get(relPath);
|
|
316
|
+
const markersToCheck = customMarkers ?? KNOWN_GDH_MARKERS;
|
|
317
|
+
const hasMarker = markersToCheck.some((marker) => content.includes(marker));
|
|
318
|
+
if (hasMarker) {
|
|
319
|
+
// file is GDH-rendered, no drift
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
// marker absent — flag as drifted. When a custom marker list was supplied
|
|
323
|
+
// but none matched, the marker convention is uncertain → use the
|
|
324
|
+
// conservative "not_applicable" state per T-72-04-07.
|
|
325
|
+
const markerState = customMarkers !== undefined ? "not_applicable" : "absent";
|
|
326
|
+
drifted.push({ path: relPath, markerState });
|
|
327
|
+
}
|
|
328
|
+
return { driftedPaths: drifted, absentPaths: absent, skipped };
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Convert a drift-detection result into preservation notes ready to attach
|
|
332
|
+
* to a `writeDurableBackup` call.
|
|
333
|
+
*
|
|
334
|
+
* Per D-24, every drifted path is preserved with reason
|
|
335
|
+
* `class_1_backup_then_overwrite`; the marker_state propagates from the
|
|
336
|
+
* drift entry so the manifest carries an audit trail of the detection
|
|
337
|
+
* outcome (absent vs not_applicable).
|
|
338
|
+
*/
|
|
339
|
+
export function driftResultToPreservationNotes(drift) {
|
|
340
|
+
return drift.driftedPaths.map((entry) => ({
|
|
341
|
+
path: entry.path,
|
|
342
|
+
reason: "class_1_backup_then_overwrite",
|
|
343
|
+
marker_state: entry.markerState,
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
//# sourceMappingURL=durable-backup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-backup.js","sourceRoot":"","sources":["../src/durable-backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,uBAAuB,EACvB,eAAe,GAEhB,MAAM,WAAW,CAAC;AAEnB;;;;;;GAMG;AACH,MAAM,CA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,MAAM,EAAE,OAAO,EAAE,CAAC;AACjE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAiC;IAEjC,OAAO,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,+BAAwC;QAChD,YAAY,EAAE,KAAK,CAAC,WAAW;KAChC,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GdhAgentAdaptersInstallResult, type GdhAgentAdaptersStatusResult, type GdhGsdSnapshot, type GdhProjectLifecycleCompatibilityResult, type GdhProjectLifecycleSurfaceStatus, type GdhStatusResult, type GdhSupportedAgent } from "@gdh/core";
|
|
2
|
+
import { type GdhStatusBuildAdapters } from "./deferred-actions-advisory.js";
|
|
2
3
|
export { GDH_MANAGED_AGENT_SKILL_MARKER, GDH_SKILL_DEFINITIONS, GDH_SKILL_IDS, renderGdhSkill, renderManagedSkillMarker, renderClaudeCheckSkill, renderClaudeMigrateSkill, renderClaudeOnboardSkill, renderClaudePrepareSkill, renderClaudeRunGameSkill, renderClaudeScanSkill, renderClaudeStatusSkill, renderClaudeUpdateSkill, renderCodexCheckSkill, renderCodexMigrateSkill, renderCodexOnboardSkill, renderCodexPrepareSkill, renderCodexRunGameSkill, renderCodexScanSkill, renderCodexStatusSkill, renderCodexUpdateSkill, renderCursorCheckSkill, renderCursorMigrateSkill, renderCursorOnboardSkill, renderCursorPrepareSkill, renderCursorRunGameSkill, renderCursorScanSkill, renderCursorStatusSkill, renderCursorUpdateSkill, } from "./skill-rendering.js";
|
|
3
4
|
export declare const adaptersPackage: import("@gdh/core").GdhPackageBoundary;
|
|
4
5
|
export declare const SUPPORTED_AGENTS: readonly ["codex", "claude", "cursor"];
|
|
@@ -54,7 +55,7 @@ export declare function installSupportedAgentAdapters(targetPath: string, option
|
|
|
54
55
|
readonly allowBootstrap?: boolean;
|
|
55
56
|
}): Promise<GdhAgentAdaptersInstallResult>;
|
|
56
57
|
export declare function inspectProjectLifecycleCompatibility(targetPath: string): Promise<GdhProjectLifecycleCompatibilityResult>;
|
|
57
|
-
export declare function buildGdhStatusResult(targetPath: string): Promise<GdhStatusResult>;
|
|
58
|
+
export declare function buildGdhStatusResult(targetPath: string, adapters?: GdhStatusBuildAdapters): Promise<GdhStatusResult>;
|
|
58
59
|
export declare function createGsdSnapshot(targetPath: string, options?: {
|
|
59
60
|
readonly files?: readonly string[];
|
|
60
61
|
}): Promise<GdhGsdSnapshot>;
|
|
@@ -74,5 +75,13 @@ export { CLAUDE_STATUSLINE_RELATIVE_PATH } from "./claude-statusline-render.js";
|
|
|
74
75
|
export { CLAUDE_CHECK_UPDATE_HOOK_RELATIVE_PATH } from "./claude-update-hook-render.js";
|
|
75
76
|
export { CLAUDE_AUTHORING_HOOK_COMMAND, CLAUDE_AUTHORING_HOOK_RELATIVE_PATH, CODEX_AUTHORING_HOOK_COMMAND, CODEX_AUTHORING_HOOK_RELATIVE_PATH, } from "./authoring-hook-render.js";
|
|
76
77
|
export { type BumpAndRebakePinResult, bumpAndRebakePin, } from "./self-update-mechanics.js";
|
|
78
|
+
export { deriveExpectedRenderSet, runInventorySweep, } from "./inventory-sweep.js";
|
|
79
|
+
export type { GdhInventorySweepInput, GdhInventorySweepResult, GdhInventorySweepSkipped, } from "./inventory-sweep.js";
|
|
80
|
+
export { BACKUP_MANIFEST_RELATIVE_PATH, BACKUP_RELATIVE_PATH, BACKUP_STAGING_RELATIVE_PATH, detectClass1MarkerDrift, driftResultToPreservationNotes, readBackupManifest, restoreFromDurableBackup, writeDurableBackup, } from "./durable-backup.js";
|
|
81
|
+
export type { GdhBackupCapturedPath, GdhBackupManifest, GdhBackupMarkerState, GdhBackupPreservationNote, GdhBackupPreservationReason, GdhClass1MarkerDriftEntry, GdhClass1MarkerDriftInput, GdhClass1MarkerDriftResult, GdhRestoreFromDurableBackupResult, GdhWriteDurableBackupInput, GdhWriteDurableBackupResult, GdhWriteDurableBackupSkipped, } from "./durable-backup.js";
|
|
82
|
+
export { computeDeferredActionsAdvisory, } from "./deferred-actions-advisory.js";
|
|
83
|
+
export type { GdhBackupAdvisory, GdhDeferredActionStatusEntry, GdhDeferredActionsAdvisoryResult, GdhStatusBuildAdapters, } from "./deferred-actions-advisory.js";
|
|
84
|
+
export { DEFAULT_GRACEFUL_STOP_TIMEOUT_MS, STOP_AND_RESTART_ENV_SUBSET_KEYS, buildProcessRestartProbeFromSnapshot, captureProcessSnapshot, defaultProcessOrchestrationEnvironment, restartFromSnapshot, stopCapturedProcesses, } from "./process-orchestration.js";
|
|
85
|
+
export type { GdhCaptureProcessSnapshotResult, GdhDiscoveredBrokerProcess, GdhDiscoveredMcpProcess, GdhProcessOrchestrationEnvironment, GdhProcessOrchestrationPlatform, GdhRestartFailedRow, GdhRestartFromSnapshotResult, GdhRestartedRow, GdhStopCapturedProcessesResult, GdhStopCapturedProcessesSkipped, } from "./process-orchestration.js";
|
|
77
86
|
export { summarizeProjectLifecycleCompatibility };
|
|
78
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAeL,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,cAAc,EAInB,KAAK,sCAAsC,EAE3C,KAAK,gCAAgC,EAKrC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAIvB,MAAM,WAAW,CAAC;AAuBnB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,gCAAgC,CAAC;AA4CxC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,wBAAwB,EAC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