Skip to content

Imports: each open of a workspace rewrites its unchanged ATIF and OpenTelemetry jobs, so they are parsed again #259

Description

@harenome

Priority

low. The cause is in the backend (app/nullius/importers/), which the form rates high. The pages show the same data, and only the time grows. That argues for low. A workspace with many imported traces parses all of them again at each open.

Components

  • app/nullius (backend)
  • app/web (routes)
  • templates and static files
  • docs and the site
  • catalogue (benchmarks, agents, capabilities)
  • the standard (ports, kits, relay, runs)
  • CI, workflows and skills

Today

shared.open_workspace (app/web/shared.py, line 319) converts every foreign root again through _import_roots (line 301). That happens when a workspace is opened from the menu, at a restart, after a rename of the open workspace and after a root is added. The ATIF importer then writes the job's result.json and config.json and each trial's result.json again, and it copies each trajectory.json again (app/nullius/importers/atif.py, lines 319, 324, 349 and 362). It does this when the source has not changed. By reading, the OpenTelemetry importer does the same (app/nullius/importers/otel.py, lines 143 and 215).

The parse cache keys a job by the size and mtime of these files (workspace._signatures, app/nullius/workspace.py, lines 291-318). New mtimes make workspace.load_job parse the job again.

.claude/rules/traces.md allows the importer to rewrite its derived root freely. This issue asks only that it skips the write when nothing changed.

A test converts one ATIF document, reads the job, converts it again as a second open does, and reads it again. On main (bdcf918), in a python:3.12 container, two runs give:

AssertionError: Tuples differ: (['config.json', 'result.json', 'run-1/result.json'], False) != ([], True)

The three files have new mtimes, and the second read is not from the cache.

Wanted

A second open over an unchanged source writes nothing into imported/, and the job comes from the parse cache. A changed or new source document is converted as today. A trial whose source is gone is removed as today.

The test, as it could go in app/tests/test_import_unchanged_source.py:

"""Opening a workspace again over an unchanged ATIF source leaves the
converted job as it was, so its cached parse is used."""
from __future__ import annotations

import os
import shutil
import tempfile
import time
import unittest
from pathlib import Path

from nullius import importers, workspace
from tests.harnesses.test_atif import minimal, write_doc


def open_again(root, imports):
    """What shared._import_roots does for a root on each open_workspace."""
    module = importers.detect(root)
    return [d for tree in importers.trees(module, root) for d in module.convert(tree, imports)]


class UnchangedSource(unittest.TestCase):
    def test_a_second_open_writes_nothing_and_parses_nothing(self):
        tmp = Path(tempfile.mkdtemp(prefix="nullius-import-"))
        self.addCleanup(shutil.rmtree, tmp, True)
        src = tmp / "src"
        write_doc(src, "run-1.json", minimal())
        ws = workspace.create(str(tmp / "workspaces"), [str(src)], "w")
        [job_dir] = open_again(str(src), ws.imports_dir)
        files = [os.path.join(job_dir, "result.json"), os.path.join(job_dir, "config.json")]
        files += [os.path.join(job_dir, t, "result.json") for t in os.listdir(job_dir) if os.path.isdir(os.path.join(job_dir, t))]
        before = {f: os.stat(f).st_mtime_ns for f in files}
        _, cached = workspace.load_job(ws, job_dir)
        self.assertFalse(cached)                                  # the first read parses
        time.sleep(0.05)
        open_again(str(src), ws.imports_dir)                      # the workspace opened again; the source unchanged
        moved = sorted(os.path.relpath(f, job_dir) for f in files if os.stat(f).st_mtime_ns != before[f])
        _, cached = workspace.load_job(ws, job_dir)
        self.assertEqual((moved, cached), ([], True))


if __name__ == "__main__":
    unittest.main()

From app/, run python3 -m unittest tests.test_import_unchanged_source.

Acceptance

  • The ATIF and OpenTelemetry importers write a file only when its new content differs from the file on disk (for example, compare the bytes, or the source's sha256 that source_document keeps already).
  • An unchanged source leaves the mtimes of the converted job as they were, and load_job returns it from the cache.
  • A changed source document is still converted, and its job is parsed again.
  • The test above is added and passes.

Dependencies and related

Activity

  1. added
    enhancementNew feature or request
    P3When convenient: wording, layout, tests
    on Nov 20, 2026
  2. added theissue type on Nov 20, 2026
  3. added a commit that references this issue on Nov 20, 2026
    872e60a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3When convenient: wording, layout, testsenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions