fusion-cli 1.3.1__tar.gz → 1.4.1__tar.gz

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 (77) hide show
  1. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/PKG-INFO +1 -1
  2. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/pyproject.toml +1 -1
  3. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/SKILL.md +21 -4
  4. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/references/convert.md +4 -1
  5. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/scripts/convert.py +139 -9
  6. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/tests/make_fixtures.py +13 -2
  7. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/tests/test_convert.py +174 -0
  8. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/tests/test_gate.py +20 -0
  9. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/restructure.md +7 -1
  10. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/checker.py +88 -1
  11. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/document.py +19 -0
  12. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/scaffold.py +9 -0
  13. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_checker_warnings.py +125 -0
  14. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_document.py +15 -0
  15. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_scaffold.py +12 -0
  16. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/uv.lock +1 -1
  17. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/.gitignore +0 -0
  18. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/README.md +0 -0
  19. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/hatch_build.py +0 -0
  20. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/SKILL.md +0 -0
  21. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/references/assess.md +0 -0
  22. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/references/compare.md +0 -0
  23. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/references/export.md +0 -0
  24. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/references/fusion-conventions.md +0 -0
  25. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/references/report.md +0 -0
  26. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-analyst/scripts/export.py +0 -0
  27. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/references/delivery.md +0 -0
  28. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/references/fusion-conventions.md +0 -0
  29. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/references/gate.md +0 -0
  30. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/scripts/gate.py +0 -0
  31. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/tests/conftest.py +0 -0
  32. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-intake/tests/test_integration.py +0 -0
  33. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/SKILL.md +0 -0
  34. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/archive.md +0 -0
  35. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/create.md +0 -0
  36. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/cross-reference.md +0 -0
  37. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/fusion-conventions.md +0 -0
  38. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/promote.md +0 -0
  39. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/query.md +0 -0
  40. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/reflect.md +0 -0
  41. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/references/tag.md +0 -0
  42. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/scripts/link-repair.py +0 -0
  43. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/tests/conftest.py +0 -0
  44. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-librarian/tests/test_link_repair.py +0 -0
  45. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-planner/SKILL.md +0 -0
  46. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-planner/references/close.md +0 -0
  47. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-planner/references/create-activity.md +0 -0
  48. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-planner/references/fusion-conventions.md +0 -0
  49. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/skills/fusion-planner/references/horizon.md +0 -0
  50. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/__init__.py +0 -0
  51. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/bucket.py +0 -0
  52. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/cli.py +0 -0
  53. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/hub.py +0 -0
  54. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/indexer.py +0 -0
  55. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/ledger.py +0 -0
  56. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/manifest.py +0 -0
  57. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/setup.py +0 -0
  58. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/update.py +0 -0
  59. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/src/fusion/views.py +0 -0
  60. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/__init__.py +0 -0
  61. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/conftest.py +0 -0
  62. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_build_payload.py +0 -0
  63. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_checker_errors.py +0 -0
  64. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_cli.py +0 -0
  65. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_cli_encoding.py +0 -0
  66. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_cli_setup.py +0 -0
  67. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_cli_update.py +0 -0
  68. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_cli_version.py +0 -0
  69. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_hub_bucket.py +0 -0
  70. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_indexer.py +0 -0
  71. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_ledger.py +0 -0
  72. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_line_endings.py +0 -0
  73. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_roundtrip.py +0 -0
  74. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_setup_agents.py +0 -0
  75. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_setup_core.py +0 -0
  76. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_skill_family.py +0 -0
  77. {fusion_cli-1.3.1 → fusion_cli-1.4.1}/tests/test_views.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusion-cli
3
- Version: 1.3.1
3
+ Version: 1.4.1
4
4
  Summary: The Fusion reference CLI — the notary of the Fusion Convention.
5
5
  Author: Bluewaves Boutique
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fusion-cli"
3
- version = "1.3.1"
3
+ version = "1.4.1"
4
4
  description = "The Fusion reference CLI — the notary of the Fusion Convention."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: fusion-intake
3
- description: "The Fusion intake gate — everything that enters a bucket enters through it, losslessly. Classify what landed in inbox/ (new, updated, duplicate, conflicting), preserve the original in sources/ with its sha256 in the MANIFEST, convert to a faithful summary-first document (xlsx, csv, docx, pptx, pdf, html, images, .eml mail, markdown/text exports), propose type and aurora, sign the ledger, clear the inbox. Use when the user says 'process the inbox', 'intake', 'ingest', 'convert this file', or drops files into a Fusion bucket's inbox/. For placement, curation, or restructuring of what is already inside, use fusion-librarian; for deliverables out of the bucket, use fusion-analyst. Applies only inside a Fusion bucket — a directory tree with BUCKET.md and LEDGER.md at its root; if there is no such bucket in play, offer to create one with `fusion new` instead of improvising structure."
3
+ description: "The Fusion intake gate — everything that enters a bucket enters through it, losslessly. Classify what landed in inbox/ (new, updated, duplicate, conflicting), preserve the original in sources/ with its sha256 in the MANIFEST, convert to a faithful summary-first document (xlsx, csv, docx, pptx, pdf, html, images, tiff→png, .eml mail, markdown/text exports), propose type and aurora, sign the ledger, clear the inbox. Use when the user says 'process the inbox', 'intake', 'ingest', 'convert this file', or drops files into a Fusion bucket's inbox/. For placement, curation, or restructuring of what is already inside, use fusion-librarian; for deliverables out of the bucket, use fusion-analyst. Applies only inside a Fusion bucket — a directory tree with BUCKET.md and LEDGER.md at its root; if there is no such bucket in play, offer to create one with `fusion new` instead of improvising structure."
4
4
  license: MIT
5
- compatibility: "Requires the fusion CLI on PATH and uv. LibreOffice (soffice on PATH) required for docx/pptx/legacy office/html formats — fails fast when missing, never silently degrades. Script deps via PEP 723 (openpyxl, PyYAML, pymupdf)."
5
+ compatibility: "Requires the fusion CLI on PATH and uv. LibreOffice (soffice on PATH) required for docx/pptx/legacy office/html formats — fails fast when missing, never silently degrades. Script deps via PEP 723 (openpyxl, PyYAML, pymupdf, pillow)."
6
6
  ---
7
7
 
8
8
  # fusion-intake — the gate
@@ -43,8 +43,8 @@ inbox/ ─► STAGE 1 gate (scripts/gate.py) deterministic: hash, similarit
43
43
 
44
44
  ## Running it
45
45
 
46
- `admit`, `prepare`, `link`, `unpack`, and `gate.py` take the bucket root as
47
- `--bucket`; `cleanup` takes only `--run-dir` — resolve it against the
46
+ `admit`, `prepare`, `link`, `relink`, `unpack`, `batch`, and `gate.py` take
47
+ the bucket root as `--bucket`; `cleanup` takes only `--run-dir` — resolve it against the
48
48
  bucket root before calling (the manifest's `run_dir` is bucket-relative).
49
49
  `<skill>` is this skill's directory.
50
50
 
@@ -70,6 +70,14 @@ and deletes the container — the members become the originals, signed
70
70
  Category follows the bucket's filing rules (BUCKET.md), else a short
71
71
  plural noun (`reports`, `mails`, `gear`). The MANIFEST row is the
72
72
  script's job — never edit MANIFEST.md yourself.
73
+ `.tif`/`.tiff` is converted to PNG right here, deterministically — the
74
+ PNG is admitted as the original (its own sha256 in the MANIFEST row);
75
+ the tiff bytes are not retained (2026-07-12 ruling: no need for large
76
+ tiff files). A single-frame tiff converts cleanly; a multi-frame tiff
77
+ is refused outright (conservative — never a silent first-frame-wins).
78
+ The JSON result carries a `note` field when this happened — sign it
79
+ immediately, same run: `fusion log noted "<note>" --bucket <root> --as
80
+ <you>`.
73
81
  3. **Prepare:**
74
82
  `uv run <skill>/scripts/convert.py prepare --bucket <root> --source <cat>/<name> [--dest …] [--slug …] [--type …] [--aurora …] [--reconcile]`
75
83
  Extractive files (`done: true`) are already conformant documents.
@@ -84,6 +92,10 @@ and deletes the container — the members become the originals, signed
84
92
  `fusion log converted "sources/<cat>/<name> → <doc>" --bucket <root> --as <you>`
85
93
  `fusion index <root>` · `fusion check <root>` — green, then
86
94
  `cleanup --run-dir <dir>`. Nothing remains in inbox for this file.
95
+ 5. **Relink** (only when a linked document later moves):
96
+ `uv run <skill>/scripts/convert.py relink --bucket <root> --source <cat>/<name> --from <old-doc> --to <new-doc>`
97
+ — repoints the cell value in place. MANIFEST.md is single-writer; a
98
+ stale cell is never hand-edited.
87
99
 
88
100
  ## The four classes (locked)
89
101
 
@@ -112,6 +124,11 @@ never erased.
112
124
  ## The fidelity contract (lossless, non-negotiable)
113
125
 
114
126
  - The original lands in `sources/` byte-identical, full sha256 in MANIFEST.
127
+ Exception, human-ruled (2026-07-12): `.tif`/`.tiff` is converted to PNG
128
+ at admit — lossless on pixels, not on bytes, and the human explicitly
129
+ waived tiff-byte preservation to avoid needlessly large files. The PNG
130
+ becomes the original; the source tiff's name + sha256 are carried in
131
+ the admit `note` so the transformation stays honest in the ledger.
115
132
  - Every page is accounted for (`page_count == len(pages)`); a page the
116
133
  text layer can't cover is flagged `needs_vision` and YOU read its image.
117
134
  - Tables: every row, every column. Numbers verbatim — never rounded,
@@ -29,7 +29,10 @@ Format-specific notes:
29
29
  into the document body; if it carried frontmatter, preserve unknown
30
30
  keys (liberal reader) and merge the required three.
31
31
  - **image**: transcribe or describe honestly — a photo gets a faithful
32
- description, a screenshot of text gets the text.
32
+ description, a screenshot of text gets the text. A tiff admitted at
33
+ Stage 1 already landed here as a PNG (admit converts tif/tiff → png,
34
+ 2026-07-12 ruling) — no special casing, it reads exactly like any other
35
+ image.
33
36
  - **html** (`path: libreoffice`): an LLM-artifact-style page — headings,
34
37
  prose, real tables — routed through LibreOffice like docx/pptx/legacy
35
38
  office formats. Read it exactly as any other rendered page below.
@@ -5,6 +5,7 @@
5
5
  # "openpyxl>=3.1.0",
6
6
  # "PyYAML>=6.0",
7
7
  # "pymupdf>=1.24.0",
8
+ # "pillow>=10.0.0",
8
9
  # ]
9
10
  # ///
10
11
  """fusion-intake Stage-1 engine: admit / prepare / link / batch / cleanup.
@@ -31,7 +32,7 @@ import subprocess
31
32
  import sys
32
33
  import uuid
33
34
  import zipfile
34
- from datetime import datetime
35
+ from datetime import date, datetime
35
36
  from email import policy
36
37
  from email.parser import BytesParser
37
38
  from html.parser import HTMLParser
@@ -46,9 +47,16 @@ EXTRACTIVE_EXTS = {".xlsx", ".csv"}
46
47
  LIBREOFFICE_EXTS = {".docx", ".pptx", ".doc", ".odt", ".rtf", ".key",
47
48
  ".pages", ".ppt", ".xls", ".html", ".htm"}
48
49
  IMAGE_EXTS = {".png", ".jpg", ".jpeg", ".webp", ".gif"}
50
+ # Tiffs are never stored as tiffs: sources/ would carry needlessly large
51
+ # files for no fidelity gain over a lossless PNG (human ruling, 2026-07-12
52
+ # — "no need for large tiff files"). admit() converts single-frame tiffs to
53
+ # PNG in place and the PNG becomes the original; TIFF_EXTS therefore stays
54
+ # out of IMAGE_EXTS — it is admit-time-special, not a plain pass-through
55
+ # image format, and (unlike IMAGE_EXTS) never appears in sources/.
56
+ TIFF_EXTS = {".tif", ".tiff"}
49
57
  MAIL_EXTS = {".eml"}
50
58
  TEXT_EXTS = {".md", ".txt", ".json", ".yaml", ".yml"}
51
- SUPPORTED_EXTS = (EXTRACTIVE_EXTS | LIBREOFFICE_EXTS | IMAGE_EXTS
59
+ SUPPORTED_EXTS = (EXTRACTIVE_EXTS | LIBREOFFICE_EXTS | IMAGE_EXTS | TIFF_EXTS
52
60
  | MAIL_EXTS | TEXT_EXTS | {".pdf"})
53
61
 
54
62
  # Containers are DELIVERY VEHICLES, not originals: `unpack` extracts them
@@ -82,6 +90,41 @@ def sha256_of(path: Path) -> str:
82
90
  return h.hexdigest()
83
91
 
84
92
 
93
+ _PNG_NATIVE_MODES = {"1", "L", "LA", "P", "RGB", "RGBA", "I"}
94
+
95
+
96
+ def tiff_to_png(src: Path, dest: Path) -> None:
97
+ """Deterministic, lossless-pixel tiff -> PNG. Single frame only: a
98
+ multi-frame tiff (fax/scan stacks, layered exports) is refused outright
99
+ rather than silently keeping just the first frame — the fidelity
100
+ contract (SKILL.md: "a lossy conversion is a failed conversion") rules
101
+ out a silent partial admit; the conservative choice is refusal, not a
102
+ loud-warning first-frame-wins."""
103
+ from PIL import Image
104
+
105
+ with Image.open(src) as img:
106
+ n_frames = getattr(img, "n_frames", 1)
107
+ if n_frames > 1:
108
+ raise IntakeError(
109
+ f"multi-frame tiff refused: {src.name} carries {n_frames} "
110
+ "frames — fusion-intake admits single-frame tiffs only "
111
+ "(silently keeping just the first frame would violate the "
112
+ "fidelity contract); split it into single-frame files and "
113
+ "admit them individually, or convert it to a single-frame "
114
+ "tiff/png before dropping it in inbox/")
115
+ img.load()
116
+ # PNG cannot encode every tiff pixel mode (CMYK, palette variants
117
+ # with exotic depth, …) — fall back to a standard mode rather than
118
+ # let Pillow's save() raise. RGB/RGBA/L/LA/P/1/I pass through with
119
+ # their pixels untouched (lossless); anything else is converted
120
+ # once, to the closest PNG-native mode (RGBA if it carries alpha,
121
+ # else RGB).
122
+ if img.mode not in _PNG_NATIVE_MODES:
123
+ img = img.convert("RGBA" if "A" in img.mode else "RGB")
124
+ dest.parent.mkdir(parents=True, exist_ok=True)
125
+ img.save(dest, format="PNG")
126
+
127
+
85
128
  def slugify(name: str) -> str:
86
129
  """SPEC §4 filename: lowercase, hyphen-separated, stem <=60 chars."""
87
130
  stem = re.sub(r"\.(xlsx|docx|pptx|csv|pdf|eml|md|txt|png|jpe?g|webp|gif|html?|json|ya?ml)$",
@@ -182,6 +225,41 @@ def manifest_link(root: Path, rel: str, doc: str) -> None:
182
225
  path.write_text("\n".join(lines) + "\n", encoding="utf-8", newline="\n")
183
226
 
184
227
 
228
+ def manifest_relink(root: Path, rel: str, old_doc: str, new_doc: str) -> None:
229
+ path = _manifest_path(root)
230
+ if not path.is_file():
231
+ raise IntakeError(f"no manifest at {path}")
232
+ if old_doc == new_doc:
233
+ raise IntakeError(
234
+ f"relink is a change: --from and --to are both {old_doc!r}")
235
+ if not (Path(root) / new_doc).is_file():
236
+ raise IntakeError(f"relink target does not exist on disk: {new_doc}")
237
+ lines = path.read_text(encoding="utf-8").splitlines()
238
+ hit = False
239
+ for i, line in enumerate(lines):
240
+ if not line.strip().startswith("|"):
241
+ continue
242
+ cells = [c.strip() for c in line.strip().strip("|").split("|")]
243
+ if len(cells) == 5 and cells[0] == rel:
244
+ values = ([] if cells[4] in ("—", "")
245
+ else [v.strip() for v in cells[4].split(",")])
246
+ if old_doc not in values:
247
+ raise IntakeError(
248
+ f"cell does not carry {old_doc!r} for source {rel} "
249
+ f"(cell: {cells[4]!r})")
250
+ if new_doc in values:
251
+ raise IntakeError(
252
+ f"cell already carries {new_doc!r} for source {rel}")
253
+ cells[4] = ", ".join(
254
+ new_doc if v == old_doc else v for v in values)
255
+ lines[i] = "| " + " | ".join(cells) + " |"
256
+ hit = True
257
+ break
258
+ if not hit:
259
+ raise IntakeError(f"source not in manifest: {rel}")
260
+ path.write_text("\n".join(lines) + "\n", encoding="utf-8", newline="\n")
261
+
262
+
185
263
  def _manifest_rels(root: Path) -> set:
186
264
  """The `file` column of every real row — used by `batch` to validate
187
265
  (category, basename) uniqueness against what's already registered."""
@@ -229,17 +307,44 @@ def admit(root: Path, inbox_rel: str, category: str, actor: str) -> dict:
229
307
  raise IntakeError(
230
308
  f"'|' and newlines break the manifest grammar: {src.name!r} — "
231
309
  "rename the incoming file before admitting it")
232
- dest = root / "sources" / category / src.name
310
+ is_tiff = src.suffix.lower() in TIFF_EXTS
311
+ # A tiff is never admitted as a tiff (2026-07-12 ruling): the PNG IS the
312
+ # original from here on, so the collision check, the MANIFEST row, and
313
+ # the returned `source` all name the .png — never the discarded .tif.
314
+ dest_name = f"{src.stem}.png" if is_tiff else src.name
315
+ dest = root / "sources" / category / dest_name
233
316
  if dest.exists():
234
317
  raise IntakeError(
235
- f"sources/ is immutable and {category}/{src.name} already "
318
+ f"sources/ is immutable and {category}/{dest_name} already "
236
319
  "exists — rename the incoming file before admitting it")
237
- dest.parent.mkdir(parents=True, exist_ok=True)
238
- shutil.move(str(src), str(dest))
239
- sha = sha256_of(dest)
240
- rel = f"{category}/{src.name}"
320
+ if is_tiff:
321
+ original_name = src.name
322
+ original_sha = sha256_of(src)
323
+ tiff_to_png(src, dest) # raises before touching dest on
324
+ src.unlink() # multi-frame; conservative refusal
325
+ sha = sha256_of(dest)
326
+ else:
327
+ dest.parent.mkdir(parents=True, exist_ok=True)
328
+ shutil.move(str(src), str(dest))
329
+ sha = sha256_of(dest)
330
+ rel = f"{category}/{dest_name}"
241
331
  manifest_append(root, rel, actor, sha)
242
- return {"source": rel, "sha256": sha, "manifest_row": True}
332
+ result = {"source": rel, "sha256": sha, "manifest_row": True}
333
+ if is_tiff:
334
+ # Ledger-visible honesty: the MANIFEST row only ever names the PNG
335
+ # (the admitted original), so the tiff's identity is carried here
336
+ # for the caller to sign — SKILL.md step 2 logs this `note` via
337
+ # `fusion log noted` right after admit, same run.
338
+ result["converted"] = {
339
+ "from_format": "tiff", "to_format": "png",
340
+ "original_name": original_name, "original_sha256": original_sha,
341
+ }
342
+ result["note"] = (
343
+ f"tiff→png at admit: {original_name} (sha256 {original_sha}) "
344
+ f"→ {dest_name} (sha256 {sha}) — original tiff bytes not "
345
+ "retained (waived per 2026-07-12 ruling: no need for large "
346
+ "tiff files)")
347
+ return result
243
348
 
244
349
 
245
350
  # ── unpack: containers are delivery vehicles, not originals ─────────────
@@ -534,6 +639,13 @@ def _merge_reconcile_fm(existing_fm: dict, seed: dict) -> dict:
534
639
  merged["created"] = seed["created"]
535
640
  merged["source"] = seed["source"]
536
641
  merged["updated"] = TODAY
642
+ # YAML's implicit resolver parses an unquoted date scalar (e.g.
643
+ # `created: 2026-07-10`) as datetime.date, which neither the work-dir
644
+ # manifest.json nor the CLI's JSON envelope can serialize — normalize
645
+ # once, here, right after the merge.
646
+ for key, value in merged.items():
647
+ if isinstance(value, (date, datetime)):
648
+ merged[key] = value.isoformat()
537
649
  return merged
538
650
 
539
651
 
@@ -639,6 +751,11 @@ def link(root: Path, source_rel: str, doc_rel: str) -> dict:
639
751
  return {"source": source_rel, "library": doc_rel}
640
752
 
641
753
 
754
+ def relink(root: Path, source_rel: str, old_doc: str, new_doc: str) -> dict:
755
+ manifest_relink(Path(root), source_rel, old_doc, new_doc)
756
+ return {"source": source_rel, "from": old_doc, "to": new_doc}
757
+
758
+
642
759
  # ── batch: one op-list, validated whole, then moved ──────────────────────
643
760
  #
644
761
  # Schema (references/delivery.md):
@@ -797,6 +914,16 @@ def main(argv=None) -> int:
797
914
  p.add_argument("--source", required=True)
798
915
  p.add_argument("--doc", required=True)
799
916
 
917
+ p = sub.add_parser("relink", help="repoint one value in a MANIFEST "
918
+ "library cell after a document moved")
919
+ p.add_argument("--bucket", required=True)
920
+ p.add_argument("--source", required=True,
921
+ help="path relative to sources/")
922
+ p.add_argument("--from", dest="from_doc", required=True,
923
+ help="current zone-relative doc path in the cell")
924
+ p.add_argument("--to", dest="to_doc", required=True,
925
+ help="new zone-relative doc path (must exist)")
926
+
800
927
  p = sub.add_parser("cleanup", help="delete one work dir")
801
928
  p.add_argument("--run-dir", required=True)
802
929
 
@@ -819,6 +946,9 @@ def main(argv=None) -> int:
819
946
  aurora=args.aurora, reconcile=args.reconcile)
820
947
  elif args.cmd == "link":
821
948
  out = link(Path(args.bucket), args.source, args.doc)
949
+ elif args.cmd == "relink":
950
+ out = relink(Path(args.bucket), args.source,
951
+ args.from_doc, args.to_doc)
822
952
  elif args.cmd == "batch":
823
953
  ops = json.loads(Path(args.ops).read_text(encoding="utf-8"))
824
954
  out = batch(Path(args.bucket), ops, args.actor)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  # /// script
3
3
  # requires-python = ">=3.11"
4
- # dependencies = ["openpyxl>=3.1.0", "pymupdf>=1.24.0"]
4
+ # dependencies = ["openpyxl>=3.1.0", "pymupdf>=1.24.0", "pillow>=10.0.0"]
5
5
  # ///
6
6
  """Generate real legacy-format fixtures for the intake tests. Imported by
7
7
  the test modules; also runnable standalone to eyeball the artifacts."""
@@ -213,11 +213,22 @@ def make_html_page(path: Path):
213
213
  "</body></html>", encoding="utf-8")
214
214
 
215
215
 
216
+ def make_tiff(path: Path, frames: int = 1):
217
+ """A real tiff, single- or multi-frame, deterministic pixels — no
218
+ external tool required, just Pillow."""
219
+ from PIL import Image
220
+ colors = [(200, 30, 30), (30, 200, 30), (30, 30, 200)]
221
+ imgs = [Image.new("RGB", (4, 4), colors[i % len(colors)])
222
+ for i in range(max(frames, 1))]
223
+ imgs[0].save(path, format="TIFF", save_all=frames > 1,
224
+ append_images=imgs[1:])
225
+
226
+
216
227
  if __name__ == "__main__":
217
228
  out = Path("fixtures-preview")
218
229
  out.mkdir(exist_ok=True)
219
230
  make_xlsx(out / "scores.xlsx"); make_csv(out / "inventory.csv")
220
231
  make_text_pdf(out / "audit.pdf"); make_scanned_pdf(out / "scan.pdf")
221
232
  make_docx(out / "procedure.docx"); make_eml(out / "mail.eml")
222
- make_png(out / "photo.png")
233
+ make_png(out / "photo.png"); make_tiff(out / "scan.tiff")
223
234
  print(f"fixtures in {out}/")
@@ -169,6 +169,33 @@ def test_prepare_reconcile_merges_frontmatter(bucket):
169
169
  assert "12500.50" in doc # new content written
170
170
 
171
171
 
172
+ def test_prepare_reconcile_yaml_date_survives_json(bucket):
173
+ # an unquoted `created: 2020-01-01` in the existing doc parses as
174
+ # datetime.date; a non-extractive source (text passthrough) must still
175
+ # serialize the work-dir manifest.json — the merge normalizes dates
176
+ # back to ISO strings
177
+ existing = bucket / "library" / "notes" / "note.md"
178
+ existing.parent.mkdir(parents=True, exist_ok=True)
179
+ existing.write_text(
180
+ "---\n"
181
+ "title: Note (curated)\n"
182
+ "type: note\n"
183
+ "aurora: library\n"
184
+ "source: sources/records/note-old.md\n"
185
+ "created: 2020-01-01\n"
186
+ "---\n\nOld summary.\n\n---\n\nOld body.\n",
187
+ encoding="utf-8")
188
+
189
+ (bucket / "inbox" / "note-v2.md").write_text(
190
+ "New body, revised.\n", encoding="utf-8")
191
+ rec = admit(bucket, "note-v2.md")
192
+ out = convert.prepare(bucket, rec["source"], dest="library/notes",
193
+ slug="note", reconcile=True)
194
+ assert out["reconcile"] is True
195
+ assert out["front_matter_seed"]["created"] == "2020-01-01"
196
+ assert (bucket / out["manifest"]).is_file()
197
+
198
+
172
199
  def test_dest_and_type_overrides(bucket):
173
200
  put_inbox(bucket, "inventory.csv", fx.make_csv)
174
201
  rec = admit(bucket, "inventory.csv", category="gear")
@@ -206,11 +233,77 @@ def test_scanned_pdf_all_pages_rendered(bucket):
206
233
  def test_image_path(bucket):
207
234
  put_inbox(bucket, "photo.png", fx.make_png)
208
235
  rec = admit(bucket, "photo.png")
236
+ assert "converted" not in rec and "note" not in rec # tiff-only fields
237
+ out = convert.prepare(bucket, rec["source"])
238
+ assert out["path"] == "image"
239
+ assert out["pages"] == [{"page": 1, "text": "", "text_chars": 0,
240
+ "needs_vision": True}]
241
+ assert len(out["images"]) == 1
242
+
243
+
244
+ # ── tiff -> png at admit (2026-07-12 ruling: no large tiffs) ─────────────
245
+
246
+ def test_tiff_admits_as_png_with_note(bucket):
247
+ put_inbox(bucket, "scan.tiff", fx.make_tiff)
248
+ rec = admit(bucket, "scan.tiff")
249
+
250
+ # the PNG is the admitted original — not the tiff
251
+ assert rec["source"] == "records/scan.png"
252
+ assert not (bucket / "inbox" / "scan.tiff").exists()
253
+ assert not (bucket / "sources" / "records" / "scan.tiff").exists()
254
+ png_path = bucket / "sources" / "records" / "scan.png"
255
+ assert png_path.is_file()
256
+ assert png_path.read_bytes()[:8] == b"\x89PNG\r\n\x1a\n" # real PNG bytes
257
+ assert rec["sha256"] == convert.sha256_of(png_path)
258
+
259
+ # MANIFEST row names the PNG, keyed to the PNG's own sha256
260
+ manifest = (bucket / "sources" / "MANIFEST.md").read_text(encoding="utf-8")
261
+ row = manifest.strip().splitlines()[-1]
262
+ cells = [c.strip() for c in row.strip("|").split("|")]
263
+ assert cells[0] == "records/scan.png"
264
+ assert cells[3] == rec["sha256"]
265
+
266
+ # the source tiff's identity is carried honestly, for the ledger
267
+ assert rec["converted"]["from_format"] == "tiff"
268
+ assert rec["converted"]["to_format"] == "png"
269
+ assert rec["converted"]["original_name"] == "scan.tiff"
270
+ assert len(rec["converted"]["original_sha256"]) == 64
271
+ assert rec["converted"]["original_sha256"] != rec["sha256"]
272
+ assert "scan.tiff" in rec["note"] and rec["converted"]["original_sha256"] in rec["note"]
273
+ assert "scan.png" in rec["note"] and rec["sha256"] in rec["note"]
274
+
275
+
276
+ def test_tiff_png_flows_through_the_image_route(bucket):
277
+ put_inbox(bucket, "scan.tiff", fx.make_tiff)
278
+ rec = admit(bucket, "scan.tiff")
209
279
  out = convert.prepare(bucket, rec["source"])
280
+ # admitted as a PNG, so Stage 2 sees it exactly like any other image —
281
+ # no tiff-specific branch downstream of admit
210
282
  assert out["path"] == "image"
211
283
  assert out["pages"] == [{"page": 1, "text": "", "text_chars": 0,
212
284
  "needs_vision": True}]
213
285
  assert len(out["images"]) == 1
286
+ assert out["images"][0].endswith(".png")
287
+
288
+
289
+ def test_multiframe_tiff_refused(bucket):
290
+ put_inbox(bucket, "stack.tiff", lambda p: fx.make_tiff(p, frames=3))
291
+ with pytest.raises(convert.IntakeError, match="multi-frame"):
292
+ admit(bucket, "stack.tiff")
293
+ # conservative refusal: nothing moved, nothing registered, nothing
294
+ # half-written into sources/
295
+ assert (bucket / "inbox" / "stack.tiff").is_file()
296
+ assert not (bucket / "sources" / "records").exists()
297
+ manifest = (bucket / "sources" / "MANIFEST.md").read_text(encoding="utf-8")
298
+ assert "stack" not in manifest
299
+
300
+
301
+ def test_tiff_uppercase_extension_also_converts(bucket):
302
+ # case-insensitive suffix match, same as every other extension check
303
+ src = put_inbox(bucket, "SCAN.TIFF", fx.make_tiff)
304
+ rec = admit(bucket, "SCAN.TIFF")
305
+ assert rec["source"] == "records/SCAN.png"
306
+ assert not src.exists()
214
307
 
215
308
 
216
309
  def test_eml_path_extracts_text_and_attachments(bucket):
@@ -723,3 +816,84 @@ def test_batch_rejects_traversal_doc_path(bucket):
723
816
  assert not (bucket / "sources" / "records").exists()
724
817
  manifest_after = (bucket / "sources" / "MANIFEST.md").read_text(encoding="utf-8")
725
818
  assert manifest_after == manifest_before
819
+
820
+
821
+ # ── relink ───────────────────────────────────────────────────────────────
822
+
823
+ def _doc(root, rel):
824
+ p = root / rel
825
+ p.parent.mkdir(parents=True, exist_ok=True)
826
+ p.write_text("---\ntitle: T\ntype: note\naurora: library\n---\n\n"
827
+ "## Summary\n\nS.\n\n---\n\nBody.\n", encoding="utf-8")
828
+ return rel
829
+
830
+
831
+ def test_relink_repoints_single_value(bucket):
832
+ put_inbox(bucket, "deed.xlsx", fx.make_xlsx)
833
+ admit(bucket, "deed.xlsx")
834
+ old = _doc(bucket, "library/records/deed.md")
835
+ convert.link(bucket, "records/deed.xlsx", old)
836
+ new = _doc(bucket, "library/areas/legal/deed.md")
837
+ out = convert.relink(bucket, "records/deed.xlsx", old, new)
838
+ assert out == {"source": "records/deed.xlsx", "from": old, "to": new}
839
+ manifest = (bucket / "sources" / "MANIFEST.md").read_text(encoding="utf-8")
840
+ row = manifest.strip().splitlines()[-1]
841
+ cells = [c.strip() for c in row.strip("|").split("|")]
842
+ assert cells[4] == new
843
+ assert old not in manifest
844
+
845
+
846
+ def test_relink_multi_value_cell_touches_only_the_target(bucket):
847
+ put_inbox(bucket, "deed.xlsx", fx.make_xlsx)
848
+ admit(bucket, "deed.xlsx")
849
+ keep = _doc(bucket, "library/records/summary.md")
850
+ old = _doc(bucket, "library/records/deed.md")
851
+ convert.link(bucket, "records/deed.xlsx", keep)
852
+ convert.link(bucket, "records/deed.xlsx", old)
853
+ new = _doc(bucket, "library/areas/legal/deed.md")
854
+ convert.relink(bucket, "records/deed.xlsx", old, new)
855
+ manifest = (bucket / "sources" / "MANIFEST.md").read_text(encoding="utf-8")
856
+ row = manifest.strip().splitlines()[-1]
857
+ cells = [c.strip() for c in row.strip("|").split("|")]
858
+ assert cells[4] == f"{keep}, {new}"
859
+
860
+
861
+ def test_relink_refusals(bucket):
862
+ put_inbox(bucket, "deed.xlsx", fx.make_xlsx)
863
+ admit(bucket, "deed.xlsx")
864
+ old = _doc(bucket, "library/records/deed.md")
865
+ new = _doc(bucket, "library/areas/legal/deed.md")
866
+ # row exists but cell is empty — old value not present
867
+ with pytest.raises(convert.IntakeError, match="does not carry"):
868
+ convert.relink(bucket, "records/deed.xlsx", old, new)
869
+ convert.link(bucket, "records/deed.xlsx", old)
870
+ # no such source row
871
+ with pytest.raises(convert.IntakeError, match="not in manifest"):
872
+ convert.relink(bucket, "records/ghost.xlsx", old, new)
873
+ # from == to is not a change
874
+ with pytest.raises(convert.IntakeError, match="is a change"):
875
+ convert.relink(bucket, "records/deed.xlsx", old, old)
876
+ # target must exist on disk
877
+ with pytest.raises(convert.IntakeError, match="does not exist on disk"):
878
+ convert.relink(bucket, "records/deed.xlsx", old, "library/nowhere.md")
879
+ # target already linked
880
+ convert.link(bucket, "records/deed.xlsx", new)
881
+ with pytest.raises(convert.IntakeError, match="already carries"):
882
+ convert.relink(bucket, "records/deed.xlsx", old, new)
883
+ # nothing was mutated by any refusal: both values still present, in order
884
+ manifest = (bucket / "sources" / "MANIFEST.md").read_text(encoding="utf-8")
885
+ row = manifest.strip().splitlines()[-1]
886
+ cells = [c.strip() for c in row.strip("|").split("|")]
887
+ assert cells[4] == f"{old}, {new}"
888
+
889
+
890
+ def test_relink_cli(bucket):
891
+ put_inbox(bucket, "deed.xlsx", fx.make_xlsx)
892
+ admit(bucket, "deed.xlsx")
893
+ old = _doc(bucket, "library/records/deed.md")
894
+ convert.link(bucket, "records/deed.xlsx", old)
895
+ new = _doc(bucket, "library/areas/legal/deed.md")
896
+ rc = convert.main(["relink", "--bucket", str(bucket),
897
+ "--source", "records/deed.xlsx",
898
+ "--from", old, "--to", new])
899
+ assert rc == 0
@@ -168,6 +168,26 @@ def test_binary_pair_is_clean_new_not_near_dup(bucket):
168
168
  assert [f["incoming"] for f in result["clean_new"]] == ["img-b.png"]
169
169
 
170
170
 
171
+ def test_tiff_classifies_like_any_other_image_not_refused(bucket):
172
+ # Stage 1 (gate.py) has no extension allowlist — it hashes, names, and
173
+ # shingles whatever is in inbox/, containers aside. A .tiff walks the
174
+ # exact same clean_new / exact_dup path a .png would; the refusal (now
175
+ # gone) lived only in convert.py admit()'s SUPPORTED_EXTS, one layer up.
176
+ tiff_bytes = b"II*\x00" + b"\x00\x01\x02\xff\xfe" * 24 # fake but binary
177
+ (bucket / "inbox" / "family-photo.tiff").write_bytes(tiff_bytes)
178
+ result = run_gate(bucket)
179
+ assert [f["incoming"] for f in result["clean_new"]] == ["family-photo.tiff"]
180
+ assert result["exact_dups"] == [] and result["near_dups"] == []
181
+
182
+ # a byte-identical re-drop is still caught as an exact duplicate —
183
+ # tiff gets the same hash-based dedupe as everything else
184
+ (bucket / "sources" / "photos").mkdir(parents=True, exist_ok=True)
185
+ (bucket / "sources" / "photos" / "family-photo.tiff").write_bytes(tiff_bytes)
186
+ result = run_gate(bucket)
187
+ assert len(result["exact_dups"]) == 1
188
+ assert result["exact_dups"][0]["matched_source"] == "photos/family-photo.tiff"
189
+
190
+
171
191
  def test_inbox_internal_duplicates_detected(bucket):
172
192
  drop(bucket, "a-report.txt", LONG_A)
173
193
  drop(bucket, "copy-of-a-report.txt", LONG_A)
@@ -12,7 +12,13 @@ propose → confirm → execute → sign.
12
12
  2. **Confirm.** The human says yes (or a Delegation explicitly covers
13
13
  it — rare for restructures; cite it).
14
14
  3. **Execute.** Move files; update relative links in affected documents
15
- (grep for the old paths); keep filenames conformant.
15
+ (grep for the old paths); keep filenames conformant. If a moved
16
+ document is named by a MANIFEST `library` cell (it was converted from
17
+ a source), repoint the cell with the intake writer — `MANIFEST.md` is
18
+ single-writer, never hand-edited:
19
+ `uv run <fusion-intake>/scripts/convert.py relink --bucket <root>
20
+ --source <cat>/<file> --from <old-path> --to <new-path>`
21
+ (one call per moved document per source row that names it).
16
22
  4. **Sign.** One ledger entry for the operation:
17
23
  `fusion log restructured "<zone>/<scope>" --note "<the reason>"
18
24
  --bucket <root> --as <you>` — the note is not optional here. Then
@@ -2,6 +2,7 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  import re
5
+ import subprocess
5
6
  import time
6
7
  from dataclasses import dataclass
7
8
  from pathlib import Path
@@ -15,11 +16,19 @@ from .document import AURORAS, FILENAME_RE, MAX_STEM
15
16
  # extension rather than a hard-coded .md.
16
17
  EXPORT_FILENAME_RE = re.compile(r"^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+$")
17
18
 
19
+ # SPEC §11 W6: sealed containers are delivery vehicles (fusion-intake
20
+ # unpacks and discards them at admit) — one never belongs committed.
21
+ CONTAINER_EXTS = (".athena", ".zip")
22
+
23
+ # SPEC §11 W7: GitHub's hard push limit is 100MB; warn a good margin before
24
+ # it, so a bucket never crosses it unpushable between one check and the next.
25
+ MAX_TRACKED_BYTES = 95 * 1024 * 1024
26
+
18
27
 
19
28
  @dataclass
20
29
  class Finding:
21
30
  level: str # "error" | "warning"
22
- code: str # E1..E8, W1..W5 — plus H1..H2 from check_hub (CLI vocabulary, not SPEC)
31
+ code: str # E1..E8, W1..W8 — plus H1..H2 from check_hub (CLI vocabulary, not SPEC)
23
32
  path: str # bucket-relative, "" when bucket-wide
24
33
  message: str
25
34
 
@@ -166,9 +175,87 @@ def _warnings(root: Path) -> list[Finding]:
166
175
  findings += _w2_indexes(root)
167
176
  findings += _w3_w4_documents(root)
168
177
  findings += _w5_untouched_activities(root)
178
+ findings += _w6_committed_containers(root)
179
+ findings += _w7_large_tracked_files(root)
180
+ findings += _w8_summary_only(root)
181
+ return findings
182
+
183
+
184
+ def _tracked_files(root: Path) -> list[str] | None:
185
+ """git-tracked paths, bucket-relative, POSIX-separated.
186
+
187
+ None when `root` isn't a git repo or git is unavailable — the checker
188
+ is a liberal reader (SPEC §0) and W6/W7 simply stay silent rather than
189
+ raise; a bucket without git has no push to protect yet.
190
+ """
191
+ try:
192
+ result = subprocess.run(
193
+ ["git", "ls-files", "-z"], cwd=root,
194
+ capture_output=True, timeout=30,
195
+ )
196
+ except (OSError, subprocess.TimeoutExpired):
197
+ return None
198
+ if result.returncode != 0:
199
+ return None
200
+ text = result.stdout.decode("utf-8", errors="surrogateescape")
201
+ return [p for p in text.split("\0") if p]
202
+
203
+
204
+ def _w6_committed_containers(root: Path) -> list[Finding]:
205
+ findings = []
206
+ for rel in sorted(_tracked_files(root) or ()):
207
+ if Path(rel).suffix.lower() not in CONTAINER_EXTS:
208
+ continue
209
+ if rel.startswith("inbox/"):
210
+ findings.append(Finding(
211
+ "warning", "W6", rel,
212
+ "container committed in inbox/ — a delivery vehicle, not "
213
+ "an original; unpack it and discard it (fusion-intake's "
214
+ "admit route), then remove it from git"))
215
+ else:
216
+ findings.append(Finding(
217
+ "warning", "W6", rel,
218
+ "sealed container committed — its content belongs "
219
+ "unpacked in sources/ + library/, not the archive itself; "
220
+ "remove it from git"))
169
221
  return findings
170
222
 
171
223
 
224
+ def _w7_large_tracked_files(root: Path) -> list[Finding]:
225
+ findings = []
226
+ for rel in sorted(_tracked_files(root) or ()):
227
+ path = root / rel
228
+ if not path.is_file():
229
+ continue
230
+ size = path.stat().st_size
231
+ if size > MAX_TRACKED_BYTES:
232
+ mb = size / (1024 * 1024)
233
+ findings.append(Finding(
234
+ "warning", "W7", rel,
235
+ f"tracked file is {mb:.1f}MB — GitHub's hard limit is "
236
+ "100MB and the bucket becomes unpushable; keep big "
237
+ "binaries in their native home and point to them "
238
+ "(resource:, §4) instead of committing them"))
239
+ return findings
240
+
241
+
242
+ def _w8_summary_only(root: Path) -> list[Finding]:
243
+ # A pointer document (source:/resource: in frontmatter) is exempt —
244
+ # its designed shape IS summary + pointer; the body is the thing it
245
+ # points at, not missing prose.
246
+ return [
247
+ Finding("warning", "W8", f"{zone}/{rel.as_posix()}",
248
+ "document is only a summary — nothing beneath the closing "
249
+ "separator and no source:/resource: pointer; write the "
250
+ "body, point at the thing, or reconsider whether the "
251
+ "document should exist")
252
+ for zone, rel, doc in iter_documents(root)
253
+ if doc.summary_first and doc.summary_only
254
+ and not (doc.frontmatter or {}).get("source")
255
+ and not (doc.frontmatter or {}).get("resource")
256
+ ]
257
+
258
+
172
259
  def _w1_stale_inbox(root: Path) -> list[Finding]:
173
260
  inbox = root / "inbox"
174
261
  if not inbox.is_dir():
@@ -66,6 +66,7 @@ class Document:
66
66
  fm_error: str | None
67
67
  summary_first: bool
68
68
  summary_line: str | None
69
+ summary_only: bool = False
69
70
  links: list[str] = field(default_factory=list)
70
71
 
71
72
  def _get(self, key: str):
@@ -123,6 +124,23 @@ def _summary(body: str) -> tuple[bool, str | None]:
123
124
  return False, first
124
125
 
125
126
 
127
+ def _summary_only(body: str) -> bool:
128
+ """True when the document is ONLY a summary — a summary-first shape
129
+ with nothing but whitespace after the '---' that closes it (§4 wants
130
+ a body below the separator; whether a stub deserves to exist is the
131
+ operator's call, so the checker warns rather than errors: W8)."""
132
+ lines = body.split("\n")
133
+ i = 0
134
+ while i < len(lines) and not lines[i].strip():
135
+ i += 1
136
+ if i == len(lines) or lines[i].strip() != "## Summary":
137
+ return False
138
+ for j in range(i + 1, len(lines)):
139
+ if lines[j].strip() == "---":
140
+ return not "".join(lines[j + 1:]).strip()
141
+ return False
142
+
143
+
126
144
  def _links(body: str) -> list[str]:
127
145
  out = []
128
146
  for target in _LINK_RE.findall(_blank_code(body)):
@@ -151,5 +169,6 @@ def read_document(path: Path) -> Document:
151
169
  fm_error=fm_error,
152
170
  summary_first=summary_first,
153
171
  summary_line=summary_line,
172
+ summary_only=_summary_only(body),
154
173
  links=_links(body),
155
174
  )
@@ -51,6 +51,12 @@ GITATTRIBUTES = (
51
51
  "sources/MANIFEST.md merge=union\n"
52
52
  )
53
53
 
54
+ GITIGNORE = (
55
+ "# delivery vehicles are never committed — fusion pattern (SPEC §2, §11 W6)\n"
56
+ "inbox/*.athena\n"
57
+ "inbox/*.zip\n"
58
+ )
59
+
54
60
 
55
61
  class ScaffoldError(Exception):
56
62
  pass
@@ -96,6 +102,9 @@ def new_bucket(
96
102
  (root / ".gitattributes").write_text(
97
103
  GITATTRIBUTES, encoding="utf-8", newline="\n"
98
104
  )
105
+ (root / ".gitignore").write_text(
106
+ GITIGNORE, encoding="utf-8", newline="\n"
107
+ )
99
108
  ledger.append(root, actor, "created", "BUCKET.md", note="bucket born", at=at)
100
109
  indexer.write_indexes(root, actor=None)
101
110
 
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import subprocess
2
3
  import time
3
4
 
4
5
  from fusion.checker import check
@@ -8,6 +9,20 @@ def warnings(root):
8
9
  return [f for f in check(root) if f.level == "warning"]
9
10
 
10
11
 
12
+ def _git_commit_all(root, message="test commit"):
13
+ """Real git init+add+commit — W6/W7 read the tracked file list, so
14
+ these tests need an actual repo, not just files on disk. Identity is
15
+ passed per-invocation so this works on a machine (or CI runner) with
16
+ no global git user configured."""
17
+ for cmd in (
18
+ ["git", "init", "-q"],
19
+ ["git", "add", "-A"],
20
+ ["git", "-c", "user.email=test@fusion.invalid",
21
+ "-c", "user.name=test", "commit", "-q", "-m", message],
22
+ ):
23
+ subprocess.run(cmd, cwd=root, check=True, capture_output=True)
24
+
25
+
11
26
  def wcodes(root):
12
27
  return {f.code for f in warnings(root)}
13
28
 
@@ -248,6 +263,62 @@ def test_check_hub_dangling_and_drift(tmp_path, monkeypatch):
248
263
  assert "newname" in findings[1].message
249
264
 
250
265
 
266
+ def test_w6_committed_container_in_inbox(make_bucket):
267
+ root = make_bucket()
268
+ (root / "inbox" / "delivery.athena").write_bytes(b"PK\x03\x04stub")
269
+ _git_commit_all(root)
270
+ found = [f for f in warnings(root) if f.code == "W6"]
271
+ assert len(found) == 1
272
+ assert found[0].path == "inbox/delivery.athena"
273
+ assert "delivery vehicle" in found[0].message
274
+ assert "unpack" in found[0].message
275
+
276
+
277
+ def test_w6_committed_container_elsewhere(make_bucket):
278
+ root = make_bucket()
279
+ (root / "output" / "export-package.zip").write_bytes(b"PK\x03\x04stub")
280
+ _git_commit_all(root)
281
+ found = [f for f in warnings(root) if f.code == "W6"]
282
+ assert len(found) == 1
283
+ assert found[0].path == "output/export-package.zip"
284
+ assert "sources/" in found[0].message and "library/" in found[0].message
285
+
286
+
287
+ def test_w6_silent_without_git(make_bucket):
288
+ root = make_bucket()
289
+ (root / "inbox" / "delivery.athena").write_bytes(b"PK\x03\x04stub")
290
+ assert "W6" not in wcodes(root) # no repo yet — liberal reader, no raise
291
+
292
+
293
+ def test_w6_silent_for_untracked_container(make_bucket):
294
+ root = make_bucket()
295
+ _git_commit_all(root) # commits everything currently on disk
296
+ (root / "inbox" / "delivery.athena").write_bytes(b"PK\x03\x04stub")
297
+ assert "W6" not in wcodes(root) # sitting on disk, never `git add`ed
298
+
299
+
300
+ def test_w7_large_tracked_file(make_bucket, tmp_path):
301
+ root = make_bucket()
302
+ big = root / "workbench" / "big-export.bin"
303
+ with open(big, "wb") as fh:
304
+ fh.truncate(96 * 1024 * 1024) # sparse — no 96MB actually written
305
+ _git_commit_all(root)
306
+ found = [f for f in warnings(root) if f.code == "W7"]
307
+ assert len(found) == 1
308
+ assert found[0].path == "workbench/big-export.bin"
309
+ assert "96.0MB" in found[0].message
310
+ assert "100MB" in found[0].message
311
+
312
+
313
+ def test_w7_silent_under_threshold(make_bucket):
314
+ root = make_bucket()
315
+ small = root / "workbench" / "small-export.bin"
316
+ with open(small, "wb") as fh:
317
+ fh.truncate(90 * 1024 * 1024) # under the 95MB bar
318
+ _git_commit_all(root)
319
+ assert "W7" not in wcodes(root)
320
+
321
+
251
322
  def test_check_hub_all_present_is_empty(tmp_path, monkeypatch):
252
323
  from fusion import checker
253
324
  from fusion.scaffold import new_bucket
@@ -255,3 +326,57 @@ def test_check_hub_all_present_is_empty(tmp_path, monkeypatch):
255
326
  monkeypatch.setenv("FUSION_HUB", str(tmp_path / "hub.md"))
256
327
  new_bucket(tmp_path / "here", description="d", actor="test")
257
328
  assert checker.check_hub() == []
329
+
330
+
331
+ SUMMARY_ONLY_DOC = """---
332
+ title: Stub
333
+ type: note
334
+ aurora: library
335
+ ---
336
+
337
+ ## Summary
338
+
339
+ A summary and nothing else.
340
+
341
+ ---
342
+ """
343
+
344
+
345
+ def test_w8_summary_only_document(make_bucket):
346
+ root = make_bucket()
347
+ (root / "library" / "stub.md").write_text(SUMMARY_ONLY_DOC,
348
+ encoding="utf-8")
349
+ found = [f for f in warnings(root) if f.code == "W8"]
350
+ assert [f.path for f in found] == ["library/stub.md"]
351
+ assert "only a summary" in found[0].message
352
+
353
+
354
+ def test_w8_silent_with_a_body(make_bucket):
355
+ root = make_bucket()
356
+ (root / "library" / "real.md").write_text(
357
+ SUMMARY_ONLY_DOC + "\nBody text.\n", encoding="utf-8")
358
+ assert not [f for f in warnings(root) if f.code == "W8"]
359
+
360
+
361
+ def test_w8_silent_when_not_summary_first(make_bucket):
362
+ # a shapeless body is E5's territory — W8 must not double-flag it
363
+ root = make_bucket()
364
+ (root / "library" / "loose.md").write_text(
365
+ "---\ntitle: L\ntype: note\naurora: library\n---\n\nJust prose.\n",
366
+ encoding="utf-8")
367
+ assert not [f for f in warnings(root) if f.code == "W8"]
368
+
369
+
370
+ def test_w8_silent_for_pointer_documents(make_bucket):
371
+ # a converted scan's designed shape IS summary + source: pointer —
372
+ # its body is the source file, not missing prose
373
+ root = make_bucket()
374
+ (root / "library" / "scan.md").write_text(
375
+ SUMMARY_ONLY_DOC.replace(
376
+ "aurora: library", "aurora: library\nsource: sources/records/scan.pdf"),
377
+ encoding="utf-8")
378
+ (root / "library" / "link.md").write_text(
379
+ SUMMARY_ONLY_DOC.replace(
380
+ "aurora: library", "aurora: library\nresource: https://example.com/x"),
381
+ encoding="utf-8")
382
+ assert not [f for f in warnings(root) if f.code == "W8"]
@@ -192,3 +192,18 @@ def test_links_tilde_fence_also_blanked(tmp_path):
192
192
  p = tmp_path / "x.md"
193
193
  p.write_text(_doc(body), encoding="utf-8")
194
194
  assert read_document(p).links == ["real.md"]
195
+
196
+
197
+ def test_summary_only_field(tmp_path):
198
+ p = tmp_path / "stub.md"
199
+ p.write_text("---\ntitle: S\ntype: note\naurora: library\n---\n\n"
200
+ "## Summary\n\nOnly this.\n\n---\n", encoding="utf-8")
201
+ assert read_document(p).summary_only is True
202
+ p2 = tmp_path / "real.md"
203
+ p2.write_text("---\ntitle: S\ntype: note\naurora: library\n---\n\n"
204
+ "## Summary\n\nLine.\n\n---\n\nBody.\n", encoding="utf-8")
205
+ assert read_document(p2).summary_only is False
206
+ p3 = tmp_path / "loose.md"
207
+ p3.write_text("---\ntitle: S\ntype: note\naurora: library\n---\n\nProse.\n",
208
+ encoding="utf-8")
209
+ assert read_document(p3).summary_only is False
@@ -117,3 +117,15 @@ def test_new_bucket_writes_gitattributes(tmp_path):
117
117
  assert "* text=auto eol=lf" in text
118
118
  assert "sources/** -text" in text
119
119
  assert "\r" not in text
120
+
121
+
122
+ def test_new_bucket_writes_gitignore(tmp_path):
123
+ root, _ = new_bucket(tmp_path / "b", description="d", actor="test")
124
+ text = (root / ".gitignore").read_text(encoding="utf-8")
125
+ assert "inbox/*.athena" in text
126
+ assert "inbox/*.zip" in text
127
+ assert "\r" not in text
128
+ # a one-line comment above the patterns, per the delivery-vehicle rule
129
+ lines = [l for l in text.splitlines() if l.strip()]
130
+ assert lines[0].startswith("#")
131
+ assert sum(1 for l in lines if l.startswith("#")) == 1
@@ -13,7 +13,7 @@ wheels = [
13
13
 
14
14
  [[package]]
15
15
  name = "fusion-cli"
16
- version = "1.3.1"
16
+ version = "1.4.1"
17
17
  source = { editable = "." }
18
18
  dependencies = [
19
19
  { name = "pyyaml" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes