Skip to content

The OSINT investigator's workbench. One case, one folder, every tool. Local-first: your media and your investigations never leave your machine.

JavaScript

Follow the case folder's hidden directories, and verify a moved workspace

OsintMeThatb8eb6c53a502
diff --git a/frontend/src/lib/chain.test.js b/frontend/src/lib/chain.test.js
index db2985c..0283754 100644
--- a/frontend/src/lib/chain.test.js
+++ b/frontend/src/lib/chain.test.js
@@ -17,7 +17,7 @@ const link = (from, to, type = 'derived-from') => ({ id: `l_${from}${to}`, from,
const entities = [
ent('video', 'media', { path: 'media/v.mp4', sha256: 'abc', source_url: 'https://x/1' }),
ent('frame', 'media', { path: 'media/f.png' }),
- ent('proof', 'proof', { spec: 'proofs/p.json', path: 'proofs/p.png' }),
+ ent('proof', 'proof', { spec: 'proofs/.meta/p.json', path: 'proofs/p.png' }),
ent('post', 'post', { draft: 'exports/d.json' }),
ent('session', 'inspect-session', { spec: 'inspect/s.json' }),
];
diff --git a/frontend/src/lib/naming.js b/frontend/src/lib/naming.js
index 1f28f90..a5ba421 100644
--- a/frontend/src/lib/naming.js
+++ b/frontend/src/lib/naming.js
@@ -71,10 +71,13 @@ export function isDefaultName(name, kind) {
}
// Where each kind's spec lives, and the entity attribute that points at it.
+// These mirror `layout.session_rel` / `proof_spec_rel` / `draft_rel` — the
+// specs are hidden inside the case folder, so a spec path is not the visible
+// path of the work it describes (a proof's own file is `proofs/<name>.png`).
const SPEC_ATTR = {
- session: { dir: 'inspect/', attr: 'spec' },
- proof: { dir: 'proofs/', attr: 'spec' },
- draft: { dir: 'exports/', attr: 'draft' },
+ session: { dir: '.inspect/', attr: 'spec' },
+ proof: { dir: 'proofs/.meta/', attr: 'spec' },
+ draft: { dir: '.drafts/', attr: 'draft' },
};
/** The filed entities of `kind`, read off a case's entity list. */
@@ -86,6 +89,16 @@ export function savedEntities(entities, kind) {
});
}
+/** The name one filed entity is saved under, or '' if it carries no spec.
+ * This is the name the tools reopen by, so it has to follow the spec's folder
+ * wherever the case layout moves it. */
+export function specStem(entity, kind) {
+ const { dir, attr } = SPEC_ATTR[kind];
+ const spec = entity?.attrs?.[attr];
+ if (typeof spec !== 'string' || !spec.startsWith(dir) || !spec.endsWith('.json')) return '';
+ return spec.slice(dir.length, -5);
+}
+
/** Slugs of everything of `kind` already saved — the collision set. */
export function savedSlugs(entities, kind) {
const { dir, attr } = SPEC_ATTR[kind];
diff --git a/frontend/src/lib/naming.test.js b/frontend/src/lib/naming.test.js
index 7173ad6..9b8111f 100644
--- a/frontend/src/lib/naming.test.js
+++ b/frontend/src/lib/naming.test.js
@@ -71,10 +71,10 @@ describe('isDefaultName — an assigned name is not a description', () => {
describe('saved-item case queries', () => {
const entities = [
- { label: 'Rooftop', attrs: { spec: 'proofs/rooftop.json' } },
- { label: 'Bridge', attrs: { spec: 'proofs/bridge.json' } },
- { label: 'Angle', attrs: { spec: 'inspect/angle.json' } },
- { label: 'Thread', attrs: { draft: 'exports/thread.json' } },
+ { label: 'Rooftop', attrs: { spec: 'proofs/.meta/rooftop.json' } },
+ { label: 'Bridge', attrs: { spec: 'proofs/.meta/bridge.json' } },
+ { label: 'Angle', attrs: { spec: '.inspect/angle.json' } },
+ { label: 'Thread', attrs: { draft: '.drafts/thread.json' } },
{ label: 'A place', attrs: { spec: 'places/x.json' } }, // filed, but not one of ours
{ label: 'No spec' },
];
@@ -104,8 +104,8 @@ describe('saved-item case queries', () => {
it('numbers a fresh name past what the case already holds', () => {
const saved = [
- { label: 'Proof 1', attrs: { spec: 'proofs/proof-1.json' } },
- { label: 'Rooftop', attrs: { spec: 'proofs/rooftop.json' } },
+ { label: 'Proof 1', attrs: { spec: 'proofs/.meta/proof-1.json' } },
+ { label: 'Rooftop', attrs: { spec: 'proofs/.meta/rooftop.json' } },
];
expect(nextName('proof', savedTitles(saved, 'proof'))).toBe('Proof 2');
});
diff --git a/src/azimut/engine/workspacemove.py b/src/azimut/engine/workspacemove.py
index b852a1b..c725b95 100644
--- a/src/azimut/engine/workspacemove.py
+++ b/src/azimut/engine/workspacemove.py
@@ -20,6 +20,7 @@ the workspace" — that is `config`'s pointer file, and writing it is the switch
from __future__ import annotations
+import hashlib
import logging
import os
import shutil
@@ -81,6 +82,10 @@ SKIPPED_DIRS = ("cache",)
#: process has locked a portion of the file".
SKIPPED_FILES = (workspacelock.LOCK_NAME,)
+#: One megabyte keeps hashing memory flat while avoiding tiny reads on a large
+#: media workspace.
+VERIFY_CHUNK_SIZE = 1024 * 1024
+
# -- comparing two paths on three operating systems ---------------------------
@@ -589,9 +594,26 @@ def _step_copy(move: Move, staging: Path) -> None:
move.copied_bytes += destination.stat().st_size
+def _file_identity(path: Path) -> tuple[int, int, int, int, int]:
+ stat = path.stat()
+ return stat.st_dev, stat.st_ino, stat.st_size, stat.st_mtime_ns, stat.st_ctime_ns
+
+
+def _verified_digest(path: Path) -> tuple[bytes, tuple[int, int, int, int, int]]:
+ """SHA-256 plus the identity that stayed stable for the whole read."""
+ before = _file_identity(path)
+ digest = hashlib.sha256()
+ with path.open("rb") as handle:
+ for chunk in iter(lambda: handle.read(VERIFY_CHUNK_SIZE), b""):
+ digest.update(chunk)
+ after = _file_identity(path)
+ if after != before:
+ raise MoveError(f"{path.name} changed while it was being verified")
+ return digest.digest(), before
+
+
def _step_verify(move: Move, staging: Path) -> None:
- """Every file, by name and by size. Until this passes the old folder is
- still the workspace, and nothing has been switched."""
+ """Every file, by name, size and content before the pointer switches."""
move.step = "verifying"
for source_dir in _copyable_dirs(move.source):
if not (staging / source_dir.relative_to(move.source)).is_dir():
@@ -605,6 +627,17 @@ def _step_verify(move: Move, staging: Path) -> None:
raise MoveError(f"the copy is missing {source_file.name}") from exc
if expected != actual:
raise MoveError(f"the copy of {source_file.name} is a different size")
+ try:
+ expected_digest, source_identity = _verified_digest(source_file)
+ actual_digest, copied_identity = _verified_digest(copied)
+ if _file_identity(source_file) != source_identity:
+ raise MoveError(f"{source_file.name} changed while it was being verified")
+ if _file_identity(copied) != copied_identity:
+ raise MoveError(f"{copied.name} changed while it was being verified")
+ except OSError as exc:
+ raise MoveError(f"the copy could not verify {source_file.name}") from exc
+ if expected_digest != actual_digest:
+ raise MoveError(f"the copy of {source_file.name} has different contents")
def _step_switch(move: Move, staging: Path) -> None:
diff --git a/tests/test_release_gate.py b/tests/test_release_gate.py
index 2a59447..fe5e857 100644
--- a/tests/test_release_gate.py
+++ b/tests/test_release_gate.py
@@ -148,6 +148,20 @@ def test_wheel_bundles_the_frontend_and_leaves_dev_tooling_out():
assert not (root / "src" / "azimut" / "bigcase.py").exists()
+def test_pdf_font_licenses_are_complete_and_packaged():
+ root = Path(__file__).resolve().parent.parent
+ fonts = root / "src" / "azimut" / "assets" / "fonts"
+ apache = (fonts / "APACHE-2.0.txt").read_text(encoding="utf-8")
+ assert "TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION" in apache
+ assert "END OF TERMS AND CONDITIONS" in apache
+ assert len(apache.splitlines()) >= 190
+ for name in ("OFL.txt", "BITSTREAM-VERA.txt", "README.md"):
+ assert (fonts / name).is_file()
+
+ spec = (root / "packaging" / "azimut.spec").read_text(encoding="utf-8")
+ assert 'collect_data_files("azimut")' in spec
+
+
def test_storage_and_jobs_add_no_new_runtime_dependency():
"""The store, the durable queue and the thumbnail worker stay on the standard
library plus deps already declared — nothing that would need a new wheel on
@@ -214,6 +228,12 @@ def test_release_tooling_is_bounded_and_built_from_the_lock():
assert "--no-editable" in workflow
assert "uv run python" not in workflow
assert "body_path: docs/RELEASE_NOTES.md" in workflow
+ for font_asset in (
+ "azimut/assets/fonts/APACHE-2.0.txt",
+ "azimut/assets/fonts/OFL.txt",
+ "azimut/assets/fonts/BITSTREAM-VERA.txt",
+ ):
+ assert font_asset in workflow
# A guard job runs before anything builds: it checks the pushed tag equals
# __version__ and runs the version-parity gate the release used to skip, so
# a stale version can never ship again (the 0.2.2 false-update-nag bug).
@@ -227,6 +247,24 @@ def test_release_tooling_is_bounded_and_built_from_the_lock():
assert (root / "docs" / "RELEASE_NOTES.md").is_file()
+def test_current_settings_docs_name_the_current_sections():
+ root = Path(__file__).resolve().parent.parent
+ current = [
+ root / "docs" / "SPEC.md",
+ root / "docs" / "UI.md",
+ root / "src" / "azimut" / "config.py",
+ root / "src" / "azimut" / "api" / "settings.py",
+ root / "src" / "azimut" / "engine" / "coords.py",
+ root / "src" / "azimut" / "engine" / "diagnostics.py",
+ root / "src" / "azimut" / "engine" / "satellite.py",
+ root / "frontend" / "src" / "components" / "WorkspaceFolder.svelte",
+ root / "frontend" / "src" / "tools" / "Settings.svelte",
+ ]
+ text = "\n".join(path.read_text(encoding="utf-8") for path in current)
+ for stale in ("Settings → Preferences", "About tab", "Preferences tab"):
+ assert stale not in text
+
+
def test_release_binary_runs_the_application_smoke_test():
root = Path(__file__).resolve().parent.parent
workflow = (root / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8")
diff --git a/tests/test_workspace_move.py b/tests/test_workspace_move.py
index 4a92432..0ac4ba1 100644
--- a/tests/test_workspace_move.py
+++ b/tests/test_workspace_move.py
@@ -418,6 +418,41 @@ def test_there_is_nothing_to_discard_before_a_move(workspace):
workspacemove.discard_old()
+def test_verify_refuses_same_size_content_damage(workspace, tmp_path):
+ source = workspace / "evidence.bin"
+ source.write_bytes(b"trusted evidence")
+ move = workspacemove.Move(source=workspace, root=tmp_path / "moved")
+ staging = tmp_path / "moved.azimut-incoming"
+ workspacemove._step_copy(move, staging)
+ (staging / "evidence.bin").write_bytes(b"altered evidence")
+
+ with pytest.raises(MoveError, match="different contents"):
+ workspacemove._step_verify(move, staging)
+
+
+def test_verify_hashes_files_larger_than_one_chunk(workspace, tmp_path):
+ (workspace / "large.bin").write_bytes(
+ b"a" * (workspacemove.VERIFY_CHUNK_SIZE + 37)
+ )
+ move = workspacemove.Move(source=workspace, root=tmp_path / "moved")
+ staging = tmp_path / "moved.azimut-incoming"
+ workspacemove._step_copy(move, staging)
+
+ workspacemove._step_verify(move, staging)
+
+
+def test_digest_refuses_a_file_that_changes_while_reading(tmp_path, monkeypatch):
+ path = tmp_path / "moving.bin"
+ path.write_bytes(b"content")
+ identity = workspacemove._file_identity(path)
+ changed = (*identity[:-1], identity[-1] + 1)
+ identities = iter((identity, changed))
+ monkeypatch.setattr(workspacemove, "_file_identity", lambda _path: next(identities))
+
+ with pytest.raises(MoveError, match="changed while it was being verified"):
+ workspacemove._verified_digest(path)
+
+
# -- killed part way through ---------------------------------------------------
#
# The steps are driven by hand here rather than through the worker thread, so a