Skip to content

Commit 7a11934

Browse files
test(second-brain): the live round trip files its evidence only after cleanup
The evidence bundle was written at the validation step, before the `finally` that removes the notes. A run that created and validated correctly and then failed to clean up left behind a bundle describing a clean pass -- and cleanup is the half of this test that protects a real vault, so that is the half whose failure most needed to be visible. The bundle now says what was validated and that the removal was asserted, and `tree.txt` says in its first two lines that it lists a state which no longer exists. Reading a listing of notes in a vault and not knowing whether they are still there is not evidence. Also drops "confirm the real CLI grammar" from the probe plan's mission: there is no CLI grammar to confirm any more, and the seeded text ends up quoted in the documentation samples. Re-run against ~/Obsidian/StudyLoop-Live-Test: 2 passed, vault left containing only .obsidian.
1 parent fe291ed commit 7a11934

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

‎packages/studyloop/tests/test_obsidian_live.py‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _seed(records: int = 2) -> StudyPlan:
118118
status="active",
119119
topics=["python"],
120120
mission=Mission(
121-
why="Confirm the real CLI grammar and the real write path against a running app.",
121+
why="Confirm the real write path against a real vault, end to end.",
122122
success=["A projection appears in the vault and republishing is a no-op"],
123123
constraints=["Throwaway vault only"],
124124
out_of_scope=["The learner's real vault"],
@@ -237,7 +237,17 @@ def test_full_round_trip_create_validate_remove(
237237
finally:
238238
assert intruder.read_bytes() == mine_before
239239

240-
# -- documentation evidence -----------------------------------------
240+
# -- collect the documentation evidence, write it after cleanup ------
241+
lines.append("## Validated on disk")
242+
lines.append("")
243+
lines.append("- every created file carries the `studyloop:` ownership marker")
244+
lines.append("- the plan projection contains the title, the mission and `LR-0001`")
245+
lines.append("- `Today.md` contains all three headings")
246+
lines.append("- republishing wrote nothing and left every mtime unchanged")
247+
lines.append(
248+
"- a hand-written `Study/Plans/live-obsidian-mine.md` was refused, byte-for-byte intact"
249+
)
250+
lines.append("")
241251
lines.append("## Rendered plan projection")
242252
lines.append("")
243253
lines.append("```markdown")
@@ -250,15 +260,13 @@ def test_full_round_trip_create_validate_remove(
250260
lines.append(today_note.read_text(encoding="utf-8").rstrip())
251261
lines.append("```")
252262
lines.append("")
253-
(evidence_dir / "round-trip.md").write_text("\n".join(lines) + "\n", encoding="utf-8")
254-
(evidence_dir / "tree.txt").write_text(
263+
tree_before_removal = (
255264
"\n".join(
256265
sorted(
257266
p.relative_to(live_vault).as_posix() for p in (live_vault / "Study").rglob("*")
258267
)
259268
)
260-
+ "\n",
261-
encoding="utf-8",
269+
+ "\n"
262270
)
263271
finally:
264272
# -- remove ---------------------------------------------------------
@@ -268,6 +276,24 @@ def test_full_round_trip_create_validate_remove(
268276
assert not path.exists(), f"{path} survived cleanup"
269277
assert not (live_vault / "Study" / "Learning Records" / PLAN_ID).exists()
270278

279+
# Written only now, so evidence exists for a run that completed the WHOLE
280+
# round trip. A bundle written before cleanup would have described a passing
281+
# create-and-validate even when removal then failed, which is the half of
282+
# this test that protects a real vault.
283+
lines.append("## Removed")
284+
lines.append("")
285+
lines.append("Every file above was deleted and its absence asserted; the empty")
286+
lines.append("`Study/Learning Records/<plan>/` directory was pruned. The vault is as")
287+
lines.append("the run found it.")
288+
lines.append("")
289+
(evidence_dir / "round-trip.md").write_text("\n".join(lines) + "\n", encoding="utf-8")
290+
(evidence_dir / "tree.txt").write_text(
291+
"# Vault contents at the validation step, BEFORE the round trip removed them.\n"
292+
"# Nothing here survives the test; see the Removed section of round-trip.md.\n"
293+
+ tree_before_removal,
294+
encoding="utf-8",
295+
)
296+
271297

272298
def _seed_second_plan() -> StudyPlan:
273299
plan = StudyPlan(

0 commit comments

Comments
 (0)