@gmickel/gno 1.31.0 → 1.32.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.
Files changed (53) hide show
  1. package/README.md +5 -4
  2. package/assets/skill/SKILL.md +23 -0
  3. package/browser-extension/artifacts/{gno-browser-clipper-v1.31.0.zip → gno-browser-clipper-v1.32.0.zip} +0 -0
  4. package/browser-extension/artifacts/gno-browser-clipper-v1.32.0.zip.sha256 +1 -0
  5. package/browser-extension/dist/manifest.json +1 -1
  6. package/package.json +1 -1
  7. package/spec/cli.md +19 -0
  8. package/spec/db/schema.sql +55 -0
  9. package/spec/mcp.md +114 -11
  10. package/spec/output-schemas/file-refactor-apply-result.schema.json +305 -0
  11. package/spec/output-schemas/file-refactor-preview.schema.json +393 -0
  12. package/src/core/document-capabilities.ts +13 -0
  13. package/src/core/file-ops.ts +129 -1
  14. package/src/core/file-refactor-adapter.ts +329 -0
  15. package/src/core/file-refactor-apply-edits.ts +61 -0
  16. package/src/core/file-refactor-apply-fs.ts +512 -0
  17. package/src/core/file-refactor-apply-safety.ts +340 -0
  18. package/src/core/file-refactor-apply-validate.ts +401 -0
  19. package/src/core/file-refactor-contract.ts +486 -0
  20. package/src/core/file-refactor-destination.ts +123 -0
  21. package/src/core/file-refactor-from-snapshot.ts +148 -0
  22. package/src/core/file-refactor-journal-port.ts +150 -0
  23. package/src/core/file-refactor-journal.ts +347 -0
  24. package/src/core/file-refactor-paths.ts +60 -0
  25. package/src/core/file-refactor-plan-classify.ts +208 -0
  26. package/src/core/file-refactor-plan-validate.ts +169 -0
  27. package/src/core/file-refactor-planner-types.ts +62 -0
  28. package/src/core/file-refactor-planner.ts +423 -0
  29. package/src/core/file-refactor-resolve.ts +280 -0
  30. package/src/core/file-refactor-service.ts +468 -0
  31. package/src/core/file-refactors.ts +84 -56
  32. package/src/core/link-destination-parse.ts +275 -0
  33. package/src/core/link-inventory-markdown.ts +454 -0
  34. package/src/core/link-inventory-opaque.ts +244 -0
  35. package/src/core/link-inventory-types.ts +47 -0
  36. package/src/core/link-inventory.ts +182 -0
  37. package/src/core/link-relevance.ts +150 -0
  38. package/src/mcp/tools/index.ts +18 -17
  39. package/src/mcp/tools/workspace-write.ts +215 -97
  40. package/src/sdk/client.ts +167 -115
  41. package/src/sdk/index.ts +7 -0
  42. package/src/sdk/types.ts +32 -2
  43. package/src/serve/file-refactor-http.ts +239 -0
  44. package/src/serve/public/components/RefactorImpactPreview.tsx +227 -0
  45. package/src/serve/public/globals.built.css +1 -1
  46. package/src/serve/public/pages/DocView.tsx +176 -41
  47. package/src/serve/routes/api.ts +191 -104
  48. package/src/store/migrations/026-file-refactor-recovery-journal.ts +72 -0
  49. package/src/store/migrations/index.ts +2 -0
  50. package/src/store/sqlite/adapter.ts +452 -0
  51. package/src/store/sqlite/file-refactor-journal-store.ts +275 -0
  52. package/src/store/types.ts +84 -0
  53. package/browser-extension/artifacts/gno-browser-clipper-v1.31.0.zip.sha256 +0 -1
package/README.md CHANGED
@@ -117,7 +117,7 @@ gno daemon --detach # headless indexing + resident MCP gateway
117
117
 
118
118
  <!-- public-truth:current-version -->
119
119
 
120
- > Current release: **v1.31.0** — see [CHANGELOG.md](./CHANGELOG.md)
120
+ > Current release: **v1.32.0** — see [CHANGELOG.md](./CHANGELOG.md)
121
121
 
122
122
  <!-- /public-truth -->
123
123
 
@@ -694,7 +694,7 @@ Open `http://localhost:3000` to:
694
694
  configured MCP retrieval without changing client config. Skill installation
695
695
  is visible, but client runtime execution cannot be proven automatically
696
696
  - **Manage files safely**: Rename, reveal, or move editable files to Trash with explicit index-vs-disk semantics
697
- - **Refactor files safely**: Move, duplicate, and organize editable notes with reference warnings
697
+ - **Refactor files safely**: Preview and atomically rename or move editable notes while GNO rewrites supported wiki and Markdown references; stale or unsafe plans fail closed
698
698
  - **Switch presets**: Change models live without restart
699
699
  - **Command palette**: Jump, create, refactor, and section-navigate from one keyboard-first surface
700
700
 
@@ -863,9 +863,10 @@ curl http://localhost:3000/api/health
863
863
  | `/api/docs` | GET | List documents |
864
864
  | `/api/docs` | POST | Create document |
865
865
  | `/api/docs/:id` | PUT | Update document content |
866
- | `/api/docs/:id/move` | POST | Move editable document |
866
+ | `/api/docs/:id/rename` | POST | Apply confirmed safe rename |
867
+ | `/api/docs/:id/move` | POST | Apply confirmed safe move |
867
868
  | `/api/docs/:id/duplicate` | POST | Duplicate editable document |
868
- | `/api/docs/:id/refactor-plan` | POST | Preview file-op warnings |
869
+ | `/api/docs/:id/refactor-plan` | POST | Preview reference-safe plan |
869
870
  | `/api/docs/:id/deactivate` | POST | Remove from index |
870
871
  | `/api/doc` | GET | Get document content |
871
872
  | `/api/doc/:id/sections` | GET | Get document sections |
@@ -499,6 +499,29 @@ search must include the new note. Browser provenance fields are
499
499
  `extractionHash`, `finalBodyHash`, `clipIdentity`, and `previewDigest`—do not
500
500
  invent `sourceHash`.
501
501
 
502
+ ## Reference-Safe Rename and Move
503
+
504
+ When MCP writes are enabled and the user asks to rename or move an editable
505
+ note, always use the operation-specific two-step tool. Never invent a digest or
506
+ collapse preview and apply into one call.
507
+
508
+ 1. Call `gno_rename_note` or `gno_move_note` with `action: "preview"` and the
509
+ exact source/destination.
510
+ 2. Inspect `canApply`, `safety.blockingReasons`, and `examinedReferences`.
511
+ Stop and report ambiguous, malformed, unsupported, read-only, occupied,
512
+ cross-collection, or truncated plans.
513
+ 3. Only after explicit user approval, call the same tool with `action: "apply"`,
514
+ the preview's exact `schemaVersion` and `planDigest`, `confirmation: "apply"`,
515
+ and `confirm: true`.
516
+ 4. Treat `applied_with_sync_pending` as a committed filesystem refactor whose
517
+ index still needs `gno_sync` or `gno_index`; do not retry the file mutation.
518
+ For `stale_plan`, preview again instead of reusing the old digest.
519
+
520
+ Supported wiki and Markdown destinations are rewritten in the same
521
+ all-or-rollback filesystem transaction as the source move. Duplicate and
522
+ create-folder do not retarget inbound references. Authentication alone never
523
+ enables these MCP writes.
524
+
502
525
  ## Collection-specific embedding models
503
526
 
504
527
  Collections can override the global embedding model with `models.embed`.
@@ -0,0 +1 @@
1
+ cb5c4bba8cf1252da4e4fc89f1dc01a8df306851cccb50f636d89a6ef3133cff gno-browser-clipper-v1.32.0.zip
@@ -21,5 +21,5 @@
21
21
  "content_security_policy": {
22
22
  "extension_pages": "script-src 'self'; object-src 'none'; connect-src http://127.0.0.1:*"
23
23
  },
24
- "version": "1.31.0"
24
+ "version": "1.32.0"
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmickel/gno",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "Local semantic search for your documents. Index Markdown, PDF, and Office files with hybrid BM25 + vector search.",
5
5
  "keywords": [
6
6
  "embeddings",
package/spec/cli.md CHANGED
@@ -3448,6 +3448,25 @@ Error codes match exit codes: `VALIDATION` (exit 1), `RUNTIME` (exit 2), `NOT_RU
3448
3448
 
3449
3449
  ---
3450
3450
 
3451
+ ## Workspace file refactors (non-CLI)
3452
+
3453
+ Reference-safe note rename and same-collection move use a transport-neutral
3454
+ preview/apply contract defined in `src/core/file-refactors.ts` and frozen as:
3455
+
3456
+ - `gno://schemas/file-refactor-preview@1.0`
3457
+ - `gno://schemas/file-refactor-apply-result@1.0`
3458
+
3459
+ Surfaces that adapt the contract are REST/Web UI, SDK, and write-gated MCP
3460
+ (`gno_rename_note`, `gno_move_note`). This specification intentionally does
3461
+ **not** add a CLI command family or generic action bus for refactors.
3462
+ Duplicate-note and create-folder keep their existing shipped semantics and do
3463
+ not retarget inbound references.
3464
+
3465
+ The contract separates durable filesystem commit/rollback from post-commit
3466
+ index convergence. A successful filesystem refactor is never rolled back solely
3467
+ because reindexing is temporarily unavailable
3468
+ (`applied_with_sync_pending`).
3469
+
3451
3470
  ## See Also
3452
3471
 
3453
3472
  - [MCP Specification](./mcp.md)
@@ -21,6 +21,7 @@
21
21
  -- retrieval_trace_exports/export_traces - Export manifests and trace joins
22
22
  -- document_changes - Bounded metadata-only document lifecycle journal
23
23
  -- document_change_journal_state - Monotonic cursor/retention boundary
24
+ -- file_refactor_recovery_journal - Content-free rename/move recovery receipts
24
25
 
25
26
  -- ─────────────────────────────────────────────────────────────────────────────
26
27
  -- Schema Metadata
@@ -742,3 +743,57 @@ CREATE TABLE IF NOT EXISTS clipper_capture_idempotency (
742
743
 
743
744
  CREATE INDEX IF NOT EXISTS idx_clipper_idempotency_created
744
745
  ON clipper_capture_idempotency(created_at_ms, grant_id, key_hash);
746
+
747
+ -- ─────────────────────────────────────────────────────────────────────────────
748
+ -- File refactor recovery journal (content-free)
749
+ -- ─────────────────────────────────────────────────────────────────────────────
750
+
751
+ -- Durable receipts for multi-file rename/move apply. Stores IDs, digests,
752
+ -- collection/relpaths, phase/state, timestamps, and fingerprints/status only.
753
+ -- Never stores note bodies or replacement content.
754
+ -- Bounded: create prunes oldest terminal receipts (converged/rolled_back/aborted)
755
+ -- under FILE_REFACTOR_JOURNAL_MAX_RECEIPTS; never prunes recovery_required.
756
+
757
+ CREATE TABLE IF NOT EXISTS file_refactor_recovery_journal (
758
+ journal_id TEXT PRIMARY KEY,
759
+ plan_digest TEXT NOT NULL,
760
+ collection TEXT NOT NULL,
761
+ operation TEXT NOT NULL
762
+ CHECK (operation IN ('rename', 'move')),
763
+ source_rel_path TEXT NOT NULL,
764
+ target_rel_path TEXT NOT NULL,
765
+ phase TEXT NOT NULL
766
+ CHECK (phase IN (
767
+ 'prepared', 'staging', 'committing', 'committed', 'sync_pending',
768
+ 'converged', 'rolling_back', 'rolled_back', 'recovery_required',
769
+ 'aborted'
770
+ )),
771
+ phase_ordinal INTEGER NOT NULL CHECK (phase_ordinal >= 0),
772
+ filesystem_state TEXT NOT NULL
773
+ CHECK (filesystem_state IN (
774
+ 'unchanged', 'committed', 'rolled_back', 'recovery_required'
775
+ )),
776
+ index_state TEXT NOT NULL
777
+ CHECK (index_state IN (
778
+ 'not_attempted', 'pending', 'converged', 'skipped'
779
+ )),
780
+ file_entries_json TEXT NOT NULL
781
+ CHECK (length(CAST(file_entries_json AS BLOB)) <= 65536),
782
+ created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
783
+ updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
784
+ CHECK (length(CAST(journal_id AS BLOB)) BETWEEN 1 AND 128),
785
+ CHECK (
786
+ length(plan_digest) = 64
787
+ AND plan_digest NOT GLOB '*[^0-9a-f]*'
788
+ ),
789
+ CHECK (length(CAST(collection AS BLOB)) BETWEEN 1 AND 256),
790
+ CHECK (length(CAST(source_rel_path AS BLOB)) BETWEEN 1 AND 4096),
791
+ CHECK (length(CAST(target_rel_path AS BLOB)) BETWEEN 1 AND 4096),
792
+ CHECK (updated_at_ms >= created_at_ms)
793
+ );
794
+
795
+ CREATE INDEX IF NOT EXISTS idx_file_refactor_journal_plan_digest
796
+ ON file_refactor_recovery_journal(plan_digest, updated_at_ms DESC, journal_id DESC);
797
+
798
+ CREATE INDEX IF NOT EXISTS idx_file_refactor_journal_collection
799
+ ON file_refactor_recovery_journal(collection, updated_at_ms DESC);
package/spec/mcp.md CHANGED
@@ -1798,39 +1798,140 @@ Create a folder inside an existing collection (write-enabled).
1798
1798
 
1799
1799
  Rename an editable note in place (write-enabled).
1800
1800
 
1801
+ Same-collection rename is covered by the transport-neutral reference-safe
1802
+ refactor contract (`src/core/file-refactors.ts`). Preview and apply share one
1803
+ versioned schema pair across MCP, REST/SDK, and UI adapters:
1804
+
1805
+ - Preview plan: `gno://schemas/file-refactor-preview@1.0`
1806
+ - Apply result: `gno://schemas/file-refactor-apply-result@1.0`
1807
+
1808
+ The preview enumerates examined wiki/Markdown references with classifications
1809
+ and stable reason codes, destination-only edit spans, precondition fingerprints,
1810
+ a deterministic `planDigest`, safety summary, and `canApply`. Apply requires the
1811
+ exact `planDigest`, confirmation token `apply`, `confirm: true`, and
1812
+ `schemaVersion: "1.0"`. Apply never silently preview-and-confirms. Terminal
1813
+ statuses are `applied`, `applied_with_sync_pending`, `conflict`, `stale_plan`,
1814
+ `unsupported`, and `failed_rolled_back`.
1815
+
1816
+ Filesystem commit (moved note + accepted reference rewrites) is an atomic
1817
+ all-or-rollback boundary. Index/link convergence runs only after a durable
1818
+ filesystem commit and is **not** the same transaction; reindex failure returns
1819
+ `applied_with_sync_pending` without rolling back committed files.
1820
+
1821
+ MCP annotations remain hints, not authorization. Write gating (`--enable-write`)
1822
+ and destructive confirmation (`confirm: true` + `confirmation: "apply"`) still
1823
+ apply. No generic action-bus tool is introduced.
1824
+
1801
1825
  **Input Schema:**
1802
1826
 
1803
1827
  ```json
1804
1828
  {
1805
1829
  "type": "object",
1806
- "properties": {
1807
- "ref": { "type": "string" },
1808
- "name": { "type": "string" }
1809
- },
1810
- "required": ["ref", "name"]
1830
+ "oneOf": [
1831
+ {
1832
+ "properties": {
1833
+ "action": { "const": "preview" },
1834
+ "ref": { "type": "string" },
1835
+ "name": { "type": "string" }
1836
+ },
1837
+ "required": ["action", "ref", "name"],
1838
+ "additionalProperties": false
1839
+ },
1840
+ {
1841
+ "properties": {
1842
+ "action": { "const": "apply" },
1843
+ "ref": { "type": "string" },
1844
+ "name": { "type": "string" },
1845
+ "schemaVersion": { "const": "1.0" },
1846
+ "planDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
1847
+ "confirmation": { "const": "apply" },
1848
+ "confirm": { "const": true }
1849
+ },
1850
+ "required": [
1851
+ "action",
1852
+ "ref",
1853
+ "name",
1854
+ "schemaVersion",
1855
+ "planDigest",
1856
+ "confirmation",
1857
+ "confirm"
1858
+ ],
1859
+ "additionalProperties": false
1860
+ }
1861
+ ]
1811
1862
  }
1812
1863
  ```
1813
1864
 
1865
+ **Output Schema:**
1866
+
1867
+ - `action=preview` → `gno://schemas/file-refactor-preview@1.0` (content-free plan)
1868
+ - `action=apply` → `gno://schemas/file-refactor-apply-result@1.0` (content-free receipt)
1869
+
1870
+ Missing or incorrect apply confirmation fails before mutation.
1871
+
1814
1872
  ---
1815
1873
 
1816
1874
  ### gno_move_note
1817
1875
 
1818
1876
  Move an editable note to another folder in the same collection (write-enabled).
1819
1877
 
1878
+ Cross-collection moves are out of scope and fail closed with
1879
+ `cross_collection_unsupported`. Preview/apply semantics, destination-only edit
1880
+ spans, stale-plan protection, and the filesystem-vs-index mutation boundary match
1881
+ `gno_rename_note` and use the same schemas:
1882
+
1883
+ - Preview plan: `gno://schemas/file-refactor-preview@1.0`
1884
+ - Apply result: `gno://schemas/file-refactor-apply-result@1.0`
1885
+
1820
1886
  **Input Schema:**
1821
1887
 
1822
1888
  ```json
1823
1889
  {
1824
1890
  "type": "object",
1825
- "properties": {
1826
- "ref": { "type": "string" },
1827
- "folderPath": { "type": "string" },
1828
- "name": { "type": "string" }
1829
- },
1830
- "required": ["ref", "folderPath"]
1891
+ "oneOf": [
1892
+ {
1893
+ "properties": {
1894
+ "action": { "const": "preview" },
1895
+ "ref": { "type": "string" },
1896
+ "folderPath": { "type": "string" },
1897
+ "name": { "type": "string" }
1898
+ },
1899
+ "required": ["action", "ref", "folderPath"],
1900
+ "additionalProperties": false
1901
+ },
1902
+ {
1903
+ "properties": {
1904
+ "action": { "const": "apply" },
1905
+ "ref": { "type": "string" },
1906
+ "folderPath": { "type": "string" },
1907
+ "name": { "type": "string" },
1908
+ "schemaVersion": { "const": "1.0" },
1909
+ "planDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
1910
+ "confirmation": { "const": "apply" },
1911
+ "confirm": { "const": true }
1912
+ },
1913
+ "required": [
1914
+ "action",
1915
+ "ref",
1916
+ "folderPath",
1917
+ "schemaVersion",
1918
+ "planDigest",
1919
+ "confirmation",
1920
+ "confirm"
1921
+ ],
1922
+ "additionalProperties": false
1923
+ }
1924
+ ]
1831
1925
  }
1832
1926
  ```
1833
1927
 
1928
+ **Output Schema:**
1929
+
1930
+ - `action=preview` → `gno://schemas/file-refactor-preview@1.0` (content-free plan)
1931
+ - `action=apply` → `gno://schemas/file-refactor-apply-result@1.0` (content-free receipt)
1932
+
1933
+ Missing or incorrect apply confirmation fails before mutation.
1934
+
1834
1935
  ---
1835
1936
 
1836
1937
  ### gno_duplicate_note
@@ -2243,6 +2344,8 @@ Output schemas include version in `$id`:
2243
2344
 
2244
2345
  - `gno://schemas/search-result@1.0`
2245
2346
  - `gno://schemas/capture-receipt@1.0`
2347
+ - `gno://schemas/file-refactor-preview@1.0`
2348
+ - `gno://schemas/file-refactor-apply-result@1.0`
2246
2349
 
2247
2350
  Clients should check schema version for compatibility.
2248
2351
 
@@ -0,0 +1,305 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/file-refactor-apply-result@1.0",
4
+ "title": "GNO File Refactor Apply Result",
5
+ "description": "Terminal result for reference-safe rename/move apply. Filesystem commit/rollback is modeled separately from post-commit index convergence; recovery metadata is content-free. Status discriminates valid filesystem/index/reason combinations.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schemaVersion",
10
+ "status",
11
+ "planDigest",
12
+ "operation",
13
+ "source",
14
+ "target",
15
+ "filesystem",
16
+ "indexConvergence"
17
+ ],
18
+ "properties": {
19
+ "schemaVersion": {
20
+ "const": "1.0"
21
+ },
22
+ "status": {
23
+ "type": "string",
24
+ "enum": [
25
+ "applied",
26
+ "applied_with_sync_pending",
27
+ "conflict",
28
+ "stale_plan",
29
+ "unsupported",
30
+ "failed_rolled_back"
31
+ ]
32
+ },
33
+ "planDigest": {
34
+ "type": "string",
35
+ "pattern": "^[a-f0-9]{64}$"
36
+ },
37
+ "operation": {
38
+ "type": "string",
39
+ "enum": ["rename", "move"]
40
+ },
41
+ "source": {
42
+ "$ref": "#/definitions/documentRef"
43
+ },
44
+ "target": {
45
+ "$ref": "#/definitions/documentRef"
46
+ },
47
+ "reasonCode": {
48
+ "$ref": "#/definitions/reasonCode"
49
+ },
50
+ "filesystem": {
51
+ "type": "object",
52
+ "additionalProperties": false,
53
+ "required": ["state"],
54
+ "properties": {
55
+ "state": {
56
+ "type": "string",
57
+ "enum": ["committed", "rolled_back", "unchanged", "recovery_required"]
58
+ },
59
+ "recoveryJournalId": {
60
+ "type": "string",
61
+ "minLength": 1,
62
+ "maxLength": 128,
63
+ "description": "Opaque journal id only — never embeds note content"
64
+ }
65
+ }
66
+ },
67
+ "indexConvergence": {
68
+ "type": "object",
69
+ "additionalProperties": false,
70
+ "required": ["state"],
71
+ "properties": {
72
+ "state": {
73
+ "type": "string",
74
+ "enum": ["converged", "pending", "not_attempted", "skipped"]
75
+ },
76
+ "recoveryInstruction": {
77
+ "type": "string",
78
+ "minLength": 1,
79
+ "maxLength": 512,
80
+ "description": "Content-free instruction to finish index convergence"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ "definitions": {
86
+ "documentRef": {
87
+ "type": "object",
88
+ "additionalProperties": false,
89
+ "required": ["uri", "relPath", "collection"],
90
+ "properties": {
91
+ "uri": {
92
+ "type": "string",
93
+ "minLength": 1,
94
+ "maxLength": 1024
95
+ },
96
+ "relPath": {
97
+ "type": "string",
98
+ "minLength": 1,
99
+ "maxLength": 1024
100
+ },
101
+ "collection": {
102
+ "type": "string",
103
+ "minLength": 1,
104
+ "maxLength": 256
105
+ }
106
+ }
107
+ },
108
+ "reasonCode": {
109
+ "type": "string",
110
+ "enum": [
111
+ "ambiguous_resolution",
112
+ "unsupported_syntax",
113
+ "malformed_syntax",
114
+ "stale_plan",
115
+ "capability_denied",
116
+ "occupied_target",
117
+ "sync_pending",
118
+ "cross_collection_unsupported",
119
+ "unsafe_target",
120
+ "external_destination",
121
+ "code_fence_context",
122
+ "inline_code_context",
123
+ "html_context",
124
+ "duplicate_basename_ambiguity",
125
+ "unicode_normalization_mismatch",
126
+ "destination_unchanged",
127
+ "read_only_document",
128
+ "relative_path_recalculated",
129
+ "reference_definition_site",
130
+ "filesystem_commit_failed",
131
+ "rollback_recovery_required"
132
+ ]
133
+ }
134
+ },
135
+ "allOf": [
136
+ {
137
+ "if": {
138
+ "type": "object",
139
+ "properties": {
140
+ "status": {
141
+ "const": "applied"
142
+ }
143
+ },
144
+ "required": ["status"]
145
+ },
146
+ "then": {
147
+ "type": "object",
148
+ "properties": {
149
+ "reasonCode": false,
150
+ "filesystem": {
151
+ "type": "object",
152
+ "properties": {
153
+ "state": {
154
+ "const": "committed"
155
+ }
156
+ }
157
+ },
158
+ "indexConvergence": {
159
+ "type": "object",
160
+ "additionalProperties": false,
161
+ "required": ["state"],
162
+ "properties": {
163
+ "state": {
164
+ "const": "converged"
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+ },
171
+ {
172
+ "if": {
173
+ "type": "object",
174
+ "properties": {
175
+ "status": {
176
+ "const": "applied_with_sync_pending"
177
+ }
178
+ },
179
+ "required": ["status"]
180
+ },
181
+ "then": {
182
+ "type": "object",
183
+ "required": ["reasonCode"],
184
+ "properties": {
185
+ "reasonCode": {
186
+ "const": "sync_pending"
187
+ },
188
+ "filesystem": {
189
+ "type": "object",
190
+ "properties": {
191
+ "state": {
192
+ "const": "committed"
193
+ }
194
+ }
195
+ },
196
+ "indexConvergence": {
197
+ "type": "object",
198
+ "additionalProperties": false,
199
+ "required": ["state", "recoveryInstruction"],
200
+ "properties": {
201
+ "state": {
202
+ "const": "pending"
203
+ },
204
+ "recoveryInstruction": {
205
+ "type": "string",
206
+ "minLength": 1,
207
+ "maxLength": 512
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ },
214
+ {
215
+ "if": {
216
+ "type": "object",
217
+ "properties": {
218
+ "status": {
219
+ "enum": ["conflict", "stale_plan", "unsupported"]
220
+ }
221
+ },
222
+ "required": ["status"]
223
+ },
224
+ "then": {
225
+ "type": "object",
226
+ "required": ["reasonCode"],
227
+ "properties": {
228
+ "filesystem": {
229
+ "type": "object",
230
+ "properties": {
231
+ "state": {
232
+ "const": "unchanged"
233
+ }
234
+ }
235
+ },
236
+ "indexConvergence": {
237
+ "type": "object",
238
+ "additionalProperties": false,
239
+ "required": ["state"],
240
+ "properties": {
241
+ "state": {
242
+ "enum": ["not_attempted", "skipped"]
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ },
249
+ {
250
+ "if": {
251
+ "type": "object",
252
+ "properties": {
253
+ "status": {
254
+ "const": "stale_plan"
255
+ }
256
+ },
257
+ "required": ["status"]
258
+ },
259
+ "then": {
260
+ "type": "object",
261
+ "required": ["reasonCode"],
262
+ "properties": {
263
+ "reasonCode": {
264
+ "const": "stale_plan"
265
+ }
266
+ }
267
+ }
268
+ },
269
+ {
270
+ "if": {
271
+ "type": "object",
272
+ "properties": {
273
+ "status": {
274
+ "const": "failed_rolled_back"
275
+ }
276
+ },
277
+ "required": ["status"]
278
+ },
279
+ "then": {
280
+ "type": "object",
281
+ "required": ["reasonCode"],
282
+ "properties": {
283
+ "filesystem": {
284
+ "type": "object",
285
+ "properties": {
286
+ "state": {
287
+ "enum": ["rolled_back", "recovery_required"]
288
+ }
289
+ }
290
+ },
291
+ "indexConvergence": {
292
+ "type": "object",
293
+ "additionalProperties": false,
294
+ "required": ["state"],
295
+ "properties": {
296
+ "state": {
297
+ "enum": ["not_attempted", "skipped"]
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ ]
305
+ }