@ansonlai/docx-redline-js 0.4.0 → 0.5.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 (100) hide show
  1. package/AGENTS.md +589 -287
  2. package/ARCHITECTURE.md +215 -9
  3. package/CHANGELOG.md +319 -0
  4. package/README.md +604 -360
  5. package/adapters/config.js +45 -43
  6. package/bin/docx-redline.js +3 -0
  7. package/core/list-targeting.js +101 -110
  8. package/core/paragraph-targeting.js +501 -61
  9. package/core/paragraph-text.js +209 -0
  10. package/core/revision-cloning.js +38 -0
  11. package/core/types.js +64 -10
  12. package/core/word-xml.js +43 -15
  13. package/dist/docx-redline-js.esm.js +2849 -466
  14. package/dist/docx-redline-js.esm.js.map +4 -4
  15. package/dist/docx-redline-js.esm.min.js +87 -76
  16. package/dist/docx-redline-js.esm.min.js.map +4 -4
  17. package/docs/TESTING.md +342 -23
  18. package/docs/plans/2026-09-05-structural-revisions-and-fidelity-oracles.md +1669 -0
  19. package/docs/plans/completed/2026-09-01-performance-and-complexity-reduction.md +669 -0
  20. package/docs/plans/completed/2026-09-03-agent-friendly-document-workflows.md +427 -0
  21. package/docs/plans/completed/2026-09-04-comment-anchor-and-cli-reliability.md +519 -0
  22. package/docs/plans/completed/PERFORMANCE-CONSOLIDATION.md +69 -0
  23. package/docs/plans/completed/structural-revision-capability-matrix.md +115 -0
  24. package/docs/schemas/document-operations.schema.json +109 -0
  25. package/docs/test-comparison-dashboard.html +4250 -7
  26. package/engine/formatting-removal.js +11 -2
  27. package/engine/oxml-engine.js +491 -336
  28. package/engine/reconstruction-mode.js +15 -14
  29. package/engine/reconstruction-writer.js +247 -142
  30. package/engine/route-selection.js +35 -0
  31. package/engine/rpr-helpers.js +334 -35
  32. package/engine/run-builders.js +239 -196
  33. package/engine/surgical-diff-application.js +222 -37
  34. package/engine/surgical-mode.js +134 -6
  35. package/engine/surgical-spans.js +52 -1
  36. package/engine/table-cell-context.js +3 -6
  37. package/engine/table-mode.js +1 -1
  38. package/index.d.ts +234 -6
  39. package/index.js +24 -1
  40. package/node/cli.js +317 -0
  41. package/node/docx-document.js +302 -0
  42. package/node/index.d.ts +31 -0
  43. package/node/index.js +2 -0
  44. package/node/zip-archive.js +52 -0
  45. package/orchestration/list-markdown.js +10 -16
  46. package/orchestration/list-parsing.js +7 -12
  47. package/orchestration/list-structural-fallback.js +21 -10
  48. package/package.json +24 -3
  49. package/pipeline/content-analysis.js +12 -17
  50. package/pipeline/ingestion-export.js +3 -31
  51. package/pipeline/ingestion-paragraph.js +10 -5
  52. package/pipeline/list-generation.js +150 -55
  53. package/pipeline/list-markers.js +70 -3
  54. package/pipeline/serialization.js +4 -2
  55. package/pipeline/structured-content.js +160 -0
  56. package/scripts/apply_changes.mjs +27 -0
  57. package/scripts/benchmark-operation-session.mjs +137 -0
  58. package/scripts/benchmark-targeting-browser.html +74 -0
  59. package/scripts/benchmark-targeting-hot-paths.mjs +67 -0
  60. package/scripts/benchmark-test-runner.mjs +59 -0
  61. package/scripts/build-test-dashboard.mjs +23 -0
  62. package/scripts/export-lane1-fixtures.mjs +380 -0
  63. package/scripts/export-reredline-stress-fixtures.mjs +317 -0
  64. package/scripts/export-validation-fixtures.mjs +1 -1
  65. package/scripts/extract_text.mjs +7 -0
  66. package/scripts/generate-paragraph-boundary-fixtures.ps1 +215 -0
  67. package/scripts/generate-test-dashboard.mjs +362 -11
  68. package/scripts/lib/word-coverage-catalogue.mjs +6 -2
  69. package/scripts/profile-route-selection.mjs +19 -0
  70. package/scripts/render-agenda-multilevel.mjs +0 -5
  71. package/scripts/render-multilevel-cases.mjs +0 -1
  72. package/scripts/run-tests.mjs +107 -35
  73. package/scripts/word-com-corpus-suite.ps1 +3 -0
  74. package/scripts/word-com-differential.ps1 +64 -4
  75. package/scripts/word-com-suite.ps1 +3 -0
  76. package/services/batch-operation-orchestrator.js +494 -0
  77. package/services/capture-engine.js +226 -0
  78. package/services/comment-builders.js +23 -6
  79. package/services/comment-engine.js +108 -47
  80. package/services/comment-locator.js +187 -82
  81. package/services/comment-replies.js +95 -0
  82. package/services/document-inspection.js +258 -0
  83. package/services/document-operation-applier.js +372 -0
  84. package/services/document-operation-contract.js +323 -0
  85. package/services/document-operation-mutations.js +1733 -0
  86. package/services/document-operation-session.js +258 -0
  87. package/services/numbering-service.js +14 -5
  88. package/services/operation-heuristics.js +173 -0
  89. package/services/operation-preflight.js +366 -0
  90. package/services/receipt-collector.js +288 -0
  91. package/services/revision-comment-management.js +37 -5
  92. package/services/revision-token.js +290 -0
  93. package/services/standalone-docx-plumbing.js +123 -8
  94. package/services/standalone-operation-runner.d.ts +296 -0
  95. package/services/standalone-operation-runner.js +10 -1455
  96. package/services/table-reconciliation.js +15 -6
  97. package/docs/VALIDATION.md +0 -183
  98. package/docs/WORD-MANUAL-REVIEW.md +0 -138
  99. package/docs/plans/2026-09-01-performance-and-complexity-reduction.md +0 -210
  100. /package/docs/plans/{2026-08-30-reliability-testing-improvements.md → completed/2026-08-30-reliability-testing-improvements.md} +0 -0
@@ -0,0 +1,427 @@
1
+ # Agent-Friendly Document Workflow Plan
2
+
3
+ **Status:** Implementation complete — external release validation noted below
4
+ **Date:** 2026-09-03
5
+
6
+ This plan turns integration lessons from a real `docx-redline-js` skill into a
7
+ supported product surface. The skill successfully uses the engine, but it also
8
+ has to reimplement document inspection, comment reading, package transactions,
9
+ visible provision references, per-operation authorship, and safe command-line
10
+ workflows. Those are recurring integration responsibilities rather than
11
+ skill-specific business logic.
12
+
13
+ The core reconciliation engine should remain host-independent and focused on
14
+ OOXML. Agent-facing `.docx` file handling should be added as a separate adapter
15
+ or companion CLI so the core does not acquire a mandatory ZIP implementation.
16
+
17
+ ## Baseline
18
+
19
+ As of 2026-09-03:
20
+
21
+ - Paragraph/range reconciliation is available through `applyRedlineToOxml`.
22
+ - Full `word/document.xml` operations are available through the
23
+ `@ansonlai/docx-redline-js/standalone-runner` export.
24
+ - Atomic batches reorder comments ahead of text edits, but accept one author
25
+ for the entire batch.
26
+ - The public declarations do not define discriminated operation types or the
27
+ standalone runner functions, and comment request arrays are typed as
28
+ `unknown[]`.
29
+ - Targeting supports transient paragraph references and text heuristics, but
30
+ text-only duplicate matches can resolve to the first candidate.
31
+ - There is no supported structured document-inspection or comment-reading API.
32
+ - Package callers must merge comments and numbering, allocate identifiers, and
33
+ invoke validation correctly themselves.
34
+ - `ensureNumberingArtifactsInZip` replaces existing numbering unless the caller
35
+ supplies `mergeNumberingXmlBySchemaOrder`.
36
+ - Revision-safe cloning work for comment/highlight run splitting is in progress
37
+ separately and is not re-scoped by this plan.
38
+
39
+ This plan overlaps with
40
+ `2026-09-01-performance-and-complexity-reduction.md`. Implement the operation
41
+ schema and batch facade against the modularized/in-memory runner from that plan
42
+ where practical; do not create a second batch engine.
43
+
44
+ ## Compatibility strategy
45
+
46
+ | Phase | Expected impact |
47
+ |---|---|
48
+ | 1. Public contracts | Additive. Existing operation objects and runner signatures remain supported. |
49
+ | 2. Targeting and preflight | Additive by default. Strict ambiguity handling is opt-in until the next major version. |
50
+ | 3. Structured inspection | Additive. New read-only APIs. |
51
+ | 4. Transactional package facade | Additive companion surface. Core keeps no mandatory ZIP dependency. |
52
+ | 5. Safe defaults and CLI | Mostly additive. Changing numbering replacement behavior requires a deprecation period or major release. |
53
+
54
+ ---
55
+
56
+ ## Phase 1 — Typed operations and per-operation attribution
57
+
58
+ **Status:** Complete (2026-09-03)
59
+
60
+ ### Problem
61
+
62
+ The runner's operation field names are discoverable mainly from implementation
63
+ code. Its batch author applies to every operation, forcing consumers that need
64
+ different redline and comment authors to rebuild scheduling and atomicity.
65
+
66
+ ### Work
67
+
68
+ 1. Define and export discriminated types for redline, comment, and highlight
69
+ operations, runner options, per-operation results, and batch results.
70
+ 2. Export runner declarations from the stable `./standalone-runner` package
71
+ subpath and consider re-exporting the primary runner functions at the root.
72
+ 3. Add optional `author` to each operation. Resolution order should be explicit:
73
+ operation author, batch default author, configured legacy fallback.
74
+ 4. Include `authorUsed`, `resolvedBy`, and resolved target metadata in every
75
+ operation result.
76
+ 5. Add runtime operation validation with stable `INVALID_OPERATION` diagnostics
77
+ for missing or incompatible fields.
78
+ 6. Keep the existing operation names (`modified`, `textToComment`, and
79
+ `commentContent`) compatible. If ergonomic aliases are introduced, normalize
80
+ them once at the API boundary and document one canonical representation.
81
+
82
+ ### Acceptance
83
+
84
+ - TypeScript catches a comment using redline-only fields and vice versa.
85
+ - One atomic batch can emit revisions and comments under different authors.
86
+ - Existing JavaScript callers using the batch-level author continue to work.
87
+ - Every result identifies the author and target actually used.
88
+
89
+ ### Implementation notes
90
+
91
+ - Added discriminated operation/result declarations at the stable
92
+ `./standalone-runner` package subpath and exported the reusable types from the
93
+ root declaration file.
94
+ - Added runtime `INVALID_OPERATION` validation while retaining `replace`,
95
+ `format`, `list-change`, `table-reconciliation`, `insert`, and `delete` as
96
+ compatibility labels for redline operations.
97
+ - Added per-operation author resolution, `authorUsed`, `authorsUsed`, canonical
98
+ `operationType`, `resolvedBy`, and resolved target metadata.
99
+ - Preserved the batch-level author as the fallback for existing callers.
100
+ - Verified with `tests/agent_operation_contract_tests.mjs`, the existing
101
+ standalone runner tests, and `npm run check:types`.
102
+
103
+ ---
104
+
105
+ ## Phase 2 — Safe target descriptors and preflight
106
+
107
+ **Status:** Complete (2026-09-03)
108
+
109
+ ### Problem
110
+
111
+ Text-only targeting is convenient but unsafe when boilerplate paragraphs repeat.
112
+ Agents also need to discover existing-revision conflicts and invalid anchors
113
+ before mutating a document.
114
+
115
+ ### Work
116
+
117
+ 1. Introduce a target descriptor supporting exact text, paragraph ID, transient
118
+ index, table/list context, occurrence, and an optional source fingerprint.
119
+ 2. Add `AMBIGUOUS_TARGET` with candidate metadata. Provide a strict targeting
120
+ option immediately and make strict behavior the default in the next major
121
+ version.
122
+ 3. Return normalization diagnostics when the matched text differs from the
123
+ supplied target in whitespace or punctuation.
124
+ 4. Add `preflightOperations(documentParts, operations, options)` that performs no
125
+ mutation and reports:
126
+ - missing and ambiguous targets;
127
+ - anchor presence and candidate ranges;
128
+ - existing revisions on affected paragraphs;
129
+ - incompatible operations against the same target;
130
+ - authors that will be written;
131
+ - required comments and numbering artifacts.
132
+ 5. Define ordering/conflict behavior for comment, highlight, and replacement
133
+ operations aimed at the same paragraph. Do not rely only on global type
134
+ priority when one operation changes another operation's target or revision
135
+ policy.
136
+
137
+ ### Acceptance
138
+
139
+ - Strict mode never silently edits the first of multiple exact matches.
140
+ - Preflight results are deterministic, serializable JSON and map one-to-one to
141
+ original operation indexes.
142
+ - A consumer can resolve all target and author questions before applying edits.
143
+
144
+ ### Implementation notes
145
+
146
+ - Added target descriptors for exact text, paragraph ID, index, occurrence,
147
+ table context, and deterministic source fingerprint.
148
+ - Added opt-in `strictTargets` application behavior with `AMBIGUOUS_TARGET` and
149
+ no fuzzy fallback. Legacy application remains permissive by default.
150
+ - Added read-only `preflightOperations`, strict by default, with target and
151
+ anchor diagnostics, existing-revision policy checks, author reporting,
152
+ artifact requirements, and same-paragraph operation conflicts.
153
+ - Added candidate metadata to ambiguity errors so callers can choose a stable
154
+ disambiguator and retry.
155
+ - Added focused coverage for duplicate exact text, occurrence and fingerprint
156
+ selection, stale fingerprints, paragraph IDs, missing anchors, existing
157
+ revisions, artifact prediction, operation conflicts, per-operation authors,
158
+ and runtime validation.
159
+ - Verified the completed phases with 47/47 test files, type checks, dependency
160
+ isolation, changed-file lint, and `git diff --check`.
161
+
162
+ ---
163
+
164
+ ## Phase 3 — Structured document inspection
165
+
166
+ **Status:** Complete (2026-09-03)
167
+
168
+ ### Problem
169
+
170
+ Consumers currently reconstruct paragraph inventories, accepted-view text,
171
+ comment anchors, headings, and visible list numbers themselves. This produces
172
+ multiple subtly different definitions of document text and target identity.
173
+
174
+ ### Work
175
+
176
+ 1. Add a read-only inspection API over document parts that returns paragraphs
177
+ in document order with:
178
+ - exact canonical visible text;
179
+ - paragraph ID/path and transient index;
180
+ - table-cell and list context;
181
+ - heading/style context;
182
+ - existing revision and comment authors;
183
+ - whether revision markup intersects the paragraph.
184
+ 2. Add a comment reader that joins `word/comments.xml` definitions to document
185
+ anchors and reports exact anchored text in document order.
186
+ 3. Centralize accepted/rejected/current-view text semantics, including moves,
187
+ tabs, breaks, fields, notes, and other structural content. Reuse the canonical
188
+ extractor in targeting and ingestion rather than maintaining parallel walkers.
189
+ 4. Add optional visible numbering resolution from `numbering.xml`, including
190
+ levels, overrides, restarts, and section-continuation cases covered by tests.
191
+ 5. Produce human-facing references from provision number, enclosing heading,
192
+ and a quotable excerpt. Treat computed numbering as advisory and always retain
193
+ the excerpt.
194
+ 6. Support filtering by index/range, text search, revision presence, table
195
+ context, and non-empty content without requiring callers to post-process a
196
+ full-document dump.
197
+
198
+ ### Acceptance
199
+
200
+ - Inspection output can supply target and replacement source strings without
201
+ losing tabs or boundary whitespace.
202
+ - Comment definitions, ranges, authors, and anchor text round-trip on existing
203
+ commented documents.
204
+ - Targeting and inspection use the same canonical text representation.
205
+ - Provision references are verified against fixtures with numbering restarts
206
+ and overrides.
207
+
208
+ ### Implementation notes
209
+
210
+ - Added `inspectDocumentParts(...)` with exact text, target identity,
211
+ heading/table/list context, revision authors, comment joins, and filters.
212
+ - Centralized accepted/rejected-view text and reused it in targeting and
213
+ ingestion, including moves, tabs, breaks, and hyphens.
214
+ - Added advisory numbering resolution for level formats and start/level
215
+ overrides while retaining exact excerpts.
216
+ - Added focused coverage in `tests/document_inspection_tests.mjs`.
217
+
218
+ ---
219
+
220
+ ## Phase 4 — Transactional package facade
221
+
222
+ **Status:** Complete (2026-09-03)
223
+
224
+ ### Problem
225
+
226
+ The XML runner cannot safely own concerns that span `document.xml`,
227
+ `comments.xml`, `numbering.xml`, relationships, and content types. Callers must
228
+ currently compose those steps correctly and preserve the original package for
229
+ rollback.
230
+
231
+ ### Work
232
+
233
+ 1. Add a separate Node adapter or companion package with an API similar to:
234
+
235
+ ```js
236
+ const document = await openDocx(inputBuffer);
237
+ const inspection = await document.inspect(options);
238
+ const result = await document.applyOperations(operations, {
239
+ author: 'Editor',
240
+ atomic: true,
241
+ validate: true
242
+ });
243
+ const outputBuffer = await result.toBuffer();
244
+ ```
245
+
246
+ 2. Seed comment IDs from both document anchors and the existing comments part.
247
+ Keep comment IDs and revision IDs in explicit document/package-scoped
248
+ allocators.
249
+ 3. Merge numbering with schema-order-safe behavior by default and preserve all
250
+ existing definitions.
251
+ 4. Update comment definitions and anchors together for add/delete operations.
252
+ 5. Treat apply, artifact merge, relationship/content-type wiring, and validation
253
+ as one transaction. Atomic failure returns the untouched input buffer.
254
+ 6. Validate both the original package and generated package so diagnostics can
255
+ distinguish pre-existing defects from newly introduced ones.
256
+ 7. Return a complete report containing operation results, authors used,
257
+ artifacts changed, validation issues, execution order, and whether output was
258
+ written.
259
+
260
+ ### Acceptance
261
+
262
+ - Callers can safely edit a `.docx` without manually opening or rewriting ZIP
263
+ parts.
264
+ - Existing comments and numbering survive new comments and lists.
265
+ - A generated validation failure cannot produce a writable partial result in
266
+ atomic mode.
267
+ - No ZIP dependency becomes mandatory for browser or XML-only core consumers.
268
+
269
+ ### Implementation notes
270
+
271
+ - Added the isolated `@ansonlai/docx-redline-js/node` entry point with
272
+ `openDocx`, inspection, preflight, batch application, and serialization.
273
+ - Package mutation clones parts, allocates comment IDs above existing package
274
+ IDs, merges numbering by schema order, updates OPC wiring, validates, and
275
+ commits only on success.
276
+ - Results report `written`; atomic failures return the original input bytes.
277
+ Unmodified entry contents remain byte-identical after extraction.
278
+ - Added coverage in `tests/docx_package_facade_tests.mjs`.
279
+
280
+ ---
281
+
282
+ ## Phase 5 — Supported agent CLI and safer defaults
283
+
284
+ **Status:** Complete (2026-09-03)
285
+
286
+ ### Problem
287
+
288
+ Agents are more reliable with small JSON-producing commands than with ad hoc ZIP
289
+ scripts or large XML dumps. The real skill demonstrates a useful command set,
290
+ but every skill author should not need to maintain a private integration layer.
291
+
292
+ ### Work
293
+
294
+ 1. Build a CLI over the package facade with commands for `inspect`, `extract`,
295
+ `preflight`, `apply`, `accept`, `reject`, `delete-comments`, and `validate`.
296
+ 2. Make output structured JSON with stable error codes and meaningful process
297
+ exit codes. Provide built-in range/search/revision/table filters.
298
+ 3. Require explicit edit and comment authors for mutating agent workflows, while
299
+ retaining legacy fallback behavior in low-level APIs.
300
+ 4. Accept a documented JSON operation file and provide a published JSON Schema.
301
+ 5. Preserve input files by default; require an explicit option for in-place
302
+ mutation.
303
+ 6. Deprecate silent numbering replacement. In the next major version, merge by
304
+ default or throw if safe merging is unavailable.
305
+ 7. Publish a compact agent workflow guide and use it as the source for future
306
+ skills instead of vendoring integration logic independently.
307
+
308
+ ### Acceptance
309
+
310
+ - A skill can consist mainly of workflow and review guidance, with no custom ZIP
311
+ or OOXML manipulation code.
312
+ - Exact paragraph text can flow from `extract` to an operation file without
313
+ whitespace normalization.
314
+ - CLI failures never report a mutation as successful and never overwrite the
315
+ input by default.
316
+ - The CLI works on supported Node versions across Windows, macOS, and Linux.
317
+
318
+ ### Implementation notes
319
+
320
+ - Added the `docx-redline` executable with JSON `inspect`, `extract`,
321
+ `preflight`, `apply`, `accept`, `reject`, `delete-comments`, and `validate`.
322
+ - Added filters for ranges, indexes, search, revision presence, table/body
323
+ context, empty paragraphs, and accepted/rejected views.
324
+ - Mutations require explicit attribution, are transactional, preserve the input
325
+ by default, refuse existing destinations, and require `--in-place` or
326
+ `--force` for the corresponding destructive intent.
327
+ - Added `docs/schemas/document-operations.schema.json` and the compact
328
+ `docs/AGENT-WORKFLOW.md` source for future skills.
329
+ - Deprecated low-level silent numbering replacement with a runtime warning and
330
+ documented the next-major error behavior. The facade and CLI merge today.
331
+ - Added `tests/agent_cli_tests.mjs` covering every command family and the
332
+ recommended end-to-end workflow.
333
+
334
+ ## Testing and release gates
335
+
336
+ Each phase must add focused unit tests plus package-level fixtures where relevant.
337
+ Before release:
338
+
339
+ - Run `npm test`, `npm run test:isolation`, `npm run check:types`, and
340
+ `npm run lint`.
341
+ - Add duplicate-target, existing-comment-ID, multi-author, numbering-merge, and
342
+ atomic-validation regression cases.
343
+ - Add Word differential cases for comments on previously revised runs, multiple
344
+ existing comment authors, and lists added to documents with existing numbering.
345
+ - Confirm accept/reject round trips and Word-open-without-repair behavior.
346
+ - Document any default change in the changelog and provide a migration example.
347
+
348
+ ### Phase 1–2 verification record (2026-09-03)
349
+
350
+ - `npm test`: 47/47 test files pass.
351
+ - `npm run check:types`: pass; the stable `./standalone-runner` self-import is
352
+ exercised by the TypeScript usage fixture.
353
+ - `npm run test:isolation`: pass.
354
+ - ESLint on all Phase 1–2 implementation files: pass.
355
+ - `git diff --check`: pass.
356
+ - The repository-wide `npm run lint` remains blocked by pre-existing unused
357
+ variables in `scripts/render-agenda-multilevel.mjs` and
358
+ `scripts/render-multilevel-cases.mjs`; these files were outside this plan and
359
+ were not changed.
360
+
361
+ ### Phase 3–4 verification record (2026-09-03)
362
+
363
+ - `npm test`: 49/49 test files pass, including structured inspection and real
364
+ DOCX-buffer transaction regressions.
365
+ - `npm run test:isolation`: pass; the Node facade is a separate export and the
366
+ root/browser dependency graph remains host-independent.
367
+ - `npm run check:types`: pass, including declarations for both new surfaces.
368
+ - `git diff --check`: pass.
369
+
370
+ ### Phase 5 and final plan audit (2026-09-03)
371
+
372
+ - `npm test`: 55/55 test files pass. The final suites cover duplicate targets,
373
+ per-operation authors, existing high comment IDs, numbering preservation,
374
+ exact comment anchors, coordinated comment deletion, atomic validation
375
+ rollback, CLI safety, and accept/reject transforms.
376
+ - `npm run test:isolation`: pass. Node filesystem, ZIP, and DOM dependencies
377
+ remain confined to the separate Node surface.
378
+ - `npm run check:types`: pass; 106 root runtime exports have declarations and
379
+ the self-import fixtures cover the standalone and Node subpaths.
380
+ - `npm run lint`: pass. The five pre-existing unused-variable failures in two
381
+ one-off rendering scripts were removed during the final release-gate audit.
382
+ - `npm run build`: pass.
383
+ - `npm pack --dry-run`: pass and includes the executable, Node facade, agent
384
+ guide, and operation JSON Schema.
385
+ - `git diff --check`: pass; only line-ending conversion notices are emitted.
386
+
387
+ | Phase | Final acceptance audit |
388
+ |---|---|
389
+ | 1. Public contracts | Complete: discriminated types, validation, attribution, and result metadata are implemented and tested. |
390
+ | 2. Targeting/preflight | Complete: strict ambiguity, stable descriptors, diagnostics, conflicts, and artifact prediction are implemented and tested. |
391
+ | 3. Inspection | Complete: canonical text, exact comment anchors, styles/headings, table-cell coordinates, structural references, advisory numbering, human references, and filters are implemented and tested. |
392
+ | 4. Package facade | Complete: add/delete comment coordination, scoped IDs, numbering preservation, validation comparison, reports, and byte-safe rollback are implemented and tested. |
393
+ | 5. Agent CLI | Complete: all planned commands, JSON output, explicit attribution, schema, safe paths, deprecation, and workflow guidance are implemented and tested. |
394
+
395
+ The implementation plan is complete. Desktop Word differential/visual runs and
396
+ multi-OS Node execution remain release-environment checks rather than local
397
+ implementation blockers. The existing Word, corpus, XSD, LibreOffice, and CI
398
+ lanes documented in `docs/TESTING.md` and `docs/VALIDATION.md` should run before
399
+ publishing a release. No local Word or independent-office validation result is
400
+ claimed by this audit.
401
+
402
+ ### Follow-up regression expansion (2026-09-04)
403
+
404
+ - Added five focused edge suites beyond the original Phase 1–5 acceptance
405
+ coverage. They verify canonical accepted/rejected/current views,
406
+ cross-paragraph comment anchors, outline/table/reference inspection, nested
407
+ numbering, byte-exact no-ops, reusable transaction rollback, selective
408
+ comment/revision authors, package ID seeding, invalid ZIP rejection, CLI
409
+ filters, output collisions, force/in-place authorization, and JSON exit codes.
410
+ - The additional tests exposed and fixed three gaps: explicit `current` view
411
+ behavior, multi-paragraph comment-anchor reconstruction, and byte-exact
412
+ package output for no-op transactions.
413
+ - `npm test` now passes 55/55 test files. The remaining release-environment
414
+ qualifications are unchanged: desktop Word/LibreOffice and multi-OS CI are
415
+ not claimed by this local test run.
416
+ - `npm run test:coverage` passes at 89.05% statements/lines, 77.04% branches,
417
+ and 92.63% functions overall. The Node facade/CLI/ZIP surface reaches 99.61%
418
+ statements/lines, while canonical paragraph text reaches 100%.
419
+
420
+ ## Non-goals
421
+
422
+ - Moving ZIP or filesystem dependencies into the host-independent core.
423
+ - Editing headers, footers, text boxes, or notes before the corresponding core
424
+ document-part support is designed and tested.
425
+ - Treating paragraph indexes or computed provision numbers as permanent document
426
+ identifiers.
427
+ - Automatically accepting existing revisions merely to make an operation pass.