From bb6eacb101352a26ece000b2de6c12d2e063ad96 Mon Sep 17 00:00:00 2001 From: Daniel Rossier Date: Thu, 26 Nov 2026 21:12:15 +0100 Subject: [PATCH] Keep the image's index in a volume, and name every bound standard chromadb opens the image's index read-write, and overlayfs then copied the whole database, about 25 GB, into every new container: tens of seconds at each start on a busy disk, long enough for chromadb to give up with "pool timed out while waiting for an open connection", and the disk space of a second index for as long as the container ran. The launcher now mounts it from a named volume, spear-index-, which Docker fills from the image once; later starts reuse it, and the volumes of earlier images are removed when nothing uses them. The precedence guard's note named only the active standard ("No requirement of ARM-DDI0487 M.c is stated here") over an answer that cited a companion throughout; it now names every bound standard. --- client/normative/normative_precedence.py | 20 ++++++++++++++++---- client/tests/test_normative_precedence.py | 16 ++++++++++++++++ scripts/docker/spear | 23 +++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/client/normative/normative_precedence.py b/client/normative/normative_precedence.py index c0569fa..3e9625c 100644 --- a/client/normative/normative_precedence.py +++ b/client/normative/normative_precedence.py @@ -266,10 +266,22 @@ def _sentences(text): if part.strip()] -def _replacement(ledger, standard_id="", revision=""): +def _names(standard_id="", revision="", binding=None): + """The bound standards, the active one first, for a reader.""" + names = [" ".join(part for part in (standard_id, revision) if part)] + + if isinstance(binding, dict): + names += [" ".join(str(item.get(key) or "") for key in ("standard_id", "revision")).strip() + for item in binding.get("companions") or () if isinstance(item, dict)] + + names = [name for name in names if name] + + return " or ".join(names) or "the bound standard" + + +def _replacement(ledger, standard_id="", revision="", binding=None): """What is put in place of a requirement nothing retrieved supports.""" - name = " ".join(part for part in (standard_id, revision) if part) or ( - "the bound standard") + name = _names(standard_id, revision, binding) read = sorted(ledger.sections, key=lambda section: [int(part) for part in section.split(".")]) @@ -296,7 +308,7 @@ def sanitize(answer, ledger, *, standard_id="", revision="", binding=None): if not problems: return text, [] - note = _replacement(ledger, standard_id, revision) + note = _replacement(ledger, standard_id, revision, binding) replaced = [] placed = False diff --git a/client/tests/test_normative_precedence.py b/client/tests/test_normative_precedence.py index 7d8c64c..1d7515a 100644 --- a/client/tests/test_normative_precedence.py +++ b/client/tests/test_normative_precedence.py @@ -136,6 +136,22 @@ def test_what_replaces_it_says_where_a_requirement_comes_from(self): answer) +class TheNoteNamesEveryBoundStandard(unittest.TestCase): + """With a companion bound, the note named only the active standard: "No + requirement of ARM-DDI0487 M.c is stated here", over an answer that cited + the GIC specification throughout.""" + + def test_companions_are_named_after_the_active_standard(self): + binding = {"standard_id": "ARM-DDI0487", "revision": "M.c", + "companions": [{"standard_id": "ARM-IHI0069", "revision": "H.b"}]} + + self.assertEqual(normative_precedence._names("ARM-DDI0487", "M.c", binding), + "ARM-DDI0487 M.c or ARM-IHI0069 H.b") + self.assertEqual(normative_precedence._names("ARM-DDI0487", "M.c"), + "ARM-DDI0487 M.c") + self.assertEqual(normative_precedence._names(), "the bound standard") + + class DeviationsAreReportable(unittest.TestCase): """CASE 2 -- the implementation contradicts the standard.""" diff --git a/scripts/docker/spear b/scripts/docker/spear index 79720e4..4f8181f 100755 --- a/scripts/docker/spear +++ b/scripts/docker/spear @@ -337,6 +337,28 @@ NAME="spear-$(printf '%s' "${WORKDIR##*/}" | tr -c 'A-Za-z0-9_.-' '-')-$$" MEMORY="${SPEAR_CONTAINER_MEMORY:-$(awk '/^MemTotal:/ { printf "%dm", $2 * 3 / 4 / 1024 }' /proc/meminfo)}" +# chromadb opens the image's index read-write, and overlayfs then copies the +# whole database into each new container: some 25 GB and tens of seconds at +# every start, long enough for chromadb to give up waiting. A named volume +# holds it instead, filled from the image once and reused while the image +# stays the same; volumes of earlier images are removed when not in use. + +INDEX=() +SHIPPED="$(docker image inspect -f '{{range .Config.Env}}{{println .}}{{end}}' "$IMAGE" 2>/dev/null \ + | sed -n 's/^SPEAR_SHIPPED_DB_PATH=//p')" + +if [ -n "$SHIPPED" ]; then + VOLUME="spear-index-$(docker image inspect -f '{{.Id}}' "$IMAGE" | cut -d: -f2 | cut -c1-12)" + + for old in $(docker volume ls -q --filter name=spear-index-); do + [ "$old" = "$VOLUME" ] || docker volume rm "$old" >/dev/null 2>&1 || true + done + + docker volume inspect "$VOLUME" >/dev/null 2>&1 \ + || echo "spear: copying the image's index into the volume $VOLUME, once" >&2 + INDEX=(-v "$VOLUME:$SHIPPED") +fi + # The three --security-opt are what bubblewrap, the harness's sandbox, needs # to start inside a container; without them it refuses every command. @@ -352,6 +374,7 @@ exec docker run --rm --name "$NAME" "${TTY[@]}" \ -e "SPEAR_STATE_DIR=/state" \ -e "HOME=/state/home" \ -v "$STATE:/state" \ + "${INDEX[@]}" \ "${BINDS[@]}" \ -w "$WORKDIR" \ "${ENTRY[@]}" \