Skip to content

Commit 62c2ffb

Browse files
test(journeys): a learner's week, asserted on what they are told
Around 230 tests already covered this feature's units and contracts. Nothing walked a learner's week: publish, read, annotate, pull, fold back, republish. So the suite proved the parts were correct and could not fail because the experience was confusing — which is the gap the owner asked to close. Three model families each planned this independently and agreed on the shape: one journey per provider, as ONE ordered test, at the integration layer, adding nothing at unit level. The arbitration and their three plans are in reviews/2026-09-04-user-harness/. The distinguishing idea, which all three reached separately: **assert on what the learner is TOLD.** Every value here is already proven elsewhere. A publish that writes the right bytes and says nothing is a correct function and a broken experience, and only a test at this level can tell them apart. Twelve numbered beats, numbered the same way in the evidence transcript so a failure names something a human can go and look at. Among them: a dry run must preview AND its listing must equal what the publish then writes; a publish must say where; `pull` must return the learner's own note and never StudyLoop's frontmatter; a missing note must not read as a crash; an unchanged republish must say so and claim nothing written; a fold-in must move the derived progress and render the checkbox. The learner's own `.notes.md` is digested after every beat, so a failure names the step that lost it rather than the fact of loss. The journeys drive the real CLI as subprocesses in a world with a complete environment that inherits nothing. `plan new --activate`, `plan milestone --done` and `plan show --markdown` were measured non-interactive first — two planners named "is plan creation interactive?" as their highest-risk assumption, because seeding through the API would start the journey one step after the learner does. A product gap the harness found, and a validation council named precisely: `WriteOutcome` gains `REPLACED`. A learner whose hand-edited projection was overwritten saw `written Study/Plans/<id>.md` — character for character what a first publish prints — and their words were gone with nothing said. The writer always knew the difference; it compares bytes to decide whether to write at all. That information now reaches the surface as a warning that names the file and points at `.notes.md`. Two findings in my own harness, both caught by reading real output rather than code: evidence transcripts contained `pytest-of-<username>`, an account name in an artefact, so paths are redacted to placeholders; and Rich soft-wrapped absolute paths across lines, defeating that redaction in two halves, so the child's COLUMNS is pinned. Screenshots: `scripts/capture-vault-screenshots.py` renders the published notes for reading, from a hermetic world, publishing through the real CLI. It is deliberately NOT a picture of Obsidian and says so in its own pixels. One planner proposed opening the temp vault through an `obsidian://` URI; rejected, because registering a throwaway vault in the switcher of a tool someone uses daily is an unverified side effect on a real environment and no documentation image is worth it. A real-app glance lives in the live suite instead: it never launches Obsidian, skips when it is closed, and FAILS when it is open on a vault that is not allow-listed.
1 parent 61e1770 commit 62c2ffb

14 files changed

Lines changed: 2320 additions & 4 deletions

‎Justfile‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ release-consistency:
154154
prepare-release version:
155155
uv run python scripts/prepare-release.py {{version}}
156156

157+
# The user-representative journeys: the real CLI driven through a learner's week in
158+
# a hermetic world. Default-on (they run in `just test`), so this recipe is only for
159+
# running them alone while iterating.
160+
journeys:
161+
uv run --group dev pytest packages/studyloop/tests/journeys/ -v
162+
163+
# Publishable pictures of the notes StudyLoop writes. Rendered for reading and
164+
# labelled in their own pixels as NOT being Obsidian -- see the script's docstring
165+
# for why a screenshot of the app itself is a separate, opt-in thing.
166+
vault-screenshots out:
167+
uv run python scripts/capture-vault-screenshots.py --out {{out}}
168+
157169
# The two opt-in second-brain checks against real products. Neither runs in
158170
# `preflight`, `release-check` or CI: one writes into a real Obsidian vault, the
159171
# other signs in to a real xTiles account. Both refuse to run without an explicit

‎packages/studyloop/src/studyloop/second_brain/obsidian.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,22 @@ def _install(
181181
atomicity live, so anything that wrote a note some other way would be a
182182
second place for those rules to be forgotten.
183183
"""
184-
return write_projection(target, rendered, identity), ()
184+
outcome = write_projection(target, rendered, identity)
185+
if outcome is WriteOutcome.REPLACED:
186+
# Named, and phrased as what happened to THEIR text rather than as what
187+
# StudyLoop did. "written" alone was indistinguishable from a first
188+
# publish, which is how a learner lost an edit without being told.
189+
return outcome, (
190+
f"replaced your edits in '{target.relative}' — a projection is "
191+
"regenerated from the plan, so write beside it in "
192+
f"'{target.relative.removesuffix('.md')}.notes.md' instead.",
193+
)
194+
return outcome, ()
185195

186196
def _bucket(
187197
self, outcome: WriteOutcome, target: VaultTarget
188198
) -> tuple[tuple[str, ...], tuple[str, ...]]:
189-
if outcome is WriteOutcome.WRITTEN:
199+
if outcome in {WriteOutcome.WRITTEN, WriteOutcome.REPLACED}:
190200
return (target.relative,), ()
191201
return (), (target.relative,)
192202

‎packages/studyloop/src/studyloop/second_brain/obsidian_writer.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,18 @@ class WriteOutcome(Enum):
6363
``UNCHANGED`` is a first-class outcome rather than a silent no-op because the
6464
CLI reports it: a learner republishing at every wind-down should see that
6565
nothing needed rewriting.
66+
67+
``REPLACED`` exists for the same reason one level up. The writer always knew the
68+
difference between creating a note and overwriting one whose bytes had drifted --
69+
it compares them to decide whether to write at all -- but it reported both as
70+
``WRITTEN``. So a learner who had typed into a projection saw the identical
71+
success line as someone publishing for the first time, and their words were gone
72+
with nothing said. A validation council found that by reading the journey
73+
evidence; the information was one frame below the surface that needed it.
6674
"""
6775

6876
WRITTEN = "written"
77+
REPLACED = "replaced"
6978
UNCHANGED = "unchanged"
7079

7180

@@ -307,6 +316,7 @@ def write_projection(
307316

308317
existing_text = read_text_if_present(path)
309318
identity_before = _file_identity(path)
319+
was_replaced = False
310320

311321
if existing_text is not None:
312322
if create_only:
@@ -322,6 +332,9 @@ def write_projection(
322332
if existing_text == rendered:
323333
logger.debug("second brain: %s is already current", target.relative)
324334
return WriteOutcome.UNCHANGED
335+
# Owned, present, and different: the learner has edited this note since
336+
# StudyLoop wrote it. Recorded so the caller can say so.
337+
was_replaced = True
325338

326339
path.parent.mkdir(parents=True, exist_ok=True)
327340

@@ -380,7 +393,7 @@ def write_projection(
380393
raise SecondBrainError(
381394
f"Could not write '{target.relative}': {exc}. The existing note was left untouched."
382395
) from exc
383-
return WriteOutcome.WRITTEN
396+
return WriteOutcome.REPLACED if was_replaced else WriteOutcome.WRITTEN
384397

385398

386399
def read_user_note(target: VaultTarget) -> str | None:

‎packages/studyloop/tests/journeys/__init__.py‎

Whitespace-only changes.

0 commit comments

Comments
 (0)