Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ project is tagged; between releases, entries are dated and `main` moves.
## [2.0.3] — 2026-10-19

Patch release: the Windows suite goes green. The v2.0.2 install path was
correct on POSIX, but Windows exposed two failures the matrix caught after
the release was tagged: `--help` crashed under the cp1252 pipe encoding, and
a test tried to execute the launcher as a native program, which Windows
cannot do.
correct on POSIX, but the matrix — and the main-branch run that followed —
exposed three failures: `--help` crashed under the cp1252 pipe encoding, a
test tried to execute the launcher as a native program, which Windows cannot
do, and the bundle check trusted a whole-second timestamp cache instead of
the bytes.

### Fixed

Expand All @@ -23,6 +24,11 @@ cannot do.
stdout and stderr where the stream supports it, so help text, JSON with
`ensure_ascii=False`, and error messages survive a redirect on a
non-UTF-8 Windows console.
- **The bundle check compares bytes, not cached metadata.** `filecmp.cmp`
keys its verdict on `int(st_mtime)`, so a drift check that followed a
same-second rewrite could report a file stale that had just been synced.
`scripts/sync_engine.py` now compares contents directly, and a regression
test pins the same-second case with a forced mtime.
- **The bare-launcher test is POSIX-only.** Windows has no exec bit and
`CreateProcess` cannot run a `.py` file without a registered association.
The portable spelling — `python3 <skill-base-dir>/scripts/executor` —
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ flowchart TD
| Path | What it is |
|---|---|
| `engine/executor/` | the engine source: `cli.py`, `engine.py`, `schemas.py`, `paths.py`, `store.py`, `views.py`, `policy.py` |
| `engine/tests/` | the suite (741 tests), including the tree-walking contract tests |
| `engine/tests/` | the suite (742 tests), including the tree-walking contract tests |
| `skills/executor/` | the router skill, its prompt templates, the references, and the engine that ships with it |
| `skills/executor/scripts/executor` | the launcher; resolves `scripts/lib/executor/` relative to itself |
| `skills/executor/scripts/lib/executor/` | the installed engine — a generated mirror of `engine/executor/` |
Expand Down
22 changes: 22 additions & 0 deletions engine/tests/test_engine_ships_with_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import subprocess
import sys
import tempfile
import time
import unittest
from contextlib import redirect_stderr, redirect_stdout
from pathlib import Path
Expand Down Expand Up @@ -88,6 +89,27 @@ def test_sync_rewrites_a_stale_bundle_and_drops_orphans(self):
self.assertEqual((dst / "a.py").read_text(encoding="utf-8"),
"A = 1\n")

def test_drift_ignores_cached_file_timestamps(self):
"""A same-second rewrite must be seen: a metadata-keyed comparison
once let a fresh write read as stale."""
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
src, dst = root / "engine", root / "bundle"
for d in (src, dst):
d.mkdir()
(src / "a.py").write_text("A = 1\n", encoding="utf-8")
(dst / "a.py").write_text("A = 2\n", encoding="utf-8")
stamp = int(time.time())
os.utime(src / "a.py", (stamp, stamp))
os.utime(dst / "a.py", (stamp, stamp))
with mock.patch.object(sync_engine, "SOURCE", src), \
unittest.mock.patch.object(sync_engine, "BUNDLE", dst):
self.assertEqual(sync_engine.drift(),
["stale in the bundle: a.py"])
sync_engine.sync()
os.utime(dst / "a.py", (stamp, stamp))
self.assertEqual(sync_engine.drift(), [])


class SyncEngineCli(unittest.TestCase):
"""`sync_engine.py` is the only writer of the bundle, so its own exit
Expand Down
12 changes: 9 additions & 3 deletions scripts/sync_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from __future__ import annotations

import argparse
import filecmp
import sys
from pathlib import Path

Expand All @@ -34,6 +33,13 @@ def modules(directory: Path) -> dict[str, Path]:
return {p.name: p for p in sorted(directory.glob("*.py")) if p.is_file()}


def same(a: Path, b: Path) -> bool:
"""Content equality, by bytes. `filecmp.cmp(shallow=False)` caches its
verdict on whole-second mtimes, so a check that follows a same-second
rewrite can report the pre-rewrite answer."""
return a.read_bytes() == b.read_bytes()


def drift() -> list[str]:
"""Every way the bundle disagrees with the source, as readable lines."""
src, dst = modules(SOURCE), modules(BUNDLE)
Expand All @@ -43,7 +49,7 @@ def drift() -> list[str]:
for name in sorted(set(dst) - set(src))]
problems += [f"stale in the bundle: {name}"
for name in sorted(set(src) & set(dst))
if not filecmp.cmp(src[name], dst[name], shallow=False)]
if not same(src[name], dst[name])]
return problems


Expand All @@ -55,7 +61,7 @@ def sync() -> list[str]:
changed = []
for name in sorted(src):
target = BUNDLE / name
if name in dst and filecmp.cmp(src[name], target, shallow=False):
if name in dst and same(src[name], target):
continue
target.write_bytes(src[name].read_bytes())
changed.append(name)
Expand Down
Loading