From 2fb0e7be5af70ae37702b97e00f0582ec496ba3b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 14 Nov 2026 16:56:58 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=201=20=F0=9F=94=B4,?= =?UTF-8?q?=203=20=F0=9F=9F=A1=20(0=20misread);=20sort=20the=20README=20en?= =?UTF-8?q?try,=20and=20reword=20the=20docstrings=20and=20comments=20the?= =?UTF-8?q?=20reviewer=20misread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- bin/adf_codec/convert.py | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7484b458..776fbafa 100644 --- a/README.md +++ b/README.md @@ -165,9 +165,9 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a `bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests. Beside the packages, `bin/`'s root holds only the launchers, the tools of one file with their tests, `test_env.py`, `failure.py` and `setup.cfg`. `failure.py`'s `Failure`, which modules across `bin/` return for a failed step, belongs to no single package. `branch_chunks/`, `claude_code/`, `command_lines/`, `git_cli/`, `loop_effects/`, `loop_state/`, `machine_load/`, `mattermost_dm/`, `model_routing/`, `plan_store/`, `record_store/`, `release_plan/`, `review_rules/`, `rung_replay/`, `text_files/` and `transcript_archive/` serve more than one tool. +- `adf_codec/` converts markdown to ADF, the rich text of Jira Cloud and Confluence, and back, in a throwaway container running a pinned `@larvit/adf-codec`. - `branch_chunks/` cuts a default branch into chunks and finds, for each, the items it shipped and the later chunks that fixed its code, for `score_outcomes` and `routing_figures`. It imports `reading_cost`'s record path. - `command_lines/` reads a shell command: its simple commands, and a docker call's subcommand and memory limits, for `command_patterns`, `reading_cost`, `routing_figures`, `rule_hook` and `run_heavy`. -- `adf_codec/` converts markdown to ADF (the rich text of Jira Cloud and Confluence) and back, with `@larvit/adf-codec`'s portable calls in a throwaway container: `convert.py` is the Python side, `node_shim/` the pinned Node shim and its Dockerfile. No tool calls it yet. - `chunk_pr` imports `deploy_release`'s forge calls, and `forge_of` as `deploy_release` does. - `deploy_release` imports `chunk_preflight`'s `forge_of`, which tells a GitHub origin from a Gitea one, and `release_plan`'s `release_standing`. - `git_cli/` runs git for every tool (`git_repo.py`), and reads the git calls in a shell command (`git_command.py`). diff --git a/bin/adf_codec/convert.py b/bin/adf_codec/convert.py index a2c8bbdc..4bc4b482 100644 --- a/bin/adf_codec/convert.py +++ b/bin/adf_codec/convert.py @@ -1,8 +1,6 @@ """Converts markdown to ADF (Atlassian Document Format, the rich text of Jira Cloud and Confluence) and back. -It runs @larvit/adf-codec's portable calls in a throwaway container, since adf-codec is a Node package: -`portableMarkdownToAdf` to write ADF and `adfToPortableMarkdown` to read it. The container holds node_shim/shim.mjs, -whose exit status says what happened: 0 answered, 2 adf-codec refused the input (its error code is in the Failure), 1 the shim itself failed. +It runs @larvit/adf-codec, a Node package, in a throwaway container that holds node_shim/shim.mjs; the shim's header says what its exit status means. """ import dataclasses import hashlib @@ -15,7 +13,7 @@ from failure import Failure SHIM = pathlib.Path(__file__).resolve().parent / "node_shim" SHIM_FILES = ("Dockerfile", "package.json", "package-lock.json", "shim.mjs") -# Both limits are equal, so the container can't swap: a document too big for it ends in a Failure, not in a slow machine. +# `--memory` and `--memory-swap` both take this, so the container can't swap: a document too big for it ends in a Failure. MEMORY = "256m" RUN_SECONDS = 60 BUILD_SECONDS = 300 @@ -29,14 +27,14 @@ class Ran: err: str -# Runs the shim in the given mode (`to-adf` or `to-markdown`) on a text, or fails to start it. +# Runs the shim in the given mode (`to-adf` or `to-markdown`) on a text, or fails to run it. Run = typing.Callable[[str, str], Ran | Failure] -# Runs a docker command line on a text, in at most the given seconds, or fails to start it. +# Runs a docker command line on a text, in at most the given seconds, or fails to run it. Docker = typing.Callable[[list[str], str, int], Ran | Failure] def image_tag(shim: pathlib.Path) -> str: - """A tag that changes with every file the image is built from, so an edited shim or a bumped adf-codec rebuilds it.""" + """A tag that changes with every file the image is built from, so an edited shim or a bumped adf-codec builds a new image.""" digest = hashlib.sha256() for name in SHIM_FILES: digest.update((shim / name).read_bytes()) @@ -58,7 +56,7 @@ def docker(args: list[str], text: str, seconds: int, call: typing.Callable[..., def ensure_image(shim: pathlib.Path, run_docker: Docker = docker) -> str | Failure: - """The tag of the shim's image, built from node_shim/ first where this machine has no image under that tag.""" + """The tag of the image for the shim folder, built from that folder first where this machine has no image under that tag.""" tag = image_tag(shim) found = run_docker(["docker", "image", "inspect", tag], "", RUN_SECONDS) if isinstance(found, Failure) or found.status == 0: @@ -79,7 +77,7 @@ def container_run(mode: str, text: str, run_docker: Docker = docker, shim: pathl def answer(mode: str, text: str, run: Run) -> str | Failure: - """What the shim printed for text, or a Failure saying why it printed none.""" + """What the shim printed for text, or a Failure saying why it gave no answer.""" ran = run(mode, text) if isinstance(ran, Failure): return ran @@ -100,7 +98,7 @@ def refusal(out: str) -> Failure: def markdown_to_adf(markdown: str, run: Run = container_run) -> dict[str, typing.Any] | Failure: - """The ADF document markdown reads as.""" + """The ADF document for the markdown.""" out = answer("to-adf", markdown, run) if isinstance(out, Failure): return out @@ -112,5 +110,5 @@ def markdown_to_adf(markdown: str, run: Run = container_run) -> dict[str, typing def adf_to_markdown(document: dict[str, typing.Any], run: Run = container_run) -> str | Failure: - """The markdown an ADF document reads as.""" + """The markdown for the ADF document.""" return answer("to-markdown", json.dumps(document), run)