Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
424241b8e5 | ||
|
|
df048ac559 | ||
|
|
722d2e8085 | ||
|
|
37070ffae2 | ||
|
|
0fce67e6b9 | ||
|
|
832056a0b0 | ||
|
|
55ddf652cb | ||
|
|
05c6697d3d |
No files matched your search
+59
-11
@@ -9,13 +9,21 @@
|
|||||||
# (`pwsh-ci-image.yml`). It runs on Linux, so what only a Windows machine can
|
# (`pwsh-ci-image.yml`). It runs on Linux, so what only a Windows machine can
|
||||||
# answer - the registry, the Store alias, a real Mark of the Web - is covered by
|
# answer - the registry, the Store alias, a real Mark of the Web - is covered by
|
||||||
# the environment hooks `tools/preflight.ps1` documents, not by this job.
|
# the environment hooks `tools/preflight.ps1` documents, not by this job.
|
||||||
|
# `python314` is the other end of the Python span tools/prerequisites.txt admits
|
||||||
|
# (Gitea #245): `verify` runs the suite on 3.13, this job on 3.14 - what is
|
||||||
|
# admitted is exactly what is checked here.
|
||||||
|
#
|
||||||
|
# Every package comes from a lock under tools/, installed with --require-hashes:
|
||||||
|
# the stack's own (through the preflight), the MCP server's, and the test tools'
|
||||||
|
# in requirements-dev.lock. Nothing is installed by name, so no run takes whatever
|
||||||
|
# was published that morning (Gitea #243, #245).
|
||||||
#
|
#
|
||||||
# Runner: `linux-docker` is one of this Gitea instance's three routing labels
|
# Runner: `linux-docker` is one of this Gitea instance's three routing labels
|
||||||
# (alongside `container-builder` and `k3s-deploy`). The job image is named
|
# (alongside `container-builder` and `k3s-deploy`). The job image is named
|
||||||
# explicitly rather than inherited from the runner's label mapping, which is
|
# explicitly rather than inherited from the runner's label mapping, which is
|
||||||
# not documented anywhere: `debian:trixie-slim` is the base the instance's
|
# not documented anywhere: `debian:trixie-slim` is the base the instance's
|
||||||
# container-build workflows already use, and Trixie's python3 is 3.13, past
|
# container-build workflows already use, and Trixie's python3 is 3.13, the
|
||||||
# the 3.11 floor `doctor` enforces.
|
# lower end of the span tools/prerequisites.txt admits.
|
||||||
#
|
#
|
||||||
# Pinning that image makes `nodejs` this workflow's own responsibility.
|
# Pinning that image makes `nodejs` this workflow's own responsibility.
|
||||||
# `actions/checkout` is a JavaScript action, and act_runner runs it with `node`
|
# `actions/checkout` is a JavaScript action, and act_runner runs it with `node`
|
||||||
@@ -111,15 +119,14 @@ jobs:
|
|||||||
cp .wikitool-tools.json /tmp/tools-first.json
|
cp .wikitool-tools.json /tmp/tools-first.json
|
||||||
tools/preflight.sh > /tmp/preflight-second.txt
|
tools/preflight.sh > /tmp/preflight-second.txt
|
||||||
cmp .wikitool-tools.json /tmp/tools-first.json
|
cmp .wikitool-tools.json /tmp/tools-first.json
|
||||||
# pytest-cov is CI-only: tools/requirements.txt describes what an
|
|
||||||
# *instance* needs at runtime and ships with `dist export`, and an
|
|
||||||
# instance does not measure this suite. Installed beside pytest for
|
|
||||||
# the same reason pytest itself is.
|
|
||||||
tools/.venv/bin/python -m pip install --quiet pytest pytest-cov
|
|
||||||
# The MCP server's dependency is optional for an instance but not for
|
# The MCP server's dependency is optional for an instance but not for
|
||||||
# CI: its tests skip without it, and a skipped golden test is exactly
|
# CI: its tests skip without it, and a skipped golden test is exactly
|
||||||
# how the server's output and the CLI's would drift apart unnoticed.
|
# how the server's output and the CLI's would drift apart unnoticed.
|
||||||
tools/.venv/bin/python -m pip install --quiet -r tools/requirements-mcp.txt
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-mcp.lock
|
||||||
|
# The test tools - pytest, pytest-cov, radicale - are dev-only:
|
||||||
|
# tools/requirements.txt describes what an *instance* needs at runtime
|
||||||
|
# and ships with `dist export`, and an instance does not run this suite.
|
||||||
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
- name: Tests
|
- name: Tests
|
||||||
# Not run with WIKI_TRACE=0: two telemetry tests assert that a trace is
|
# Not run with WIKI_TRACE=0: two telemetry tests assert that a trace is
|
||||||
@@ -180,10 +187,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Start Radicale
|
- name: Start Radicale
|
||||||
# Its own step because the script hands the server's address to the suite through
|
# Its own step because the script hands the server's address to the suite through
|
||||||
# $GITHUB_ENV, which only reaches the steps after the one that wrote it.
|
# $GITHUB_ENV, which only reaches the steps after the one that wrote it. Radicale
|
||||||
|
# itself came in with requirements-dev.lock above.
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
tools/.venv/bin/python -m pip install --quiet radicale
|
|
||||||
.gitea/scripts/start-radicale.sh tools/.venv/bin/python /tmp/radicale
|
.gitea/scripts/start-radicale.sh tools/.venv/bin/python /tmp/radicale
|
||||||
|
|
||||||
- name: Live tracker suite (CalDAV)
|
- name: Live tracker suite (CalDAV)
|
||||||
@@ -420,7 +427,7 @@ jobs:
|
|||||||
rm .wikitool-tools.json
|
rm .wikitool-tools.json
|
||||||
tools/preflight.sh
|
tools/preflight.sh
|
||||||
cmp .wikitool-tools.json /tmp/tools-pwsh.json
|
cmp .wikitool-tools.json /tmp/tools-pwsh.json
|
||||||
tools/.venv/bin/python -m pip install --quiet pytest
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
- name: The launcher, started from PowerShell
|
- name: The launcher, started from PowerShell
|
||||||
# `tools/wikitool` from pwsh resolves to wikitool.ps1, not the sh launcher - the one
|
# `tools/wikitool` from pwsh resolves to wikitool.ps1, not the sh launcher - the one
|
||||||
@@ -436,3 +443,44 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
cd tools
|
cd tools
|
||||||
.venv/bin/python -m pytest -q chemenu/tests/test_preflight_pwsh.py chemenu/tests/test_preflight.py chemenu/tests/test_doctor.py chemenu/tests/test_bugreport_launcher.py
|
.venv/bin/python -m pytest -q chemenu/tests/test_preflight_pwsh.py chemenu/tests/test_preflight.py chemenu/tests/test_doctor.py chemenu/tests/test_bugreport_launcher.py
|
||||||
|
|
||||||
|
python314:
|
||||||
|
# The suite on the upper end of the Python span (Gitea #245). The official Python image
|
||||||
|
# on the same Debian base as `verify`, so the one difference between the two jobs is the
|
||||||
|
# interpreter: its python3 is 3.14, which the preflight finds and builds tools/.venv on.
|
||||||
|
# Only the suite - the distribution replay, the version gate and the live steps answer
|
||||||
|
# questions that do not depend on the Python minor, and the one runner works through
|
||||||
|
# the jobs of a push one after another.
|
||||||
|
runs-on: linux-docker
|
||||||
|
container:
|
||||||
|
image: python:3.14-slim-trixie
|
||||||
|
env:
|
||||||
|
WIKITOOL_SESSION_ID: ci-py314-${{ github.run_id }}
|
||||||
|
WIKI_TRACE_DIR: /tmp/wikitool-trace
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: System dependencies
|
||||||
|
# `nodejs` for act_runner's checkout action, as in `verify`; no python3 package -
|
||||||
|
# the image's own 3.14 is the point of this job.
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y --no-install-recommends git nodejs ripgrep ca-certificates
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- name: Tool environment
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
tools/preflight.sh
|
||||||
|
tools/.venv/bin/python -c 'import sys; assert sys.version_info[:2] == (3, 14), sys.version'
|
||||||
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-mcp.lock
|
||||||
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
|
- name: Tests
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
cd tools
|
||||||
|
.venv/bin/python -m pytest -q
|
||||||
@@ -40,6 +40,7 @@ on:
|
|||||||
- 'tools/chemenu/tests/test_raw_derive*.py'
|
- 'tools/chemenu/tests/test_raw_derive*.py'
|
||||||
- 'tools/chemenu/tests/binary_formats.py'
|
- 'tools/chemenu/tests/binary_formats.py'
|
||||||
- 'tools/requirements.txt'
|
- 'tools/requirements.txt'
|
||||||
|
- 'tools/requirements.lock'
|
||||||
- '.gitea/workflows/converters.yml'
|
- '.gitea/workflows/converters.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
tools/preflight.sh
|
tools/preflight.sh
|
||||||
tools/.venv/bin/python -m pip install --quiet pytest
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
- name: Real documents
|
- name: Real documents
|
||||||
# `-c pytest.ini` applies the suite's own configuration to a harness that lives outside
|
# `-c pytest.ini` applies the suite's own configuration to a harness that lives outside
|
||||||
|
|||||||
@@ -25,6 +25,15 @@
|
|||||||
# container, so it is installed before the checkout or the job dies with exit
|
# container, so it is installed before the checkout or the job dies with exit
|
||||||
# 127. Do not re-derive this; see the header of ci.yml.
|
# 127. Do not re-derive this; see the header of ci.yml.
|
||||||
#
|
#
|
||||||
|
# Two more kinds of drift happen with no commit at all, in the packages the locks under
|
||||||
|
# tools/ pin (Gitea #245), and the last three steps watch them without touching the tree:
|
||||||
|
# a vulnerability published for a pinned version (`pip-audit` against every lock - red
|
||||||
|
# means a security lift is due), and the next regular lift breaking the suite (a fresh
|
||||||
|
# resolution with the same 7-day cooldown, in a venv of its own, and the suite against
|
||||||
|
# it - red means the lift will need more than a new lock). They run even when an
|
||||||
|
# earlier step failed, so a red lint never hides them. The procedure for either answer
|
||||||
|
# is instructions/dev/dependency-locks.md.
|
||||||
|
#
|
||||||
# Failure is meant to be visible without opening the Actions page. That is
|
# Failure is meant to be visible without opening the Actions page. That is
|
||||||
# Gitea's own run notification, not something this workflow builds: a job that
|
# Gitea's own run notification, not something this workflow builds: a job that
|
||||||
# files its own issue needs an Actions token with issue-write and a dedup rule,
|
# files its own issue needs an Actions token with issue-write and a dedup rule,
|
||||||
@@ -100,3 +109,46 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
tools/wikitool sources coverage
|
tools/wikitool sources coverage
|
||||||
tools/wikitool migrate status
|
tools/wikitool migrate status
|
||||||
|
|
||||||
|
- name: Audit tools, in a venv of their own
|
||||||
|
# pip-audit and uv come from the test tools' lock - never into tools/.venv, which
|
||||||
|
# stays exactly what the preflight installed.
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
python3 -m venv /tmp/audit
|
||||||
|
/tmp/audit/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
|
- name: No known vulnerability in any lock
|
||||||
|
# --disable-pip audits the pinned versions as written, installing none of them.
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
/tmp/audit/bin/pip-audit --disable-pip --require-hashes --progress-spinner off \
|
||||||
|
-r tools/requirements.lock -r tools/requirements-mcp.lock \
|
||||||
|
-r tools/requirements-browser.lock -r tools/requirements-dev.lock
|
||||||
|
|
||||||
|
- name: The suite passes against a fresh resolution
|
||||||
|
# What the next regular lift would produce today: every source file resolved again
|
||||||
|
# with the cooldown, written outside the tree, installed into a venv of its own.
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
PATH="/tmp/audit/bin:$PATH" python3 tools/lock_requirements.py --out /tmp/fresh-locks
|
||||||
|
python3 -m venv /tmp/fresh
|
||||||
|
for lock in requirements requirements-mcp requirements-dev; do
|
||||||
|
/tmp/fresh/bin/python -m pip install --quiet --require-hashes -r "/tmp/fresh-locks/${lock}.lock"
|
||||||
|
done
|
||||||
|
cd tools
|
||||||
|
/tmp/fresh/bin/python -m pytest -q -p no:cacheprovider
|
||||||
|
|
||||||
|
- name: The tree is unchanged
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
changed=$(git status --porcelain)
|
||||||
|
if [ -n "$changed" ]; then
|
||||||
|
echo "The nightly changed the tree:"
|
||||||
|
printf '%s\n' "$changed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -94,7 +94,7 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
tools/preflight.sh
|
tools/preflight.sh
|
||||||
tools/.venv/bin/python -m pip install --quiet pytest
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
- name: Real documents
|
- name: Real documents
|
||||||
if: steps.version.outputs.skip != 'true'
|
if: steps.version.outputs.skip != 'true'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The live tracker suite, nightly (Gitea #156): the documented `task` and `review` workflow
|
# The live tracker suite, nightly (Gitea #156): the documented `task` and `review` workflow
|
||||||
# against a real Super Productivity and a real CalDAV server, not against fakes.
|
# against a real Super Productivity and a real CalDAV server, not against fakes.
|
||||||
#
|
#
|
||||||
# `ci.yml` already runs the CalDAV half on every push (Radicale is a pip install). This
|
# `ci.yml` already runs the CalDAV half on every push (Radicale comes from tools/requirements-dev.lock). This
|
||||||
# workflow adds the half that needs the desktop app, inside the prebuilt
|
# workflow adds the half that needs the desktop app, inside the prebuilt
|
||||||
# `chemenu-sp-live` image (`sp-live-image.yml`), and runs both, so one green night covers both
|
# `chemenu-sp-live` image (`sp-live-image.yml`), and runs both, so one green night covers both
|
||||||
# providers.
|
# providers.
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
tools/preflight.sh
|
tools/preflight.sh
|
||||||
tools/.venv/bin/python -m pip install --quiet pytest radicale
|
tools/.venv/bin/python -m pip install --quiet --require-hashes -r tools/requirements-dev.lock
|
||||||
|
|
||||||
- name: Start Radicale
|
- name: Start Radicale
|
||||||
run: .gitea/scripts/start-radicale.sh tools/.venv/bin/python /tmp/radicale
|
run: .gitea/scripts/start-radicale.sh tools/.venv/bin/python /tmp/radicale
|
||||||
|
|||||||
+31
@@ -14,6 +14,37 @@ place only: `instructions/dev/version-parts.md` § The candidate model.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 11.0.0 - 2026-11-30 - Abhängigkeiten festgeschrieben, Präzisierungen beim Ingest - letzter Stand vor dem Neuschnitt
|
||||||
|
|
||||||
|
**Author:** Torben Nehmer
|
||||||
|
|
||||||
|
**Breaking Change:** Python 3.11 und 3.12 sind nicht mehr zugelassen (ebenso 3.15): der Preflight weist sie mit exit 42 ab. Eine Instanz darauf installiert Python 3.13 oder 3.14 und führt den Preflight erneut aus; er legt tools/.venv darauf neu an.
|
||||||
|
|
||||||
|
**Migration:** none required - kb/ bleibt unberührt
|
||||||
|
|
||||||
|
<!-- wikitool:bumps -->
|
||||||
|
**High impact**
|
||||||
|
- Abhängigkeiten festgeschrieben: Lock-Dateien mit Hashes und 7 Tagen Abkühlzeit, pip-audit im Nightly; Python 3.13-3.14 als zugelassene Spanne (#245)
|
||||||
|
|
||||||
|
**Medium impact**
|
||||||
|
- Reine Lesevorgänge schreiben keinen Log-Eintrag mehr, und ein offener Log-Eintrag allein lässt den Katalog beim Abgleich unangetastet
|
||||||
|
- Ingest: Präzisierungen des Operators als Begleitdatei im Bundle der Quelle - neuer Befehl raw clarify (#241)
|
||||||
|
- Abhängigkeiten: Testsuite läuft unter pytest 9.2, Befehlshilfe und Referenz folgen typer 0.29 - Untergrenze typer>=0.29.1 (#243)
|
||||||
|
|
||||||
|
**Low impact**
|
||||||
|
- Publish-, Sync-Hilfe und Log-Vorlage nennen den reinen Log-Zusatz beim Abgleich
|
||||||
|
- Wartezeiten der CI-Läufe mit dem Job python314 gemessen (#245 close)
|
||||||
|
- Benennungsregel: ein GTD-Projekt heißt nach seinem Ergebnis, nie nach dem Artefakt; new project nennt die kb/-Titelkollision (#244)
|
||||||
|
<!-- /wikitool:bumps -->
|
||||||
|
|
||||||
|
Dieses Release ist der letzte Stand des bisherigen Stacks vor dem Neuschnitt nach #249; bis zur Umschaltung gehen nur noch Fixes hinein, die den Betrieb bestehender Instanzen blockieren. Es schreibt die Abhängigkeiten fest: Lock-Dateien mit Hashes und sieben Tagen Abkühlzeit, Python 3.13 bis 3.14 als zugelassene Spanne, `pip-audit` und frische Auflösung im Nightly. Der Ingest nimmt Präzisierungen des Operators als Begleitdatei zur Quelle auf (`raw clarify`), reine Lesevorgänge schreiben keinen Log-Eintrag mehr, und ein GTD-Projekt heißt nach seinem Ergebnis.
|
||||||
|
|
||||||
|
### Abhängigkeiten festgeschrieben
|
||||||
|
|
||||||
|
Neben jeder `tools/requirements*.txt` (nur Untergrenzen) liegt eine `.lock` mit exakter Version und SHA-256 je Paket, transitive eingeschlossen, erzeugt mit 7 Tagen Abkühlzeit; Preflight und CI installieren nur daraus, mit `--require-hashes`. Ändert ein neuer Stand das Lock, bringt der nächste Preflight `tools/.venv` genau auf dessen Versionen, auch abwärts - bisher fror eine Instanz auf ihrem Installationstag ein. Python ist eine Spanne, 3.13 bis 3.14, in `tools/prerequisites.txt`; der Preflight nimmt auch `python3.14`/`py -3.14` und legt ein venv außerhalb der Spanne neu an. CI prüft beide Enden, der Nightly `pip-audit` und eine frische Auflösung. Eine Instanz auf 3.11/3.12 installiert Python 3.13 oder 3.14 und führt den Preflight erneut aus; der MCP-Server kommt jetzt aus `tools/requirements-mcp.lock`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 10.1.0 - 2026-10-16 - Große PDFs und lange Quellen beim Ingest, vollständiger Export, Konverter-Tests gegen echte Dokumente
|
## 10.1.0 - 2026-10-16 - Große PDFs und lange Quellen beim Ingest, vollständiger Export, Konverter-Tests gegen echte Dokumente
|
||||||
|
|
||||||
**Author:** Torben Nehmer
|
**Author:** Torben Nehmer
|
||||||
|
|||||||
+11
-3
@@ -24,11 +24,18 @@ preflight names the install command for your system. The list is generated from
|
|||||||
`tools/prerequisites.txt`, the same file the preflight reads:
|
`tools/prerequisites.txt`, the same file the preflight reads:
|
||||||
|
|
||||||
<!-- wikitool:prerequisites -->
|
<!-- wikitool:prerequisites -->
|
||||||
- **Python** ≥ 3.11
|
- **Python** 3.13 – 3.14
|
||||||
- **Git**
|
- **Git**
|
||||||
- **ripgrep (rg)**
|
- **ripgrep (rg)**
|
||||||
<!-- /wikitool:prerequisites -->
|
<!-- /wikitool:prerequisites -->
|
||||||
|
|
||||||
|
Python has an upper bound as well as a lower one: the stack is checked on 3.13 and 3.14 and
|
||||||
|
runs on nothing else. On Windows and macOS the install command the preflight names installs a
|
||||||
|
3.14. On Linux it is your distribution's own Python, which is in that span on Debian 13, Ubuntu
|
||||||
|
25.04 and newer and Arch - but not on Debian 12 (3.11) or Ubuntu 24.04 (3.12). There, a Python
|
||||||
|
3.13 or 3.14 installed some other way works too: tell the agent its path, and it passes it on with
|
||||||
|
`--set python=<path>`.
|
||||||
|
|
||||||
Optional: the **1Password CLI (`op`)**, if you want secrets and private values in the settings to
|
Optional: the **1Password CLI (`op`)**, if you want secrets and private values in the settings to
|
||||||
come from 1Password ([use-1password-for-settings.md](docs/how-to/use-1password-for-settings.md)).
|
come from 1Password ([use-1password-for-settings.md](docs/how-to/use-1password-for-settings.md)).
|
||||||
The preflight records it when it finds it and never asks for it.
|
The preflight records it when it finds it and never asks for it.
|
||||||
@@ -162,8 +169,9 @@ are done; then it checks again. It may not work around the stop or install anyth
|
|||||||
- **A tool is missing** - Python, git, ripgrep, on Windows also PowerShell 7. The output names
|
- **A tool is missing** - Python, git, ripgrep, on Windows also PowerShell 7. The output names
|
||||||
the install command for your system. If it is installed, just somewhere else, tell the agent the
|
the install command for your system. If it is installed, just somewhere else, tell the agent the
|
||||||
path; it passes it on with `--set <tool>=<path>`.
|
path; it passes it on with `--set <tool>=<path>`.
|
||||||
- **A version is too old** - Python below 3.11, for example. Install a newer version or name its
|
- **A version is too old, or too new** - Python below 3.13 or above 3.14, for example. Install
|
||||||
path.
|
one in the span or name the path of one you have; a `python3.14` or `python3.13` beside a newer
|
||||||
|
default is found by itself.
|
||||||
- **A path you named does not work** - the path must point at the program itself, not at its
|
- **A path you named does not work** - the path must point at the program itself, not at its
|
||||||
folder.
|
folder.
|
||||||
- **The Python environment (`tools/.venv`) or its libraries could not be set up.** The output
|
- **The Python environment (`tools/.venv`) or its libraries could not be set up.** The output
|
||||||
|
|||||||
@@ -196,8 +196,8 @@ refills the Gitea wiki by hand (see below).
|
|||||||
`.gitea/workflows/converters.yml` runs the converters against the real documents of the private
|
`.gitea/workflows/converters.yml` runs the converters against the real documents of the private
|
||||||
repository (the clone above, run with the checkout's `tools/.venv`). It starts by itself on a push
|
repository (the clone above, run with the checkout's `tools/.venv`). It starts by itself on a push
|
||||||
to `main` that touches the converter surface - `tools/chemenu/filters/`, `raw/derive.py`,
|
to `main` that touches the converter surface - `tools/chemenu/filters/`, `raw/derive.py`,
|
||||||
`raw/accept.py`, `tests/test_raw_derive*.py`, `tests/binary_formats.py`, `tools/requirements.txt`
|
`raw/accept.py`, `tests/test_raw_derive*.py`, `tests/binary_formats.py`, `tools/requirements.txt`,
|
||||||
and the workflow itself - and by hand (`workflow_dispatch`), which is how to run it after a change
|
`tools/requirements.lock` and the workflow itself - and by hand (`workflow_dispatch`), which is how to run it after a change
|
||||||
in the private repository alone: a push there starts nothing here. It always tests `main` of the
|
in the private repository alone: a push there starts nothing here. It always tests `main` of the
|
||||||
private repository, so a converter change that alters an expected output is two commits, the
|
private repository, so a converter change that alters an expected output is two commits, the
|
||||||
private one first. Before a release without suffix, `release.yml` runs the same steps as a job its
|
private one first. Before a release without suffix, `release.yml` runs the same steps as a job its
|
||||||
@@ -284,9 +284,9 @@ preceding a release measures a tree that is one commit short of the published on
|
|||||||
The pair says more than either number does. Between them the measured code grew by a quarter
|
The pair says more than either number does. Between them the measured code grew by a quarter
|
||||||
and the suite by a third, and the quota moved by a tenth of a point - which is the observation a
|
and the suite by a third, and the quota moved by a tenth of a point - which is the observation a
|
||||||
threshold was waiting for, rather than the total itself. Reproduce either with
|
threshold was waiting for, rather than the total itself. Reproduce either with
|
||||||
`cd tools && .venv/bin/python -m pytest -q --cov` (needs `pytest-cov`, which is CI-only and
|
`cd tools && .venv/bin/python -m pytest -q --cov` (needs `pytest-cov`, which sits in the dev-only
|
||||||
deliberately absent from `tools/requirements.txt` - an instance runs the wiki, it does not
|
`tools/requirements-dev.lock` and deliberately not in `tools/requirements.txt` - an instance runs
|
||||||
measure this suite).
|
the wiki, it does not measure this suite).
|
||||||
|
|
||||||
The total stays the least interesting number here. What the report is for is *which* modules sit
|
The total stays the least interesting number here. What the report is for is *which* modules sit
|
||||||
low, and three kinds have to be told apart before any of it turns into work:
|
low, and three kinds have to be told apart before any of it turns into work:
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ chemenu/
|
|||||||
├── kb/ # OUTPUT: compiled knowledge. A namespace, not a collection
|
├── kb/ # OUTPUT: compiled knowledge. A namespace, not a collection
|
||||||
│ ├── CONTRACT.md # Collections, naming, tone, linking, provenance
|
│ ├── CONTRACT.md # Collections, naming, tone, linking, provenance
|
||||||
│ ├── index.md # Generated catalog *map*: counts and pointers
|
│ ├── index.md # Generated catalog *map*: counts and pointers
|
||||||
│ ├── log.md # Generated chronological audit log
|
│ ├── log.md # Generated audit log, in the order entries arrived
|
||||||
│ ├── provenance.md # Generated raw-file reverse index
|
│ ├── provenance.md # Generated raw-file reverse index
|
||||||
│ ├── entities/ # COLLECTION.md + INDEX.md + areas below
|
│ ├── entities/ # COLLECTION.md + INDEX.md + areas below
|
||||||
│ │ ├── codebases/
|
│ │ ├── codebases/
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ obligations explicitly: uniqueness is checked before a project is created rather
|
|||||||
later; a rename is a deliberate, infrequent operation that touches both sides in one pass; and
|
later; a rename is a deliberate, infrequent operation that touches both sides in one pass; and
|
||||||
nothing tries to re-match automatically behind the operator's back.
|
nothing tries to re-match automatically behind the operator's back.
|
||||||
|
|
||||||
|
The shared name is the undertaking's, not the artifact's. A product, a codebase or a house has
|
||||||
|
its own entity page, and since a title is unique across `kb/`, a project named after the artifact
|
||||||
|
alone would collide with that page - so the project is named after its outcome
|
||||||
|
(`kb/CONVENTIONS.md` § Naming), and the artifact keeps its name for the page that describes it.
|
||||||
|
|
||||||
The last one is what makes the review's *both-directional* report matter. A tracker project with
|
The last one is what makes the review's *both-directional* report matter. A tracker project with
|
||||||
no page and a page with no tracker project are reported separately, as two findings. They are
|
no page and a page with no tracker project are reported separately, as two findings. They are
|
||||||
usually the two halves of one rename - and reporting them separately is exactly what turns a
|
usually the two halves of one rename - and reporting them separately is exactly what turns a
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ same context, it names that reason once and then does.
|
|||||||
|
|
||||||
## Where the agent asks you
|
## Where the agent asks you
|
||||||
|
|
||||||
|
- **When the source lacks something only you know** - the date of a recorded meeting, who took
|
||||||
|
part, what an abbreviation stands for. The agent asks, and writes your short answers with
|
||||||
|
`tools/wikitool raw clarify` as `<name>.clarifications.md` beside the source; it is promoted with
|
||||||
|
the source into one folder in `raw/` and cited from the source page, instead of becoming a
|
||||||
|
second source. Only what the agent asked about the source goes in. New content you add
|
||||||
|
unprompted is still a source of its own.
|
||||||
- **Before promoting the file into `raw/`**, the agent asks how faithful the capture is
|
- **Before promoting the file into `raw/`**, the agent asks how faithful the capture is
|
||||||
(`fidelity`) and what the material may claim about its subject (`authority`). Both are recorded
|
(`fidelity`) and what the material may claim about its subject (`authority`). Both are recorded
|
||||||
once and never guessed: you know the answers now, and nobody can recover them later.
|
once and never guessed: you know the answers now, and nobody can recover them later.
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ command stops with exit 42 and asks you to create the project in the app yoursel
|
|||||||
when you are done, and it continues with `--resume`. A tracker the wiki can only read refuses the
|
when you are done, and it continues with `--resume`. A tracker the wiki can only read refuses the
|
||||||
command outright.
|
command outright.
|
||||||
|
|
||||||
|
Name the project after what it is meant to achieve, not after the thing it is about: the product
|
||||||
|
"Binford 9000" keeps that name for its entity page, and the project becomes "Binford 9000 -
|
||||||
|
Markteinführung EU". Titles are unique across the wiki, so `new project` refuses a name an entity
|
||||||
|
page already has. The rule itself is in your instance's `kb/CONVENTIONS.md` § Naming.
|
||||||
|
|
||||||
A single open item with no page of its own - a commitment that came with a source, say - is filed
|
A single open item with no page of its own - a commitment that came with a source, say - is filed
|
||||||
with `tools/wikitool task new`. `task list` reads a project's open items back, and `task close --id`
|
with `tools/wikitool task new`. `task list` reads a project's open items back, and `task close --id`
|
||||||
marks one done. Nothing deletes an item. The commands are in the
|
marks one done. Nothing deletes an item. The commands are in the
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ Set up the MCP read server for this instance
|
|||||||
```
|
```
|
||||||
|
|
||||||
It installs the server's optional dependency, which is deliberately not in
|
It installs the server's optional dependency, which is deliberately not in
|
||||||
`tools/requirements.txt`: an instance that only uses the CLI should not have to install pydantic,
|
`tools/requirements.txt`: an instance that only uses the CLI should not have to install
|
||||||
starlette, uvicorn and cryptography. It also checks that tracing cannot write into the served tree.
|
starlette, uvicorn and the rest of a web server. It installs `tools/requirements-mcp.lock`, with
|
||||||
|
exact versions and hashes that agree with the rest of `tools/.venv`. It also checks that tracing cannot write into the served tree.
|
||||||
The server refuses to start if it could:
|
The server refuses to start if it could:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ Full records: [raw-material-and-uploads.md](raw-material-and-uploads.md)
|
|||||||
- [`raw fetch`](raw-material-and-uploads.md#raw-fetch) - Capture a web page the user names into `incoming/`: the HTML as received plus a derived text, for `raw accept` to promote. Pages of a known website are fetched in the website's standard form and cleaned of its page furniture; a host the instance routes so is fetched with the user's own session or through an external fetcher.
|
- [`raw fetch`](raw-material-and-uploads.md#raw-fetch) - Capture a web page the user names into `incoming/`: the HTML as received plus a derived text, for `raw accept` to promote. Pages of a known website are fetched in the website's standard form and cleaned of its page furniture; a host the instance routes so is fetched with the user's own session or through an external fetcher.
|
||||||
- [`raw login`](raw-material-and-uploads.md#raw-login) - Let the user sign in to a website once, in a visible browser window, and store the session it leaves as a secret outside the working tree, for `raw fetch` to fetch that website's pages with. Only the user runs it.
|
- [`raw login`](raw-material-and-uploads.md#raw-login) - Let the user sign in to a website once, in a visible browser window, and store the session it leaves as a secret outside the working tree, for `raw fetch` to fetch that website's pages with. Only the user runs it.
|
||||||
- [`raw derive`](raw-material-and-uploads.md#raw-derive) - Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`, or unpack a ZIP, and leave the original beside it, for `raw accept` to promote.
|
- [`raw derive`](raw-material-and-uploads.md#raw-derive) - Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`, or unpack a ZIP, and leave the original beside it, for `raw accept` to promote.
|
||||||
|
- [`raw clarify`](raw-material-and-uploads.md#raw-clarify) - Write the operator's answers to an ingest's questions about a source as a companion file in `incoming/`, to be promoted with the source instead of as a source of its own.
|
||||||
- [`raw capture`](raw-material-and-uploads.md#raw-capture) - Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
- [`raw capture`](raw-material-and-uploads.md#raw-capture) - Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
||||||
- [`raw status`](raw-material-and-uploads.md#raw-status) - Report which captured bundles under `raw/` have fallen behind their repository, with each changed file as `A`/`M`/`D`.
|
- [`raw status`](raw-material-and-uploads.md#raw-status) - Report which captured bundles under `raw/` have fallen behind their repository, with each changed file as `A`/`M`/`D`.
|
||||||
- [`raw pending`](raw-material-and-uploads.md#raw-pending) - List what waits in `incoming/`, oldest first, and name the entry an ingest without an argument takes next.
|
- [`raw pending`](raw-material-and-uploads.md#raw-pending) - List what waits in `incoming/`, oldest first, and name the entry an ingest without an argument takes next.
|
||||||
|
|||||||
@@ -66,13 +66,13 @@ Append a formatted entry to `kb/log.md`.
|
|||||||
|
|
||||||
**Synopsis**
|
**Synopsis**
|
||||||
|
|
||||||
- `wikitool log append --op ingest|query|lint|create|update|delete|rename|move --title "..." [--body "..."|--body-file path]`
|
- `wikitool log append --op ingest|lint|create|update|delete|rename|move|query --title "..." [--body "..."|--body-file path]`
|
||||||
|
|
||||||
**Options**
|
**Options**
|
||||||
|
|
||||||
```text
|
```text
|
||||||
--op <str> ingest|query|lint|create|update|delete|rename|move
|
--op <str> ingest|query|lint|create|update|delete|rename|move (query:
|
||||||
[required]
|
legacy, no longer written by the stack) [required]
|
||||||
--title <str> Brief description, e.g. a source path [required]
|
--title <str> Brief description, e.g. a source path [required]
|
||||||
--body <str> Optional multi-line details
|
--body <str> Optional multi-line details
|
||||||
--body-file <path> Read the body from a file instead of --body
|
--body-file <path> Read the body from a file instead of --body
|
||||||
@@ -90,6 +90,7 @@ tools/wikitool log append --op lint --title "2026-09-26" --body-file lint-summar
|
|||||||
|
|
||||||
- Appends one entry to `kb/log.md`: a `## [YYYY-MM-DD] <op> | <title>` heading, the body if one is given, and a `---` separator.
|
- Appends one entry to `kb/log.md`: a `## [YYYY-MM-DD] <op> | <title>` heading, the body if one is given, and a `---` separator.
|
||||||
- Not idempotent: every successful run appends a new entry, including a repeated one.
|
- Not idempotent: every successful run appends a new entry, including a repeated one.
|
||||||
|
- `query` is a legacy value: older versions wrote one entry per read-only query. It is still accepted so existing logs and an instance's own instructions keep working, but the stack no longer writes it - a read is not an operation on the wiki.
|
||||||
|
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ Set one value of the tiered settings, in the file its tier names.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
key <section>.<field> [required]
|
key <str> <section>.<field> [required]
|
||||||
value The plain value; a string as given, anything else as JSON.
|
value <str> The plain value; a string as given, anything else as JSON.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--ref <str> A reference instead of a value: <name> or
|
--ref <str> A reference instead of a value: <name> or
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ Compare `kb/` against a git revision on the invariants a content migration must
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
--from <str> Git revision to compare against, e.g. HEAD [required]
|
--from <str> Git revision to compare against, e.g. HEAD [required]
|
||||||
--path <str> Limit to a subtree, repeatable (e.g. kb/concepts)
|
--path <list[str]> Limit to a subtree, repeatable (e.g. kb/concepts)
|
||||||
--expect-body-change Also report pages whose body did not change at all
|
--expect-body-change Also report pages whose body did not change at all
|
||||||
--json Print the diff as JSON
|
--json Print the diff as JSON
|
||||||
--fail-on-error Exit 1 if any invariant changed
|
--fail-on-error Exit 1 if any invariant changed
|
||||||
@@ -173,7 +173,7 @@ Record one migration as applied, advancing `kb_version` in `.wikitool-kb.json`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
version The migration's target version, e.g. 1.4.0 [required]
|
version <str> The migration's target version, e.g. 1.4.0 [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--pages <int> How many pages it touched
|
--pages <int> How many pages it touched
|
||||||
@@ -227,7 +227,7 @@ Declare `kb_version` once, for an instance predating `.wikitool-kb.json`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
version The shape this instance's content is already in [required]
|
version <str> The shape this instance's content is already in [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--force Overwrite an existing declaration (not a substitute for `done`)
|
--force Overwrite an existing declaration (not a substitute for `done`)
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ Write a contentless, distributable copy of this repo's machinery.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
target Directory to write the distribution into. Must not exist, or must be
|
target <path> Directory to write the distribution into. Must not exist, or
|
||||||
empty. [required]
|
must be empty. [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--dry-run List what would be written, without writing anything.
|
--dry-run List what would be written, without writing anything.
|
||||||
@@ -98,8 +98,8 @@ Take shipped templates as this instance's own: copy each to its unsuffixed name.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
templates... Templates to adopt. Default: every collection contract and page
|
templates... <list[Path]> Templates to adopt. Default: every collection
|
||||||
type-spec template.
|
contract and page type-spec template.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--dry-run List what would be copied, without writing anything.
|
--dry-run List what would be copied, without writing anything.
|
||||||
@@ -154,28 +154,29 @@ Apply a stack update `dist export` produced - the write half of `version check`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
source An extracted distribution directory, or a release .tar.gz archive - or
|
source <path> An extracted distribution directory, or a release .tar.gz
|
||||||
use --latest
|
archive - or use --latest
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--latest Download the release the feed announces as latest
|
--latest Download the release the feed announces as latest
|
||||||
instead of naming a <source>
|
instead of naming a <source>
|
||||||
--expect <str> With --latest: refuse, before downloading anything,
|
--expect <str> With --latest: refuse, before downloading
|
||||||
unless the feed's latest release is this version (the
|
anything, unless the feed's latest release is this
|
||||||
one `version notes` was read for)
|
version (the one `version notes` was read for)
|
||||||
--dry-run Classify and report, without writing anything
|
--dry-run Classify and report, without writing anything
|
||||||
--keep-local Proceed even with locally changed files - leave each one
|
--keep-local Proceed even with locally changed files - leave
|
||||||
untouched rather than aborting
|
each one untouched rather than aborting
|
||||||
--take-release <str> Overwrite this locally changed path with the release's
|
--take-release <list[str]> Overwrite this locally changed path with the
|
||||||
version, discarding the local change. Repeatable, and
|
release's version, discarding the local change.
|
||||||
each path must be one this run reports as locally
|
Repeatable, and each path must be one this run
|
||||||
changed. The counterpart to --keep-local, which keeps
|
reports as locally changed. The counterpart to
|
||||||
the change and reports it again on every future upgrade
|
--keep-local, which keeps the change and reports
|
||||||
--prune Accepted and ignored: files the new release no longer
|
it again on every future upgrade
|
||||||
ships are now deleted by default when unchanged since
|
--prune Accepted and ignored: files the new release no
|
||||||
install
|
longer ships are now deleted by default when
|
||||||
--pre Allow a pre-release (-beta.N) source tree - release.yml
|
unchanged since install
|
||||||
never publishes one
|
--pre Allow a pre-release (-beta.N) source tree -
|
||||||
|
release.yml never publishes one
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -503,8 +504,8 @@ List the running candidate's bump titles with their impact grade, or change one
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
indices... 1-based positions in the rendered bump list to regrade (see the
|
indices... <list[int]> 1-based positions in the rendered bump list to regrade
|
||||||
bare listing). Omit to just list.
|
(see the bare listing). Omit to just list.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--impact <str> high|medium|low - required together with indices
|
--impact <str> high|medium|low - required together with indices
|
||||||
|
|||||||
@@ -22,18 +22,18 @@ Render the guideline pages into one generated `GUIDELINES.md`, or push it into t
|
|||||||
**Options**
|
**Options**
|
||||||
|
|
||||||
```text
|
```text
|
||||||
-f, --field <str> Frontmatter predicate, repeatable (AND) - the same forms
|
-f, --field <list[str]> Frontmatter predicate, repeatable (AND) - the same
|
||||||
as `search --field`.
|
forms as `search --field`.
|
||||||
--kind <str> Shorthand for --field kind=<value>.
|
--kind <str> Shorthand for --field kind=<value>.
|
||||||
--subtype <str> Shorthand for --field subtype=<value>.
|
--subtype <str> Shorthand for --field subtype=<value>.
|
||||||
--collection <str> Shorthand for --field collection=<value>.
|
--collection <str> Shorthand for --field collection=<value>.
|
||||||
--tag <str> Shorthand for --field tags=<value>.
|
--tag <str> Shorthand for --field tags=<value>.
|
||||||
--push Write the file into the captured repositories (Guideline
|
--push Write the file into the captured repositories
|
||||||
Push Gate).
|
(Guideline Push Gate).
|
||||||
--bundle <path> Only the repository of this captured bundle under raw/;
|
--bundle <list[Path]> Only the repository of this captured bundle under
|
||||||
repeatable.
|
raw/; repeatable.
|
||||||
--confirm <str> The token from a prior exit 42, once a human has approved
|
--confirm <str> The token from a prior exit 42, once a human has
|
||||||
it.
|
approved it.
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ Write the derived, read-only reading copy of `kb/` into the folders the `export`
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
[TARGET]... Targets to run; default: every configured target.
|
[TARGET]... <list[str]> Targets to run; default: every configured target.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
|
|||||||
@@ -88,22 +88,22 @@ Find pages in `kb/` by text and/or frontmatter.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
text Text to search for. Omit it to run a pure frontmatter query.
|
text <str> Text to search for. Omit it to run a pure frontmatter query.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f, --field <str> Frontmatter predicate, repeatable (AND). Forms:
|
-f, --field <list[str]> Frontmatter predicate, repeatable (AND). Forms:
|
||||||
field=value, field~substring, 'field>=value', 'field:*'
|
field=value, field~substring, 'field>=value',
|
||||||
(present), '!field' (absent).
|
'field:*' (present), '!field' (absent).
|
||||||
--kind <str> Shorthand for --field kind=<value>.
|
--kind <str> Shorthand for --field kind=<value>.
|
||||||
--subtype <str> Shorthand for --field subtype=<value>.
|
--subtype <str> Shorthand for --field subtype=<value>.
|
||||||
--collection <str> Shorthand for --field collection=<value>.
|
--collection <str> Shorthand for --field collection=<value>.
|
||||||
--tag <str> Shorthand for --field tags=<value>.
|
--tag <str> Shorthand for --field tags=<value>.
|
||||||
--regex Treat the query as a regex. Off by default: terms are
|
--regex Treat the query as a regex. Off by default: terms are
|
||||||
literal.
|
literal.
|
||||||
--limit <int> Maximum number of results. 0 for no limit. A capped result
|
--limit <int> Maximum number of results. 0 for no limit. A capped
|
||||||
says so. [default: 50]
|
result says so. [default: 50]
|
||||||
--sort <str> Sort by a result field; prefix with '-' to reverse, e.g.
|
--sort <str> Sort by a result field; prefix with '-' to reverse,
|
||||||
-modified.
|
e.g. -modified.
|
||||||
--backend <str> Search backend(s), comma-separated. Default 'rg' (or
|
--backend <str> Search backend(s), comma-separated. Default 'rg' (or
|
||||||
$WIKITOOL_SEARCH_BACKEND).
|
$WIKITOOL_SEARCH_BACKEND).
|
||||||
--matches Print the matching lines under each result.
|
--matches Print the matching lines under each result.
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ tools/wikitool sync --confirm-rebase <token> # re-run after exit 42, once the
|
|||||||
**Behaviour**
|
**Behaviour**
|
||||||
|
|
||||||
- Fetches `<remote>/<branch>`, then: fast-forwards when only the remote moved; rebases the local commits on top when both sides moved but touched disjoint files; exits 42 (Rebase-Review Gate) when both sides touched the same file.
|
- Fetches `<remote>/<branch>`, then: fast-forwards when only the remote moved; rebases the local commits on top when both sides moved but touched disjoint files; exits 42 (Rebase-Review Gate) when both sides touched the same file.
|
||||||
- Files `wikitool` generates (`kb/index.md`, `kb/log.md`, `kb/provenance.md`, every `kb/**/INDEX.md`) never count as an overlap and never reach the gate. Where they are what stops git - uncommitted ones in the way of a fast-forward or rebase, or a rebase conflict in them - they are merged mechanically: `kb/log.md` becomes the incoming log plus the entries only this side appended, and the catalog and `kb/provenance.md` are regenerated from the merged pages and left as an uncommitted change. A reconcile git can do on its own is unchanged and regenerates nothing.
|
- Files `wikitool` generates (`kb/index.md`, `kb/log.md`, `kb/provenance.md`, every `kb/**/INDEX.md`) never count as an overlap and never reach the gate. Where they are what stops git - uncommitted ones in the way of a fast-forward or rebase, or a rebase conflict in them - they are merged mechanically: `kb/log.md` becomes the incoming log plus the entries only this side appended, and the catalog and `kb/provenance.md` are regenerated from the merged pages and left as an uncommitted change. When only `kb/log.md` stood in the way - an open log entry, nothing else generated - the catalog is not rebuilt: the incoming one stays, and just the local entries are appended again. A reconcile git can do on its own is unchanged and regenerates nothing.
|
||||||
- Uncommitted changes that no incoming commit touches do not stop a rebase: they are carried through it (`git rebase --autostash`) and come back unchanged.
|
- Uncommitted changes that no incoming commit touches do not stop a rebase: they are carried through it (`git rebase --autostash`) and come back unchanged.
|
||||||
- Before anything is set aside, the working tree is stored as a commit under `refs/wikitool/reconcile-backup`. A successful reconcile drops it; a failed one restores the working tree and names the ref.
|
- Before anything is set aside, the working tree is stored as a commit under `refs/wikitool/reconcile-backup`. A successful reconcile drops it; a failed one restores the working tree and names the ref.
|
||||||
- A refused call performs no rebase attempt and leaves the branch where it was.
|
- A refused call performs no rebase attempt and leaves the branch where it was.
|
||||||
@@ -55,7 +55,7 @@ tools/wikitool sync --confirm-rebase <token> # re-run after exit 42, once the
|
|||||||
|
|
||||||
- Changes files: yes
|
- Changes files: yes
|
||||||
- Idempotent: yes
|
- Idempotent: yes
|
||||||
- Atomic: No - fetch, then at most one merge/rebase attempt, aborted cleanly on failure with the working tree restored; a success that merged generated files then rewrites the catalog
|
- Atomic: No - fetch, then at most one merge/rebase attempt, aborted cleanly on failure with the working tree restored; a success that merged generated files then rewrites the catalog, unless `kb/log.md` was the only one
|
||||||
- Counts toward the session call budget: yes
|
- Counts toward the session call budget: yes
|
||||||
- Can reach the network: yes
|
- Can reach the network: yes
|
||||||
- Gates: rebase-review - see [exit codes and gates](../exit-codes.md)
|
- Gates: rebase-review - see [exit codes and gates](../exit-codes.md)
|
||||||
@@ -101,7 +101,7 @@ Reconcile with `<remote>/<branch>`, then stage all changes, commit, and push.
|
|||||||
at/above which clearance is required. [default: 10]
|
at/above which clearance is required. [default: 10]
|
||||||
--remote <str> Git remote to push to [default: origin]
|
--remote <str> Git remote to push to [default: origin]
|
||||||
--branch <str> Branch to push [default: main]
|
--branch <str> Branch to push [default: main]
|
||||||
--path <str> Limit this publish to a path (repeatable). Lets a
|
--path <list[str]> Limit this publish to a path (repeatable). Lets a
|
||||||
large change be committed in reviewable batches
|
large change be committed in reviewable batches
|
||||||
instead of one opaque commit - the Mass-Update Gate
|
instead of one opaque commit - the Mass-Update Gate
|
||||||
then counts only the files in scope.
|
then counts only the files in scope.
|
||||||
@@ -121,7 +121,7 @@ tools/wikitool publish --confirm-rebase <token> --message "ingest: docker-cheats
|
|||||||
- Order: branch check and Publish-Remote Gate, then the reconcile with `<remote>/<branch>`, then the Mass-Update Gate, then `git add -A`, commit and push. `--no-push` skips all but the Mass-Update Gate and the commit.
|
- Order: branch check and Publish-Remote Gate, then the reconcile with `<remote>/<branch>`, then the Mass-Update Gate, then `git add -A`, commit and push. `--no-push` skips all but the Mass-Update Gate and the commit.
|
||||||
- Without `--no-push`, a remote that is not configured or cannot be reached ends the call with exit 1 at the reconcile - before the gate, `git add` and the commit, and also on a clean tree. Nothing is committed, the index and the working tree are unchanged, and the message names `--no-push` as the way to a local commit. The next `publish` that reaches the remote pushes that commit along with whatever is new. A remote that answers but has no `<branch>` yet (a new, empty repository) is not this case: the first publish of an instance commits and pushes as before.
|
- Without `--no-push`, a remote that is not configured or cannot be reached ends the call with exit 1 at the reconcile - before the gate, `git add` and the commit, and also on a clean tree. Nothing is committed, the index and the working tree are unchanged, and the message names `--no-push` as the way to a local commit. The next `publish` that reaches the remote pushes that commit along with whatever is new. A remote that answers but has no `<branch>` yet (a new, empty repository) is not this case: the first publish of an instance commits and pushes as before.
|
||||||
- Reconcile: fetches `<remote>/<branch>`, fast-forwards when only the remote moved, rebases the local commits on top when both sides moved but touched disjoint files, and exits 42 (Rebase-Review Gate) when both sides touched the same file. A refused reconcile performs no rebase attempt. The `--confirm-rebase` token covers the exact upstream state and the set of files touched on both sides.
|
- Reconcile: fetches `<remote>/<branch>`, fast-forwards when only the remote moved, rebases the local commits on top when both sides moved but touched disjoint files, and exits 42 (Rebase-Review Gate) when both sides touched the same file. A refused reconcile performs no rebase attempt. The `--confirm-rebase` token covers the exact upstream state and the set of files touched on both sides.
|
||||||
- Generated files are never an overlap: where they are all that stops the reconcile, it merges them as `sync` does (both sides' log entries kept, the catalog and `kb/provenance.md` regenerated) and carries uncommitted changes no incoming commit touches through the rebase. The proactive reconcile runs before staging, so this publish commits the regenerated files - with `--path` too, see there; on the retry after a rejected push they get a commit of their own before the second push.
|
- Generated files are never an overlap: where they are all that stops the reconcile, it merges them as `sync` does (both sides' log entries kept, the catalog and `kb/provenance.md` regenerated unless the log alone stood in the way) and carries uncommitted changes no incoming commit touches through the rebase. The proactive reconcile runs before staging, so this publish commits the regenerated files - with `--path` too, see there; on the retry after a rejected push they get a commit of their own before the second push.
|
||||||
- The push target must be the checked-out branch; this is checked before anything is staged. The unborn branch of a fresh `git init -b main` counts as checked out, so the first publish of a new instance works; a real detached HEAD is refused.
|
- The push target must be the checked-out branch; this is checked before anything is staged. The unborn branch of a fresh `git init -b main` counts as checked out, so the first publish of a new instance works; a real detached HEAD is refused.
|
||||||
- With nothing new to stage, a local commit the remote lacks is still pushed: one left behind by an earlier publish whose push failed, or every commit when the remote answers but does not have the branch yet (a new, empty remote repository).
|
- With nothing new to stage, a local commit the remote lacks is still pushed: one left behind by an earlier publish whose push failed, or every commit when the remote answers but does not have the branch yet (a new, empty remote repository).
|
||||||
- A rejected push that finds the remote unreachable on its one retry reports the original push error.
|
- A rejected push that finds the remote unreachable on its one retry reports the original push error.
|
||||||
|
|||||||
@@ -33,22 +33,23 @@ Scaffold a new wiki page of any type.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
type_name Type name, e.g. entity|concept|source|comparison (see `wikitool
|
type_name <str> Type name, e.g. entity|concept|source|comparison (see
|
||||||
types list`) [required]
|
`wikitool types list`) [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name <str> Page title (a type's title_prefix is added automatically)
|
--name <str> Page title (a type's title_prefix is added automatically)
|
||||||
[required]
|
[required]
|
||||||
--type <str> Override the type-spec path (defaults to the one named by
|
--type <str> Override the type-spec path (defaults to the one named by
|
||||||
TYPE_NAME)
|
TYPE_NAME)
|
||||||
--set <str> Frontmatter field, repeatable: --set entity_type=tool --set
|
--set <list[str]> Frontmatter field, repeatable: --set entity_type=tool --set
|
||||||
tags=a,b. Array values split on commas (escape a literal one as
|
tags=a,b. Array values split on commas (escape a literal
|
||||||
\,); repeating --set for an array field appends instead of
|
one as \,); repeating --set for an array field appends
|
||||||
replacing
|
instead of replacing
|
||||||
--resume `project` only: confirm a human has completed the manual tracker
|
--resume `project` only: confirm a human has completed the manual
|
||||||
step an earlier HumanInterventionRequired refusal asked for, so
|
tracker step an earlier HumanInterventionRequired refusal
|
||||||
this run continues to page creation instead of refusing the now-
|
asked for, so this run continues to page creation instead
|
||||||
existing tracker project as a collision.
|
of refusing the now-existing tracker project as a
|
||||||
|
collision.
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -94,6 +95,7 @@ tools/wikitool new project --name "Homelab migration" --set responsibility=infra
|
|||||||
- `1` - A `raw_files` path does not exist
|
- `1` - A `raw_files` path does not exist
|
||||||
- `1` - A capture field the type-spec requires is missing, or set to `unknown`
|
- `1` - A capture field the type-spec requires is missing, or set to `unknown`
|
||||||
- `1` - `--resume` with a type other than `project`
|
- `1` - `--resume` with a type other than `project`
|
||||||
|
- `1` - new project: The name is already the title of a `kb/` page - typically the entity page of the artifact the project concerns
|
||||||
- `1` - new project: The name is already taken in the tracker (case-insensitively; for `caldav` against every list in the account)
|
- `1` - new project: The name is already taken in the tracker (case-insensitively; for `caldav` against every list in the account)
|
||||||
- `1` - new project: The configured access path has no write path (Super Productivity's `access: "snapshot"`)
|
- `1` - new project: The configured access path has no write path (Super Productivity's `access: "snapshot"`)
|
||||||
- `1` - new project: The page write failed after the tracker project was confirmed to exist
|
- `1` - new project: The page write failed after the tracker project was confirmed to exist
|
||||||
@@ -309,14 +311,15 @@ Bump a page's `modified:` date and optionally rewrite its other frontmatter fiel
|
|||||||
--date <str> Date to record (YYYY-MM-DD). `modified:` defaults to
|
--date <str> Date to record (YYYY-MM-DD). `modified:` defaults to
|
||||||
today; a source's `date:` is its publication date and
|
today; a source's `date:` is its publication date and
|
||||||
changes only when given here.
|
changes only when given here.
|
||||||
--set <str> Replace a frontmatter field, repeatable: --set tags=a,b.
|
--set <list[str]> Replace a frontmatter field, repeatable: --set tags=a,b.
|
||||||
Array values split on commas (escape a literal one as \,);
|
Array values split on commas (escape a literal one as
|
||||||
repeating --set for one array field appends within this
|
\,); repeating --set for one array field appends within
|
||||||
call. Page-reference fields belong to `xref`, not here
|
this call. Page-reference fields belong to `xref`, not
|
||||||
--add <str> Append elements to an array field without naming the whole
|
here
|
||||||
list: --add tags=x. Elements already present are left
|
--add <list[str]> Append elements to an array field without naming the
|
||||||
alone
|
whole list: --add tags=x. Elements already present are
|
||||||
--remove <str> Drop elements from an array field: --remove tags=x.
|
left alone
|
||||||
|
--remove <list[str]> Drop elements from an array field: --remove tags=x.
|
||||||
Removing an absent element succeeds and says so
|
Removing an absent element succeeds and says so
|
||||||
--no-date Only change the given fields; leave the modified/date
|
--no-date Only change the given fields; leave the modified/date
|
||||||
field alone
|
field alone
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ Bringing new material into `raw/`: fetching and capturing it, seeing what is wai
|
|||||||
- [`raw fetch`](#raw-fetch)
|
- [`raw fetch`](#raw-fetch)
|
||||||
- [`raw login`](#raw-login)
|
- [`raw login`](#raw-login)
|
||||||
- [`raw derive`](#raw-derive)
|
- [`raw derive`](#raw-derive)
|
||||||
|
- [`raw clarify`](#raw-clarify)
|
||||||
- [`raw capture`](#raw-capture)
|
- [`raw capture`](#raw-capture)
|
||||||
- [`raw status`](#raw-status)
|
- [`raw status`](#raw-status)
|
||||||
- [`raw pending`](#raw-pending)
|
- [`raw pending`](#raw-pending)
|
||||||
@@ -34,7 +35,7 @@ Capture a web page the user names into `incoming/`: the HTML as received plus a
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
url The http(s) URL to fetch
|
url <str> The http(s) URL to fetch
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--html <path> Derive the text from this HTML file under incoming/ (saved from
|
--html <path> Derive the text from this HTML file under incoming/ (saved from
|
||||||
@@ -116,7 +117,7 @@ Let the user sign in to a website once, in a visible browser window, and store t
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
host The website's host, such as www.example.org [required]
|
host <str> The website's host, such as www.example.org [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
@@ -171,7 +172,7 @@ Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`,
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
path A file or a folder directly in incoming/ [required]
|
path <path> A file or a folder directly in incoming/ [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name <str> Folder stem for a single file instead of the file's own stem
|
--name <str> Folder stem for a single file instead of the file's own stem
|
||||||
@@ -223,6 +224,64 @@ tools/wikitool raw derive incoming/scans.zip
|
|||||||
- `wikitool raw accept` - promotes the folder into `raw/`
|
- `wikitool raw accept` - promotes the folder into `raw/`
|
||||||
- `instructions/wiki-ingest/SKILL.md` - where a PDF, mail or Office file to ingest starts
|
- `instructions/wiki-ingest/SKILL.md` - where a PDF, mail or Office file to ingest starts
|
||||||
|
|
||||||
|
## `raw clarify`
|
||||||
|
|
||||||
|
Write the operator's answers to an ingest's questions about a source as a companion file in `incoming/`, to be promoted with the source instead of as a source of its own.
|
||||||
|
|
||||||
|
**Synopsis**
|
||||||
|
|
||||||
|
- `wikitool raw clarify incoming/<entry> --item "<answer>" [--item "<answer>" ...]` - A file, a file of a stem bundle, or a folder in `incoming/`: write `<stem>.clarifications.md` beside it, or `clarifications.md` inside the folder
|
||||||
|
- `wikitool raw clarify --page "<Title>" --item "<answer>" [--item "<answer>" ...]` - A source already in `raw/`: write the companion file to `incoming/` and print the `raw accept --page` line that adds it to the source's bundle
|
||||||
|
|
||||||
|
**Options**
|
||||||
|
|
||||||
|
```text
|
||||||
|
Arguments:
|
||||||
|
entry <path> A file or folder directly in incoming/ (omit with --page)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--item <list[str]> One answer, one line; repeat for more
|
||||||
|
--page <str> Clarify the source of this existing page instead of an
|
||||||
|
entry of incoming/
|
||||||
|
-h, --help Show this message and exit.
|
||||||
|
```
|
||||||
|
|
||||||
|
**Examples**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tools/wikitool raw clarify incoming/meeting.vtt --item "Termindatum: 2026-11-12"
|
||||||
|
tools/wikitool raw clarify incoming/workshop --item "Teilnehmer: A, B" --item "KI = künstliche Intelligenz"
|
||||||
|
tools/wikitool raw clarify --page "Source - Meeting" --item "Projekt: Alpha"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Behaviour**
|
||||||
|
|
||||||
|
- Writes into `incoming/` only, never into `raw/`, and reads no network. The name and the place are computed, never chosen: `incoming/<stem>.clarifications.md` for a file or a stem bundle, `incoming/<folder>/clarifications.md` for a folder; a taken name gets `-2`, `-3` before the extension, and no existing file is overwritten.
|
||||||
|
- The file starts with a fixed header (`kind`, `written_by`, `clarifies` - the file(s) it belongs to, `answered` - today's date, `by`), then one bullet per `--item`, word for word as passed. An item is one line; its language is the one the operator answered in.
|
||||||
|
- What belongs in it is what this ingest session asked about this source and the operator answered in a few points - the date of the recording, who took part, an abbreviation, a transcription error. What the operator adds unprompted, or says about a subject of its own, stays a source of its own (`instructions/wiki-ingest/SKILL.md`).
|
||||||
|
- `raw pending` lists the companion file with its original as one candidate, and `raw accept` promotes both as one bundle named after the original, whatever order the files are passed in. A companion file with no original in the call (or, with `--page`, in the page's raw_files:) is refused.
|
||||||
|
- `--page` names the file after the stem of the source's first file and prints the `raw accept --page` line with the page's own `fidelity` and `authority` - a bundle has one pair, and the companion file inherits it.
|
||||||
|
|
||||||
|
**Properties**
|
||||||
|
|
||||||
|
- Changes files: yes
|
||||||
|
- Idempotent: no
|
||||||
|
- Atomic: Yes - everything is checked before the one write, and the file is created exclusively, so an existing file is never overwritten
|
||||||
|
- Counts toward the session call budget: yes
|
||||||
|
- Can reach the network: no
|
||||||
|
|
||||||
|
**Exit codes**
|
||||||
|
|
||||||
|
- `0` - success
|
||||||
|
- `1` - No `--item`, an empty or multi-line one, an entry that is not directly in `incoming/`, a captured bundle, or neither (or both of) an entry and `--page`
|
||||||
|
- `1` - `--page` names no page, or one without `raw_files:`
|
||||||
|
|
||||||
|
**See also**
|
||||||
|
|
||||||
|
- `raw/CONTRACT.md` "Getting a file in: incoming/" - the companion file and its bundle
|
||||||
|
- `wikitool raw accept` - promotes the companion file with its original
|
||||||
|
- `instructions/wiki-ingest/SKILL.md` - when to ask, and where the answer goes
|
||||||
|
|
||||||
## `raw capture`
|
## `raw capture`
|
||||||
|
|
||||||
Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
||||||
@@ -236,11 +295,11 @@ Capture documentation from a git repository into `incoming/<bundle>/`, with a ma
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
repo_url The repository URL (ssh://, https:// or user@host:path)
|
repo_url <str> The repository URL (ssh://, https:// or user@host:path)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--ref <str> A branch name (main) or a tag pattern (v*)
|
--ref <str> A branch name (main) or a tag pattern (v*)
|
||||||
--path <str> A glob over the repository's paths; repeatable
|
--path <list[str]> A glob over the repository's paths; repeatable
|
||||||
--name <str> The bundle name - the folder in incoming/ and under raw/
|
--name <str> The bundle name - the folder in incoming/ and under raw/
|
||||||
--fidelity <str> How faithful the capture is (see `wikitool types describe
|
--fidelity <str> How faithful the capture is (see `wikitool types describe
|
||||||
source`)
|
source`)
|
||||||
@@ -411,9 +470,9 @@ Promote one or more files, or one folder, from `incoming/` into `raw/`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
files... One or more files directly in incoming/, all belonging to the same
|
files... <list[Path]> One or more files directly in incoming/, all belonging
|
||||||
source - or one folder in incoming/, accepted whole as one source
|
to the same source - or one folder in incoming/,
|
||||||
[required]
|
accepted whole as one source [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--fidelity <str> How faithful the capture is (see `wikitool types
|
--fidelity <str> How faithful the capture is (see `wikitool types
|
||||||
@@ -512,7 +571,8 @@ Pull material from the configured `folder` and `command` intake channels into th
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
names... Channels to collect from; all pulled channels when none is named
|
names... <list[str]> Channels to collect from; all pulled channels when none
|
||||||
|
is named
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
@@ -615,7 +675,7 @@ Print one submission's manifest in full.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
submission_id A submission id from `upload list` [required]
|
submission_id <str> A submission id from `upload list` [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--json
|
--json
|
||||||
@@ -665,7 +725,7 @@ tools/wikitool upload show <id>
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
submission_id A submission id from `upload list` [required]
|
submission_id <str> A submission id from `upload list` [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--confirm <str> The token from a prior refusal, once a human has reviewed it
|
--confirm <str> The token from a prior refusal, once a human has reviewed it
|
||||||
@@ -720,7 +780,7 @@ Delete a submission's material, keeping only its ledger trail.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
submission_id A submission id from `upload list` [required]
|
submission_id <str> A submission id from `upload list` [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--reason <str> Why this submission was declined [required]
|
--reason <str> Why this submission was declined [required]
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ Print one type's full contract.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
name Type name, e.g. 'entity' (see `types list`) [required]
|
name <str> Type name, e.g. 'entity' (see `types list`) [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--json Print raw findings as JSON
|
--json Print raw findings as JSON
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
type: types/instruction.md
|
||||||
|
name: dependency-locks
|
||||||
|
description: How the Python packages of the stack are pinned and moved - the four lock files under tools/, regenerating them with the 7-day cooldown, lifting one package at once for a security fix without ever lowering it again, checking that no locked package was too young, and what a red nightly audit or fresh-resolution run asks for.
|
||||||
|
---
|
||||||
|
# Pin the stack's packages, and move them on purpose
|
||||||
|
|
||||||
|
Every Python package the stack or its CI installs comes from a lock under `tools/`: exact
|
||||||
|
versions with SHA-256 hashes, transitive packages included, installed with
|
||||||
|
`pip install --require-hashes`. Before Gitea #245 the requirement files carried lower bounds
|
||||||
|
only, CI installed whatever was newest that morning, and an instance kept the packages of the day
|
||||||
|
it was set up - CI went red after four quiet weeks when pytest 9.2 and typer 0.29.1 came out
|
||||||
|
(#243), and a compromised release would have reached the next install unchecked. Pins answer both
|
||||||
|
sides of faster attacks: nothing new flows in unchecked, and a known hole is closed by a
|
||||||
|
deliberate lift, at once.
|
||||||
|
|
||||||
|
<!-- wikitool:toc -->
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
- [The files](#the-files)
|
||||||
|
- [When to run](#when-to-run)
|
||||||
|
- [Steps](#steps)
|
||||||
|
- [Decision points](#decision-points)
|
||||||
|
- [Scope](#scope)
|
||||||
|
<!-- /wikitool:toc -->
|
||||||
|
|
||||||
|
## The files
|
||||||
|
|
||||||
|
| Source (lower bounds) | Lock | Installed by | Ships |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `tools/requirements.txt` | `tools/requirements.lock` | the preflight, every run whose stamp differs | yes |
|
||||||
|
| `tools/requirements-mcp.txt` | `tools/requirements-mcp.lock` | the user, by hand (command in the source's head); CI | yes |
|
||||||
|
| `tools/requirements-browser.txt` | `tools/requirements-browser.lock` | the preflight, `--with browser` and after | yes |
|
||||||
|
| `tools/requirements-dev.txt` | `tools/requirements-dev.lock` | CI and a developer: pytest, pytest-cov, radicale, pip-audit, uv | no (`TOOLS_DEV_ONLY`) |
|
||||||
|
|
||||||
|
`tools/lock_requirements.py` (dev-only) is the one way a lock is written. It resolves the four in
|
||||||
|
that order, each constrained by every lock above it (`-c`), because all of them land in one venv:
|
||||||
|
a package in two locks has one version, and a later `pip install -r` never moves a package an
|
||||||
|
earlier lock placed. `test_dependency_locks.py` holds every property below on each push.
|
||||||
|
|
||||||
|
The locks resolve for the Python minimum in `tools/prerequisites.txt` with `--universal`, so one
|
||||||
|
file serves Linux, macOS and Windows across the admitted span. A source file is never installed
|
||||||
|
itself - not by the preflight, not by CI (the same test reads every workflow for it).
|
||||||
|
|
||||||
|
## When to run
|
||||||
|
|
||||||
|
- **A regular lift** - a new package version is wanted, a source file's floor moved, or a lock is
|
||||||
|
simply due. It is a small stack package of its own: the locks, a patch bump, `publish`.
|
||||||
|
- **A security lift** - the nightly's `pip-audit` step is red, or an advisory names a locked
|
||||||
|
version. Same day, one package, no cooldown.
|
||||||
|
- **The nightly's fresh-resolution step is red** - today's regular lift would break the suite.
|
||||||
|
Not a lift yet: the defect it shows is fixed first, in a package of its own, and the lift
|
||||||
|
follows with it.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
1. **Have `uv` on `PATH`.** `requirements-dev.lock` carries it; in a checkout with the test tools
|
||||||
|
installed, `tools/.venv/bin/uv` is it.
|
||||||
|
|
||||||
|
2. **Regular lift - regenerate every lock:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PATH="$PWD/tools/.venv/bin:$PATH" python3 tools/lock_requirements.py
|
||||||
|
```
|
||||||
|
|
||||||
|
It sets `--exclude-newer` to now minus 7 days: a file uploaded later is not considered. A
|
||||||
|
compromised release is usually found and pulled within hours to days; the cooldown lets that
|
||||||
|
happen before a lock can take one. Exceptions from an earlier security lift are carried over
|
||||||
|
while still younger than the cutoff and dropped once it passes them (step 3).
|
||||||
|
|
||||||
|
3. **Security lift - one package, at once.** `pip-audit` names the package and the first fixed
|
||||||
|
version X:
|
||||||
|
|
||||||
|
- Raise the floor in its source file to `<name>>=X`. It stays there for good - it is simply
|
||||||
|
true that vulnerable versions are no longer taken, and it is what keeps every later lift
|
||||||
|
from lowering the package again.
|
||||||
|
- Regenerate with an exception for that package alone, up to X's upload time plus a minute
|
||||||
|
(PyPI's JSON API shows it as `upload_time_iso_8601` per file):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PATH="$PWD/tools/.venv/bin:$PATH" python3 tools/lock_requirements.py \
|
||||||
|
--exception <name>=<upload time of X + 1 minute, e.g. 2026-11-17T09:31:00Z>
|
||||||
|
```
|
||||||
|
|
||||||
|
uv writes the exception into each lock's head beside the cutoff. **The invariant: no later
|
||||||
|
lift lowers the package below X.** While X is younger than the cooldown, the script carries
|
||||||
|
the exception into the next regular lift; once the cutoff has passed X, the exception is no
|
||||||
|
longer needed and drops out, and the floor stays. Without both, a lift would fail loudly -
|
||||||
|
"No solution ... filtered by `exclude-newer`" - rather than lower the package silently: that
|
||||||
|
is the floor doing its job, not a reason to remove it.
|
||||||
|
|
||||||
|
4. **Check the result.**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd tools && .venv/bin/python -m pytest -q chemenu/tests/test_dependency_locks.py
|
||||||
|
```
|
||||||
|
|
||||||
|
It holds: an exact version and at least one SHA-256 per package; every source requirement
|
||||||
|
pinned at or above its floor; one version per package across the four locks; each lock
|
||||||
|
constrained by the ones before it; and **no package younger than 7 days** - the lock's
|
||||||
|
`--exclude-newer` lies at least 7 days before the lock's last commit (before now, while the
|
||||||
|
file differs from `HEAD`). A security lift's package is the one exception, visible as
|
||||||
|
`--exclude-newer-package` in the head. Read the diff as well: a package that moved a major
|
||||||
|
version, or one new in a lock, is worth a line in the changelog entry.
|
||||||
|
|
||||||
|
5. **Install and run the suite against the new locks** - the preflight installs
|
||||||
|
`requirements.lock` by itself once its hash changed; the other two by hand:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tools/preflight.sh
|
||||||
|
tools/.venv/bin/python -m pip install --require-hashes -r tools/requirements-mcp.lock
|
||||||
|
tools/.venv/bin/python -m pip install --require-hashes -r tools/requirements-dev.lock
|
||||||
|
cd tools && .venv/bin/python -m pytest -q
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Bump and publish.** A lock under `tools/` reaches every instance - its next preflight moves
|
||||||
|
the venv to it - so it is a patch bump ([version-parts.md](version-parts.md)) with a changelog
|
||||||
|
entry naming the lift, then [publish-and-ci.md](publish-and-ci.md). A lift that touches
|
||||||
|
`requirements.lock` also starts the `Converters` workflow.
|
||||||
|
|
||||||
|
## Decision points
|
||||||
|
|
||||||
|
- **The nightly's `pip-audit` step is red, but no fixed version exists yet?** Nothing to lift.
|
||||||
|
Name the advisory and whether the stack reaches the vulnerable code in the topic issue, and
|
||||||
|
check again when a fix is released.
|
||||||
|
- **A regular lift fails with "No solution found ... filtered by `exclude-newer`"?** A floor in a
|
||||||
|
source file names a version younger than the cutoff - usually a security lift whose exception
|
||||||
|
was lost. Restore the exception from the lock's head in `git log -p`; never lower the floor.
|
||||||
|
- **A package wants a Python outside the span?** The resolution for the minimum fails or picks an
|
||||||
|
old version. The span is a design decision in `tools/prerequisites.txt`, not something a lift
|
||||||
|
moves; take it to `stack-dev`.
|
||||||
|
- **A new dependency?** Add it to the source file that matches who needs it, with a floor, then
|
||||||
|
regenerate. A package only the origin repository's tests need goes into
|
||||||
|
`requirements-dev.txt`, never into a lock that ships.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
The origin repository only - `dist export` ships the three runtime locks, not this file, the
|
||||||
|
script or the dev lock. The span of Python versions itself is `tools/prerequisites.txt` and
|
||||||
|
[instructions/preflight.md](../preflight.md); reasons for the design are Gitea #245.
|
||||||
@@ -40,10 +40,12 @@ formality after it - which is why waiting for it belongs to the phase that wrote
|
|||||||
|
|
||||||
3. **Wait for CI on the published commit, this way.** One runner serves the repository and it
|
3. **Wait for CI on the published commit, this way.** One runner serves the repository and it
|
||||||
currently runs **no jobs in parallel**, so the jobs of a push run **one after another**: CI's `verify` job (about
|
currently runs **no jobs in parallel**, so the jobs of a push run **one after another**: CI's `verify` job (about
|
||||||
**8 minutes**) and `pwsh` job (about **3 minutes**) first, then the second run a push to
|
**8 minutes**), `pwsh` job (about **3 minutes**) and `python314` job (the suite on the upper
|
||||||
|
end of the Python span, about **6 minutes**) first, then the second run a push to
|
||||||
`main` starts - `release.yml`, preceded by the `Converters` check - which waits `queued`
|
`main` starts - `release.yml`, preceded by the `Converters` check - which waits `queued`
|
||||||
until CI is done and then takes about **1 minute**. From the push to the last green run that
|
until CI is done and then takes about **1 minute**. From the push to the last green run that
|
||||||
is about **12 minutes** (measured 10.5 to 13 minutes, October 2026); a second run still
|
is about **18 minutes** (CI measured at 17.6 minutes in November 2026, run 872: `verify`
|
||||||
|
8.8, `pwsh` 3.2, `python314` 5.6); a second run still
|
||||||
`queued` while CI works is the runner's order, not a hang. The times below rest on that
|
`queued` while CI works is the runner's order, not a hang. The times below rest on that
|
||||||
setup (`ENVIRONMENT.md` § CI records it); once the runner takes parallel jobs, measure them
|
setup (`ENVIRONMENT.md` § CI records it); once the runner takes parallel jobs, measure them
|
||||||
again and rewrite them here.
|
again and rewrite them here.
|
||||||
@@ -52,8 +54,8 @@ formality after it - which is why waiting for it belongs to the phase that wrote
|
|||||||
`ENVIRONMENT.md` lists (the Gitea MCP's `actions_run_read`, `list_runs`), right after
|
`ENVIRONMENT.md` lists (the Gitea MCP's `actions_run_read`, `list_runs`), right after
|
||||||
`publish`, to get their ids. **Never anonymously via `curl`:** Gitea answers the Actions
|
`publish`, to get their ids. **Never anonymously via `curl`:** Gitea answers the Actions
|
||||||
API with `401 token is required` even for this public repo.
|
API with `401 token is required` even for this public repo.
|
||||||
- Check again after about 11 minutes, then every 2 minutes.
|
- Check again after about 16 minutes, then every 2 minutes.
|
||||||
- **Give up after 25 minutes** - twice the usual time, so a slow day is not mistaken for a
|
- **Give up after 35 minutes** - about twice the usual time, so a slow day is not mistaken for a
|
||||||
hang - and hand the open runs to the user by id and link, rather than waiting on.
|
hang - and hand the open runs to the user by id and link, rather than waiting on.
|
||||||
- **Count from when the runner is free, not from the push.** Runs of an earlier push that are
|
- **Count from when the runner is free, not from the push.** Runs of an earlier push that are
|
||||||
still open when you publish run first, and the runner does not keep push order: it may take
|
still open when you publish run first, and the runner does not keep push order: it may take
|
||||||
@@ -69,11 +71,11 @@ formality after it - which is why waiting for it belongs to the phase that wrote
|
|||||||
**Converter changes have a second run.** When the published commit touches the converter
|
**Converter changes have a second run.** When the published commit touches the converter
|
||||||
surface - `tools/chemenu/filters/`, `tools/chemenu/commands/raw/derive.py` or `accept.py`,
|
surface - `tools/chemenu/filters/`, `tools/chemenu/commands/raw/derive.py` or `accept.py`,
|
||||||
`tools/chemenu/tests/test_raw_derive*.py`, `tools/chemenu/tests/binary_formats.py`,
|
`tools/chemenu/tests/test_raw_derive*.py`, `tools/chemenu/tests/binary_formats.py`,
|
||||||
`tools/requirements.txt` or `.gitea/workflows/converters.yml` - the `Converters` workflow
|
`tools/requirements.txt`, `tools/requirements.lock` or `.gitea/workflows/converters.yml` - the `Converters` workflow
|
||||||
(`converters.yml`) starts by itself with CI and derives the real documents of the private
|
(`converters.yml`) starts by itself with CI and derives the real documents of the private
|
||||||
test corpus. Deriving the corpus takes about **10 minutes** on top of CI, on the same
|
test corpus. Deriving the corpus takes about **10 minutes** on top of CI, on the same
|
||||||
runner and after it, so the last run finishes about **22 minutes** after the push; give up
|
runner and after it, so the last run finishes about **28 minutes** after the push; give up
|
||||||
after **35 minutes** instead of 25, and count a red run like a red CI run (step 4). Start it by hand
|
after **45 minutes** instead of 35, and count a red run like a red CI run (step 4). Start it by hand
|
||||||
(`actions_run_write`, `dispatch_workflow` on `main`) when only the private repository changed
|
(`actions_run_write`, `dispatch_workflow` on `main`) when only the private repository changed
|
||||||
or when the commit reaches the converters only indirectly. A release without suffix runs the
|
or when the commit reaches the converters only indirectly. A release without suffix runs the
|
||||||
same steps as the first job of `release.yml`, which the release waits for.
|
same steps as the first job of `release.yml`, which the release waits for.
|
||||||
|
|||||||
@@ -92,6 +92,11 @@ slash command for the operator, and stops.
|
|||||||
*good*, not merely working: the converters against reference tools over the private corpus,
|
*good*, not merely working: the converters against reference tools over the private corpus,
|
||||||
seven measures, markings judged against the original, a baseline moved only on purpose. Read it
|
seven measures, markings judged against the original, a baseline moved only on purpose. Read it
|
||||||
before designing a converter change, after building one, and when the corpus gains a file.
|
before designing a converter change, after building one, and when the corpus gains a file.
|
||||||
|
- [dependency-locks.md](dependency-locks.md) - the four lock files under `tools/`: how a lock
|
||||||
|
is regenerated with the 7-day cooldown, how one package is lifted at once for a security fix
|
||||||
|
without ever being lowered again, how the result is checked, and what a red nightly audit or
|
||||||
|
fresh-resolution run asks for. Read it before changing a `tools/requirements*.txt`, and when
|
||||||
|
the nightly's dependency steps are red.
|
||||||
- [doc-pull-through.md](doc-pull-through.md) - which document makes a claim about a touched
|
- [doc-pull-through.md](doc-pull-through.md) - which document makes a claim about a touched
|
||||||
surface (a `wikitool` command, a stage's rules, an `AGENTS.md` rule/gate/invariant, a
|
surface (a `wikitool` command, a stage's rules, an `AGENTS.md` rule/gate/invariant, a
|
||||||
README-shaped human doc, a `docs/` page's reasoning) and therefore needs updating alongside
|
README-shaped human doc, a `docs/` page's reasoning) and therefore needs updating alongside
|
||||||
|
|||||||
@@ -66,6 +66,18 @@ Both corpus fixtures therefore repoint it: `raw_dir` and `kb_dir` each set
|
|||||||
access, so repointing `ROOT` carries `KB_DIR`, `RAW_DIR` and the rest with it. A new fixture
|
access, so repointing `ROOT` carries `KB_DIR`, `RAW_DIR` and the rest with it. A new fixture
|
||||||
that builds a tree does the same thing - that is the rule here, not a per-test judgment.
|
that builds a tree does the same thing - that is the rule here, not a per-test judgment.
|
||||||
|
|
||||||
|
**Repoint a path with `set_config_path(monkeypatch, name, value)` from `conftest.py`, never with
|
||||||
|
`monkeypatch.setattr(config, name, value)`.** The names `config` resolves rather than stores
|
||||||
|
(`config.MANAGED_PATHS`: `ROOT` and everything derived from it) break `setattr`'s undo in a way
|
||||||
|
that depends on the pytest version. Up to 9.1 it read the old value through the module
|
||||||
|
`__getattr__` and wrote the resolved path back as a real attribute, so the name stopped
|
||||||
|
following `resolve_root()`; from 9.2 it reads the module dict instead and undoes with `delattr`,
|
||||||
|
which raises, because `hermetic_environment` has already dropped the binding. The first was
|
||||||
|
silent for as long as it lasted; the second turned CI red on the first run that installed
|
||||||
|
pytest 9.2. `set_config_path` patches the module dict
|
||||||
|
as a dict, whose undo copes with either, and a `pytest_runtest_teardown` hook in `conftest.py`
|
||||||
|
fails any test that still leaves a managed path bound after `monkeypatch` is done.
|
||||||
|
|
||||||
`kb_dir` did not, until Gitea #44. Two things came of that. A test calling
|
`kb_dir` did not, until Gitea #44. Two things came of that. A test calling
|
||||||
`kb_state.write_kb_state()` overwrote the real `.wikitool-kb.json`, which `git status` made
|
`kb_state.write_kb_state()` overwrote the real `.wikitool-kb.json`, which `git status` made
|
||||||
visible within the minute. Quieter and worse: `lint`'s collection lookup resolved a page
|
visible within the minute. Quieter and worse: `lint`'s collection lookup resolved a page
|
||||||
@@ -135,7 +147,8 @@ Whenever you add or change a test under `tools/chemenu/tests/`.
|
|||||||
a prefix loop beside it, as `WIKITOOL_SECRET_*` has. A variable the tool reads and the fixture does not clear
|
a prefix loop beside it, as `WIKITOOL_SECRET_*` has. A variable the tool reads and the fixture does not clear
|
||||||
is the exact hole this whole file is about, reopened.
|
is the exact hole this whole file is about, reopened.
|
||||||
|
|
||||||
5. **Writing a fixture that builds a tree?** Repoint `config.ROOT` at it and call
|
5. **Writing a fixture that builds a tree?** Repoint `config.ROOT` at it with
|
||||||
|
`set_config_path(monkeypatch, "ROOT", tree)` and call
|
||||||
`use_shipped_type_specs(monkeypatch)`, as `raw_dir` and `kb_dir` do - see
|
`use_shipped_type_specs(monkeypatch)`, as `raw_dir` and `kb_dir` do - see
|
||||||
[Which tree a test writes into](#which-tree-a-test-writes-into). A fixture that returns a
|
[Which tree a test writes into](#which-tree-a-test-writes-into). A fixture that returns a
|
||||||
path without repointing hands the code under test the real repository.
|
path without repointing hands the code under test the real repository.
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ that fails against theirs. The steps differ per tracker only in the profile and
|
|||||||
|
|
||||||
| Workflow | When | What |
|
| Workflow | When | What |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `ci.yml`, step "Live tracker suite (CalDAV)" | Every push and PR | Radicale as a process on loopback (`pip install radicale`), `CHEMENU_LIVE_REQUIRE=caldav`. The one half that needs no app and no display. |
|
| `ci.yml`, step "Live tracker suite (CalDAV)" | Every push and PR | Radicale as a process on loopback (from `tools/requirements-dev.lock`), `CHEMENU_LIVE_REQUIRE=caldav`. The one half that needs no app and no display. |
|
||||||
| `tracker-live.yml` | Nightly 05:00 UTC, and by hand | Both kinds, `CHEMENU_LIVE_REQUIRE=sp,caldav`, inside the `chemenu-sp-live` image. It logs the installed Super Productivity version and warns when it differs from the update channel. |
|
| `tracker-live.yml` | Nightly 05:00 UTC, and by hand | Both kinds, `CHEMENU_LIVE_REQUIRE=sp,caldav`, inside the `chemenu-sp-live` image. It logs the installed Super Productivity version and warns when it differs from the update channel. |
|
||||||
| `sp-live-image.yml` | Daily 04:10 UTC, and by hand | Builds `gitea.nehmer.net/torben/chemenu-sp-live` when the registry lacks the channel's current version, and once a month regardless. |
|
| `sp-live-image.yml` | Daily 04:10 UTC, and by hand | Builds `gitea.nehmer.net/torben/chemenu-sp-live` when the registry lacks the channel's current version, and once a month regardless. |
|
||||||
|
|
||||||
@@ -178,9 +178,9 @@ shows a new answer shape, and when the manifest's version is more than a few rel
|
|||||||
|
|
||||||
1. Get a Super Productivity to record from: the current `chemenu-sp-live` image with the
|
1. Get a Super Productivity to record from: the current `chemenu-sp-live` image with the
|
||||||
checkout mounted (`docker run --rm -v "$PWD:/work" -w /work/tools ...`, then a venv from
|
checkout mounted (`docker run --rm -v "$PWD:/work" -w /work/tools ...`, then a venv from
|
||||||
`requirements.txt` inside it), or any machine with the `.deb` installed and
|
`requirements.lock` inside it), or any machine with the `.deb` installed and
|
||||||
`CHEMENU_LIVE_SP_BINARY` set.
|
`CHEMENU_LIVE_SP_BINARY` set.
|
||||||
2. From `tools/`, in an environment that has `requirements.txt`:
|
2. From `tools/`, in an environment that has `requirements.lock` installed:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
.venv/bin/python -m chemenu.tests.record_sp_fixtures chemenu/tests/fixtures/sp/api
|
.venv/bin/python -m chemenu.tests.record_sp_fixtures chemenu/tests/fixtures/sp/api
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ surface, lives in `docs/explanation/knowledge-and-commitment.md`, which this ski
|
|||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `stalled` | A tracker project has zero open items and its `kb/` page is `state: active` | (a) A next action is genuinely missing - propose `tools/wikitool task new --title "<title>" --project "<project>"` with a title the user confirms or corrects, asked as one combined question ("Create '<title>' in project '<project>'?"), then run it once confirmed. (b) The initiative is deliberately paused - `tools/wikitool touch --page "<Title>" --set state=dormant`. (c) It is actually finished or given up on - `--set state=completed` or `--set state=abandoned` | Read the page's `## Ziel` and `## Status` sections and ask the user directly: is there still a next step toward that goal, or did this stop for a reason? A pause that was never decided is (a); a pause that *was* decided is (b), never left as `active` with nothing moving |
|
| `stalled` | A tracker project has zero open items and its `kb/` page is `state: active` | (a) A next action is genuinely missing - propose `tools/wikitool task new --title "<title>" --project "<project>"` with a title the user confirms or corrects, asked as one combined question ("Create '<title>' in project '<project>'?"), then run it once confirmed. (b) The initiative is deliberately paused - `tools/wikitool touch --page "<Title>" --set state=dormant`. (c) It is actually finished or given up on - `--set state=completed` or `--set state=abandoned` | Read the page's `## Ziel` and `## Status` sections and ask the user directly: is there still a next step toward that goal, or did this stop for a reason? A pause that was never decided is (a); a pause that *was* decided is (b), never left as `active` with nothing moving |
|
||||||
| `waiting_overdue` | A `WAITING` item's `follow_up_at` is older than the threshold | (a) Follow up now, then move the reminder forward in the tracker - the user's own action, there is no `wikitool` command for it. (b) The commitment is no longer needed - propose `tools/wikitool task close --id "<id>"` (the finding's own `item_id`), asked as one combined question naming the item's title and id, then run it once confirmed | Did the person the item names actually come through, and is the ask still relevant? If yes but late, (a); if the need has passed, (b) - never leave the same stale date standing unexamined |
|
| `waiting_overdue` | A `WAITING` item's `follow_up_at` is older than the threshold | (a) Follow up now, then move the reminder forward in the tracker - the user's own action, there is no `wikitool` command for it. (b) The commitment is no longer needed - propose `tools/wikitool task close --id "<id>"` (the finding's own `item_id`), asked as one combined question naming the item's title and id, then run it once confirmed | Did the person the item names actually come through, and is the ask still relevant? If yes but late, (a); if the need has passed, (b) - never leave the same stale date standing unexamined |
|
||||||
| `unpaged_project` | A tracker project has no `kb/` page, past the age threshold | (a) It has grown a memory worth keeping (participants, decisions, context) - `tools/wikitool new project --name "<Name>" --set responsibility=<area>`. (b) It genuinely never needs one - confirm and leave it tracker-only | Ask: would anyone, including the operator in six months, need to know *why* this exists or who is in it? If yes, (a); a project that is fully explained by its own title and task list stays (b) |
|
| `unpaged_project` | A tracker project has no `kb/` page, past the age threshold | (a) It has grown a memory worth keeping (participants, decisions, context) - `tools/wikitool new project --name "<Name>" --set responsibility=<area>`. If the tracker project's name is already the title of a `kb/` page - usually the entity of the artifact it concerns - propose an outcome name instead (`kb/CONVENTIONS.md` § Naming); renaming the tracker project is the operator's own action in the tracker, there is no `wikitool` command for it, and once done run `new project` with the new name and `--resume`, since the tracker project then already exists. (b) It genuinely never needs one - confirm and leave it tracker-only | Ask: would anyone, including the operator in six months, need to know *why* this exists or who is in it? If yes, (a); a project that is fully explained by its own title and task list stays (b) |
|
||||||
| `no_open_loop` | A `kb/` page is `state: active` but its tracker project is missing or empty | (a) Same three options as `stalled` above. (b) The name diverged - a rename happened on one side only | Before assuming a stall, check whether a *similarly* named tracker project exists. If it does, this is `instructions/page-lifecycle.md`'s rename case (`tools/wikitool rename` for the page, plus renaming the tracker project to match), not a state change - the review reports both directions of a rename so it never has to be inferred silently |
|
| `no_open_loop` | A `kb/` page is `state: active` but its tracker project is missing or empty | (a) Same three options as `stalled` above. (b) The name diverged - a rename happened on one side only | Before assuming a stall, check whether a *similarly* named tracker project exists. If it does, this is `instructions/page-lifecycle.md`'s rename case (`tools/wikitool rename` for the page, plus renaming the tracker project to match), not a state change - the review reports both directions of a rename so it never has to be inferred silently |
|
||||||
| `someday_stale` | A someday/maybe item has not been touched past the threshold | (a) Activate it - give it a page with `tools/wikitool new project` if it is ready to become a committed initiative. (b) Strike it - propose `tools/wikitool task close --id "<id>"` (the finding's own `item_id`), asked as one combined question naming the item's title and id, then run it once confirmed. (c) Leave it - still genuinely "maybe" | Would the user commit to starting this today? If yes, (a). If it no longer belongs on the list at all, (b). If it is still worth keeping but not yet, (c) is a legitimate answer, not inaction - do not force a decision the user is not ready to make |
|
| `someday_stale` | A someday/maybe item has not been touched past the threshold | (a) Activate it - give it a page with `tools/wikitool new project` if it is ready to become a committed initiative. (b) Strike it - propose `tools/wikitool task close --id "<id>"` (the finding's own `item_id`), asked as one combined question naming the item's title and id, then run it once confirmed. (c) Leave it - still genuinely "maybe" | Would the user commit to starting this today? If yes, (a). If it no longer belongs on the list at all, (b). If it is still worth keeping but not yet, (c) is a legitimate answer, not inaction - do not force a decision the user is not ready to make |
|
||||||
| `waiting_no_follow_up` | A `WAITING` item carries no `follow_up_at` at all - the provider had nothing to judge staleness against, so `waiting_overdue` could not even ask the question | (a) Set a follow-up date on the item, in the tracker itself - there is no `wikitool` command for this, same as moving a reminder forward. (b) Leave it open-ended deliberately - some commitments genuinely have no date yet | Ask whether there is a date to follow up on at all. If yes, (a); if the item is a genuine "whenever they get back to me", (b) is legitimate, but say so plainly rather than treating the finding as resolved by itself |
|
| `waiting_no_follow_up` | A `WAITING` item carries no `follow_up_at` at all - the provider had nothing to judge staleness against, so `waiting_overdue` could not even ask the question | (a) Set a follow-up date on the item, in the tracker itself - there is no `wikitool` command for this, same as moving a reminder forward. (b) Leave it open-ended deliberately - some commitments genuinely have no date yet | Ask whether there is a date to follow up on at all. If yes, (a); if the item is a genuine "whenever they get back to me", (b) is legitimate, but say so plainly rather than treating the finding as resolved by itself |
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ stack's hardcoded behaviour until the conventions file existed.
|
|||||||
|---|---|
|
|---|---|
|
||||||
| `language:` | `de` |
|
| `language:` | `de` |
|
||||||
| `sections:` | `Beziehungen` / `Siehe auch` / `Fußnoten` |
|
| `sections:` | `Beziehungen` / `Siehe auch` / `Fußnoten` |
|
||||||
| Naming | Human-readable titles with spaces; singular for entities; a decision named like any other concept, no `adr-NNN-` prefix; `X vs Y` for comparisons |
|
| Naming | Human-readable titles with spaces; singular for entities; a decision named like any other concept, no `adr-NNN-` prefix; `X vs Y` for comparisons; a GTD project named after its outcome, never the bare name of the artifact |
|
||||||
| Tone | Wikipedia register, with a German buzzword and filler list |
|
| Tone | Wikipedia register, with a German buzzword and filler list |
|
||||||
| Relationship labels | `hängt ab von` · `verwendet` · `implementiert` · `erweitert` · `ersetzt` · `steht in Konflikt mit` · `benötigt` · `erzeugt` · `konsumiert` · `besitzt` · `pflegt` · `läuft auf` · `verwandt mit` |
|
| Relationship labels | `hängt ab von` · `verwendet` · `implementiert` · `erweitert` · `ersetzt` · `steht in Konflikt mit` · `benötigt` · `erzeugt` · `konsumiert` · `besitzt` · `pflegt` · `läuft auf` · `verwandt mit` |
|
||||||
| Hedging | By source standing, not a score: `provenance: general` with no `sources:` says "im Allgemeinen"/"üblicherweise"; a claim rests on its weakest cited source's `authority` (`normative` vs. `opinion`); disagreement is named in prose ("möglicherweise", "laut X, aber Y widerspricht") |
|
| Hedging | By source standing, not a score: `provenance: general` with no `sources:` says "im Allgemeinen"/"üblicherweise"; a claim rests on its weakest cited source's `authority` (`normative` vs. `opinion`); disagreement is named in prose ("möglicherweise", "laut X, aber Y widerspricht") |
|
||||||
|
|||||||
@@ -41,11 +41,12 @@ everything an operator needs that is *true of the software* rather than of one i
|
|||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
1. **Install the server's dependency.** It is deliberately not in `requirements.txt`: an
|
1. **Install the server's dependency.** It is deliberately not in `requirements.txt`: an
|
||||||
instance that only uses the CLI should not be made to install pydantic, starlette, uvicorn
|
instance that only uses the CLI should not be made to install starlette, uvicorn and the
|
||||||
and cryptography to do it.
|
rest of a web server to do it. Install the lock beside it, never the `.txt`: exact versions
|
||||||
|
and hashes, consistent with what the preflight put into `tools/.venv`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tools/.venv/bin/python -m pip install -r tools/requirements-mcp.txt
|
tools/.venv/bin/python -m pip install --require-hashes -r tools/requirements-mcp.lock
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Decide which checkout it serves.** The root resolves by precedence - an explicit `--root`,
|
2. **Decide which checkout it serves.** The root resolves by precedence - an explicit `--root`,
|
||||||
|
|||||||
@@ -14,20 +14,25 @@ known to exist: `tools/preflight.sh` for POSIX shells, `tools/preflight.ps1` for
|
|||||||
Windows. The two answer the same questions from the same list and write the same
|
Windows. The two answer the same questions from the same list and write the same
|
||||||
`.wikitool-tools.json`. It does three things, all inside the install folder:
|
`.wikitool-tools.json`. It does three things, all inside the install folder:
|
||||||
|
|
||||||
- checks the tools listed in `tools/prerequisites.txt` - Python 3.11 or newer, git, ripgrep
|
- checks the tools listed in `tools/prerequisites.txt` - Python 3.13 to 3.14 (both checked in
|
||||||
(`rg`) - and, on Windows, that the install folder is short enough for Windows' path limit and
|
CI; an older or newer one is refused with exit 42, and a `python3.14`/`python3.13`, or `py -3.14`
|
||||||
|
on Windows, is taken where the plain `python` lies outside), git, ripgrep (`rg`) - and, on Windows, that the install folder is short enough for Windows' path limit and
|
||||||
(PowerShell only) that the execution policy and the files' Mark of the Web let
|
(PowerShell only) that the execution policy and the files' Mark of the Web let
|
||||||
`tools/wikitool.ps1` start;
|
`tools/wikitool.ps1` start;
|
||||||
- records the absolute path of each tool in `.wikitool-tools.json`, which `wikitool` then starts
|
- records the absolute path of each tool in `.wikitool-tools.json`, which `wikitool` then starts
|
||||||
them from instead of trusting whatever `PATH` a session inherited - and of an optional tool,
|
them from instead of trusting whatever `PATH` a session inherited - and of an optional tool,
|
||||||
such as the 1Password CLI `op`, when it finds one: an optional tool missing is reported as
|
such as the 1Password CLI `op`, when it finds one: an optional tool missing is reported as
|
||||||
`ABSENT` and is never a reason to stop, nor to install anything;
|
`ABSENT` and is never a reason to stop, nor to install anything;
|
||||||
- creates `tools/.venv` from the recorded Python and installs `tools/requirements.txt` into it.
|
- creates `tools/.venv` from the recorded Python and installs `tools/requirements.lock` into it:
|
||||||
|
exact versions with their SHA-256 hashes (`pip install --require-hashes`), so every instance
|
||||||
|
of one stack version runs the same packages. When an update brings a changed lock, the next
|
||||||
|
run moves the venv to it, a version up or down; a venv built on a Python outside the span is
|
||||||
|
built again on the one found.
|
||||||
|
|
||||||
One more thing it does only when the user asks for it: `--with browser` installs the optional
|
One more thing it does only when the user asks for it: `--with browser` installs the optional
|
||||||
browser component - `tools/requirements-browser.txt` and the Chromium it drives - into
|
browser component - `tools/requirements-browser.lock` and the Chromium it drives - into
|
||||||
`tools/.venv`. Only `raw login` and a page a site handler fetches through a browser need it. Once
|
`tools/.venv`. Only `raw login` and a page a site handler fetches through a browser need it. Once
|
||||||
installed, every later run keeps it up to date; nothing else ever installs it.
|
installed, every later run keeps it at its lock; nothing else ever installs it.
|
||||||
|
|
||||||
<!-- wikitool:toc -->
|
<!-- wikitool:toc -->
|
||||||
## Contents
|
## Contents
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ consistent.
|
|||||||
3. **Append the audit entry** - one per operation:
|
3. **Append the audit entry** - one per operation:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tools/wikitool log append --op ingest|query|lint|create|update|delete|rename|move \
|
tools/wikitool log append --op ingest|lint|create|update|delete|rename|move \
|
||||||
--title "<what>" --body "<outcome>"
|
--title "<what>" --body "<outcome>"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ the session instead of discovering the drift only at the very end.
|
|||||||
never commits and never pushes. Files `wikitool` generates are never a reason to stop: when the
|
never commits and never pushes. Files `wikitool` generates are never a reason to stop: when the
|
||||||
catalog or `kb/log.md` changed on both sides, `sync` keeps both sides' log entries and
|
catalog or `kb/log.md` changed on both sides, `sync` keeps both sides' log entries and
|
||||||
regenerates the catalog and `kb/provenance.md`, which it leaves as an uncommitted change for the
|
regenerates the catalog and `kb/provenance.md`, which it leaves as an uncommitted change for the
|
||||||
next `publish`. Uncommitted work that the incoming commits do not touch stays where it is.
|
next `publish`. An open log entry alone is no such case: the incoming catalog stays and only the
|
||||||
|
entry is appended again. Uncommitted work that the incoming commits do not touch stays where it is.
|
||||||
**Exit 42 (rebase-review)?** Same as any exit 42 - read the
|
**Exit 42 (rebase-review)?** Same as any exit 42 - read the
|
||||||
diff it prints, judge whether it conflicts with what you are about to do, summarize that to the
|
diff it prints, judge whether it conflicts with what you are about to do, summarize that to the
|
||||||
user, then `tools/wikitool sync --confirm-rebase <token>` before continuing. See
|
user, then `tools/wikitool sync --confirm-rebase <token>` before continuing. See
|
||||||
|
|||||||
@@ -280,6 +280,24 @@ validator complains - and the ticked list is the only record that they happened.
|
|||||||
No commitment either way in this source? Skip straight to step 5 - the knowledge side runs on
|
No commitment either way in this source? Skip straight to step 5 - the knowledge side runs on
|
||||||
its own exactly as before.
|
its own exactly as before.
|
||||||
|
|
||||||
|
**A question about the source itself - the date of a recording, who took part, what an
|
||||||
|
abbreviation stands for, a transcription error - is asked here, and the answer is kept with
|
||||||
|
the source, not as a second one.** Ask it as one short question, then write the answers down
|
||||||
|
exactly as given, one `--item` each:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tools/wikitool raw clarify incoming/<entry> --item "Termindatum: 2026-11-12" [--item "..."]
|
||||||
|
```
|
||||||
|
|
||||||
|
The command writes `incoming/<stem>.clarifications.md` (inside a folder:
|
||||||
|
`clarifications.md`); step 5 promotes it with the original in the same `raw accept`. **The
|
||||||
|
test for what goes in:** this session asked about it and the operator answered in a few
|
||||||
|
points, and it is context of the *recording* - date, participants, occasion, project,
|
||||||
|
an abbreviation, a transcription error. What the operator adds unprompted, or says about a
|
||||||
|
subject of its own, is new content and stays a source of its own (the normal route, a file in
|
||||||
|
`incoming/`). A source already in `raw/` is clarified with `raw clarify --page "<Title>"
|
||||||
|
--item "..."`, which prints the `raw accept --page` line that adds the file to its bundle.
|
||||||
|
|
||||||
5. **Promote from `incoming/` if that is where the file sits.** Read
|
5. **Promote from `incoming/` if that is where the file sits.** Read
|
||||||
`raw/CONTRACT.md` "Getting a file in" and "Capture fields" if you have
|
`raw/CONTRACT.md` "Getting a file in" and "Capture fields" if you have
|
||||||
not this session - the directory and any bundling are computed, never chosen by hand, but the
|
not this session - the directory and any bundling are computed, never chosen by hand, but the
|
||||||
@@ -299,8 +317,12 @@ validator complains - and the ticked list is the only record that they happened.
|
|||||||
incoming/<file> [incoming/<other-file> ...]
|
incoming/<file> [incoming/<other-file> ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
List every file this one source produced (e.g. a `raw fetch` pair)
|
List every file this one source produced (e.g. a `raw fetch` pair, or the
|
||||||
in the same call, so they land bundled together rather than as two independent promotions. A
|
`<stem>.clarifications.md` that step 4's `raw clarify` wrote) in the same call, so they land
|
||||||
|
bundled together rather than as two independent promotions - the bundle is named after the
|
||||||
|
original, whichever file comes first. The companion file inherits the bundle's one
|
||||||
|
`--fidelity`/`--authority` pair; step 6 lists it in `raw_files:`, and a claim that rests on it
|
||||||
|
is cited to it with `cite add`, so that the page shows it as the operator's statement. A
|
||||||
file already in `raw/` skips this step entirely. A folder is accepted as a whole, on its own:
|
file already in `raw/` skips this step entirely. A folder is accepted as a whole, on its own:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -542,7 +564,7 @@ validator complains - and the ticked list is the only record that they happened.
|
|||||||
|
|
||||||
## wikitool commands used
|
## wikitool commands used
|
||||||
|
|
||||||
`raw pending`, `raw fetch`, `raw derive`, `raw accept`, `raw status`, `raw capture`, `search`, `types describe`, `task new`, `task list`, `task close`,
|
`raw pending`, `raw fetch`, `raw derive`, `raw clarify`, `raw accept`, `raw status`, `raw capture`, `search`, `types describe`, `task new`, `task list`, `task close`,
|
||||||
`new project`, `new source`, `new entity`, `new concept`, `touch`, `cite add`, `xref add`,
|
`new project`, `new source`, `new entity`, `new concept`, `touch`, `cite add`, `xref add`,
|
||||||
`xref link-source`, `sources coverage`, `sources rebuild-index`, `index rebuild`, `log append`,
|
`xref link-source`, `sources coverage`, `sources rebuild-index`, `index rebuild`, `log append`,
|
||||||
`log status`, `publish`
|
`log status`, `publish`
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ description: Answers a question using the LLM wiki's compiled knowledge - read-o
|
|||||||
**Before the first `wikitool` call:** `instructions/session-setup.md`.
|
**Before the first `wikitool` call:** `instructions/session-setup.md`.
|
||||||
|
|
||||||
**Hard rule:** read-only with respect to wiki *content*. Never modify, hand-edit, or scaffold a
|
**Hard rule:** read-only with respect to wiki *content*. Never modify, hand-edit, or scaffold a
|
||||||
page while answering. Two exceptions, both mechanical: step 7 (filing a valuable answer through
|
page while answering. One exception, mechanical: step 7 (filing a valuable answer through
|
||||||
`wikitool new`, never by hand) and step 8 (one audit entry via `wikitool log append`). If the
|
`wikitool new`, never by hand). A query writes no `kb/log.md` entry - a read changes nothing the
|
||||||
wiki has no confident source, say so - per AGENTS.md's "never file an unsourced answer"
|
wiki learned. If the wiki has no confident source, say so - per AGENTS.md's "never file an
|
||||||
invariant - rather than synthesizing a plausible-sounding answer from general knowledge.
|
unsourced answer" invariant - rather than synthesizing a plausible-sounding answer from general
|
||||||
|
knowledge.
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
@@ -98,19 +99,16 @@ invariant - rather than synthesizing a plausible-sounding answer from general kn
|
|||||||
find again than a sentence in a chat log.
|
find again than a sentence in a chat log.
|
||||||
|
|
||||||
7. **File back what survived.** Scaffold it - `tools/wikitool new ...` - and follow
|
7. **File back what survived.** Scaffold it - `tools/wikitool new ...` - and follow
|
||||||
`wiki-manage`. Never write the page by hand, and never file an answer no source backs.
|
`wiki-manage`, which logs it as a `create` through `publish-cycle.md`. Never write the page by
|
||||||
|
hand, and never file an answer no source backs.
|
||||||
8. **Log it.**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
tools/wikitool log append --op query --title "<question>" --body "<outcome>"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Decision points
|
## Decision points
|
||||||
|
|
||||||
- **Nothing found?** Try the structural query before concluding the wiki is silent - a page may
|
- **Nothing found?** Try the structural query before concluding the wiki is silent - a page may
|
||||||
exist under different words. Then say the wiki has no confident source, and offer to ingest
|
exist under different words. Then say the wiki has no confident source, and offer to ingest
|
||||||
one.
|
one. If the user wants the gap kept, file it as an inbox item on their say-so:
|
||||||
|
`tools/wikitool task new --inbox --title "<the question>"`. Without a configured tracker the
|
||||||
|
offer stays in the chat. Never log it.
|
||||||
- **The question asks for the wording** - "what exactly does rule 16:3e say", "which value is
|
- **The question asks for the wording** - "what exactly does rule 16:3e say", "which value is
|
||||||
in table 4"? Find the page that carries the substance first (steps 2-3), then step 4's route
|
in table 4"? Find the page that carries the substance first (steps 2-3), then step 4's route
|
||||||
to the passage. A paraphrase from the page is not the wording, and searching `raw/` is not a
|
to the passage. A paraphrase from the page is not the wording, and searching `raw/` is not a
|
||||||
@@ -129,7 +127,7 @@ invariant - rather than synthesizing a plausible-sounding answer from general kn
|
|||||||
|
|
||||||
## wikitool commands used
|
## wikitool commands used
|
||||||
|
|
||||||
`search`, `log append`. If filing an answer back: `new`, `xref add`, `sources rebuild-index`,
|
`search`. If filing an answer back: `new`, `xref add`, `sources rebuild-index`,
|
||||||
`index rebuild`, and `publish` only if asked.
|
`index rebuild`, and `publish` only if asked.
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
|
|||||||
+7
-1
@@ -94,10 +94,16 @@ There is no `## Siehe auch` region any more. It was the reciprocal half of a bid
|
|||||||
See [kb/concepts/COLLECTION.md § Decisions](concepts/COLLECTION.md#decisions).
|
See [kb/concepts/COLLECTION.md § Decisions](concepts/COLLECTION.md#decisions).
|
||||||
- Prefer readability over convention when the two conflict.
|
- Prefer readability over convention when the two conflict.
|
||||||
|
|
||||||
What to name a thing: projects use their repository or common name; systems a descriptive
|
What to name a thing: codebases use their repository or common name; systems a descriptive
|
||||||
name; tools the tool's own name; technologies their standard spelling and capitalization;
|
name; tools the tool's own name; technologies their standard spelling and capitalization;
|
||||||
people a full name or common handle.
|
people a full name or common handle.
|
||||||
|
|
||||||
|
A GTD project - a `project` page - is named after the undertaking or the outcome it aims at,
|
||||||
|
never after the bare name of the artifact it concerns: entity `Binford 9000`, project
|
||||||
|
`Binford 9000 im EU-Markt eingeführt` or `Binford 9000 - Markteinführung EU`. The artifact's
|
||||||
|
name belongs to its entity page, and since a project's title is also the name of its tracker
|
||||||
|
project, this keeps both free.
|
||||||
|
|
||||||
The naming facts that are *not* a choice, and therefore live in the contract: the filename
|
The naming facts that are *not* a choice, and therefore live in the contract: the filename
|
||||||
stem is the page title, `[[wikilinks]]` must match it exactly, and the title must be a valid,
|
stem is the page title, `[[wikilinks]]` must match it exactly, and the title must be a valid,
|
||||||
unique file name on every platform (`kb/CONTRACT.md` § Titles are identifiers).
|
unique file name on every platform (`kb/CONTRACT.md` § Titles are identifiers).
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ them - they are rebuilt from frontmatter on every write. Any *other* heading is
|
|||||||
- {Singular or plural for entities.}
|
- {Singular or plural for entities.}
|
||||||
- {How a comparison page's title reads.}
|
- {How a comparison page's title reads.}
|
||||||
- {The ADR prefix, if this instance files decisions as pages.}
|
- {The ADR prefix, if this instance files decisions as pages.}
|
||||||
- {What to name a thing: projects, systems, tools, technologies, people.}
|
- {What to name a thing: codebases, systems, tools, technologies, people.}
|
||||||
|
- {What to name a GTD project (a `project` page, whose title is also its tracker project's
|
||||||
|
name) - after its outcome, or after the artifact it concerns.}
|
||||||
|
|
||||||
The naming facts that are *not* a choice, and therefore live in the contract: the filename
|
The naming facts that are *not* a choice, and therefore live in the contract: the filename
|
||||||
stem is the page title, `[[wikilinks]]` must match it exactly, and the title must be a valid,
|
stem is the page title, `[[wikilinks]]` must match it exactly, and the title must be a valid,
|
||||||
|
|||||||
@@ -95,6 +95,25 @@ That is what keeps the clean-up safe: only directories the moves emptied are rem
|
|||||||
can go with them. A file *inside* a subdirectory is never accepted on its own; the refusal names
|
can go with them. A file *inside* a subdirectory is never accepted on its own; the refusal names
|
||||||
both ways out - the whole folder, or the file moved up into `incoming/`.
|
both ways out - the whole folder, or the file moved up into `incoming/`.
|
||||||
|
|
||||||
|
**What the operator answers about a source goes beside it, not into a second source.** An ingest
|
||||||
|
often has one question only the operator can answer - the date of a recorded meeting, who took
|
||||||
|
part, an abbreviation. `tools/wikitool raw clarify incoming/<entry> --item "..."` writes the
|
||||||
|
answers as a companion file in `incoming/`: `<stem>.clarifications.md` beside a file or stem
|
||||||
|
bundle, `clarifications.md` inside a folder (`-2`, `-3` before the extension when the name is
|
||||||
|
taken). Name and place are computed; the file starts with a fixed header and holds one bullet per
|
||||||
|
`--item`, word for word. `raw pending` counts `<stem>.clarifications.md` with its original as one
|
||||||
|
`bundle`, and `raw accept` promotes both together under `raw/<YYYY>/<MM>/<stem>/`, named after the
|
||||||
|
original whatever order the files are passed in. A companion file with no original - neither in
|
||||||
|
the call nor, with `--page`, among the page's `raw_files:` - is refused: a clarification of
|
||||||
|
nothing is not a source. For a source already in `raw/`, `raw clarify --page "<Title>"` writes the
|
||||||
|
file to `incoming/` and prints the `raw accept --page` line that folds it into the bundle. Only
|
||||||
|
what the ingest session asked about *this* source and the operator answered in a few points
|
||||||
|
belongs in it - context of the recording, an abbreviation, a transcription error; what the
|
||||||
|
operator adds unprompted, or says about a subject of its own, is a source of its own. The file
|
||||||
|
sits in `raw/`, is listed in the page's `raw_files:` and is cited like any raw file, so it is
|
||||||
|
within [`kb/CONTRACT.md`](../kb/CONTRACT.md)'s source and provenance rules rather than an
|
||||||
|
exception to them.
|
||||||
|
|
||||||
**An export never comes back in.** A file that carries the stack's export marker is this stack's
|
**An export never comes back in.** A file that carries the stack's export marker is this stack's
|
||||||
own output and `raw accept` refuses it, given on its own, inside a folder, or as
|
own output and `raw accept` refuses it, given on its own, inside a folder, or as
|
||||||
`--replaces`/`--replaces-bundle` material, naming each one. The marker is either a first line
|
`--replaces`/`--replaces-bundle` material, naming each one. The marker is either a first line
|
||||||
@@ -624,6 +643,11 @@ OK Promoted 1 file(s) to raw/2026/09/handbuch.pdf.
|
|||||||
--set source_type=<category>
|
--set source_type=<category>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**A clarification inherits the pair of its bundle.** A bundle has exactly one
|
||||||
|
`fidelity`/`authority` pair, so a `<stem>.clarifications.md` promoted with a `published` +
|
||||||
|
`normative` source formally carries `normative` too. That is accepted: its fixed header marks it
|
||||||
|
as the operator's own statement, and what may go in it is limited to context of the recording.
|
||||||
|
|
||||||
**Fixed once, correctable only as a new edition.** `wikitool touch --set fidelity=<value>` writes
|
**Fixed once, correctable only as a new edition.** `wikitool touch --set fidelity=<value>` writes
|
||||||
a capture field only while it is absent; once set, it refuses and points at the one sanctioned way
|
a capture field only while it is absent; once set, it refuses and points at the one sanctioned way
|
||||||
to correct it - `raw accept --replaces`, which alone may pass `--fidelity`/`--authority` to
|
to correct it - `raw accept --replaces`, which alone may pass `--fidelity`/`--authority` to
|
||||||
|
|||||||
+67
-8
@@ -126,6 +126,7 @@ sources rebuild-index write idempotent budget:counted exit:0,1
|
|||||||
raw fetch write non-idempotent budget:counted exit:0,1,42 Capture a web page the user names into `incoming/`: the HTML as received plus a derived text, for `raw accept` to promote. Pages of a known website are fetched in the website's standard form and cleaned of its page furniture; a host the instance routes so is fetched with the user's own session or through an external fetcher.
|
raw fetch write non-idempotent budget:counted exit:0,1,42 Capture a web page the user names into `incoming/`: the HTML as received plus a derived text, for `raw accept` to promote. Pages of a known website are fetched in the website's standard form and cleaned of its page furniture; a host the instance routes so is fetched with the user's own session or through an external fetcher.
|
||||||
raw login write idempotent budget:counted exit:0,1,42 Let the user sign in to a website once, in a visible browser window, and store the session it leaves as a secret outside the working tree, for `raw fetch` to fetch that website's pages with. Only the user runs it.
|
raw login write idempotent budget:counted exit:0,1,42 Let the user sign in to a website once, in a visible browser window, and store the session it leaves as a secret outside the working tree, for `raw fetch` to fetch that website's pages with. Only the user runs it.
|
||||||
raw derive write non-idempotent budget:counted exit:0,1 Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`, or unpack a ZIP, and leave the original beside it, for `raw accept` to promote.
|
raw derive write non-idempotent budget:counted exit:0,1 Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`, or unpack a ZIP, and leave the original beside it, for `raw accept` to promote.
|
||||||
|
raw clarify write non-idempotent budget:counted exit:0,1 Write the operator's answers to an ingest's questions about a source as a companion file in `incoming/`, to be promoted with the source instead of as a source of its own.
|
||||||
raw capture write non-idempotent budget:counted exit:0,1 Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
raw capture write non-idempotent budget:counted exit:0,1 Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
||||||
raw status read idempotent budget:counted exit:0 Report which captured bundles under `raw/` have fallen behind their repository, with each changed file as `A`/`M`/`D`.
|
raw status read idempotent budget:counted exit:0 Report which captured bundles under `raw/` have fallen behind their repository, with each changed file as `A`/`M`/`D`.
|
||||||
raw pending read idempotent budget:counted exit:0 List what waits in `incoming/`, oldest first, and name the entry an ingest without an argument takes next.
|
raw pending read idempotent budget:counted exit:0 List what waits in `incoming/`, oldest first, and name the entry an ingest without an argument takes next.
|
||||||
@@ -213,6 +214,7 @@ Scaffold a new wiki page of any type.
|
|||||||
- 1 A `raw_files` path does not exist
|
- 1 A `raw_files` path does not exist
|
||||||
- 1 A capture field the type-spec requires is missing, or set to `unknown`
|
- 1 A capture field the type-spec requires is missing, or set to `unknown`
|
||||||
- 1 `--resume` with a type other than `project`
|
- 1 `--resume` with a type other than `project`
|
||||||
|
- 1 new project: The name is already the title of a `kb/` page - typically the entity page of the artifact the project concerns
|
||||||
- 1 new project: The name is already taken in the tracker (case-insensitively; for `caldav` against every list in the account)
|
- 1 new project: The name is already taken in the tracker (case-insensitively; for `caldav` against every list in the account)
|
||||||
- 1 new project: The configured access path has no write path (Super Productivity's `access: "snapshot"`)
|
- 1 new project: The configured access path has no write path (Super Productivity's `access: "snapshot"`)
|
||||||
- 1 new project: The page write failed after the tracker project was confirmed to exist
|
- 1 new project: The page write failed after the tracker project was confirmed to exist
|
||||||
@@ -225,6 +227,7 @@ Scaffold a new wiki page of any type.
|
|||||||
- A `raw_files` path does not exist -> Not transient - fix the path and retry once
|
- A `raw_files` path does not exist -> Not transient - fix the path and retry once
|
||||||
- A capture field the type-spec requires is missing, or set to `unknown` -> Pass it explicitly (e.g. `--set fidelity=verbatim --set authority=reporting`), then retry once
|
- A capture field the type-spec requires is missing, or set to `unknown` -> Pass it explicitly (e.g. `--set fidelity=verbatim --set authority=reporting`), then retry once
|
||||||
- `--resume` with a type other than `project` -> Drop `--resume` and retry once
|
- `--resume` with a type other than `project` -> Drop `--resume` and retry once
|
||||||
|
- new project: The name is already the title of a `kb/` page - typically the entity page of the artifact the project concerns -> Not transient - name the project after its undertaking or outcome (`kb/CONVENTIONS.md` § Naming) and retry once. Nothing was created, no tracker project either
|
||||||
- new project: The name is already taken in the tracker (case-insensitively; for `caldav` against every list in the account) -> Not transient - choose another name. If an earlier run of this exact command asked a human to create the project and they did, re-run with `--resume`
|
- new project: The name is already taken in the tracker (case-insensitively; for `caldav` against every list in the account) -> Not transient - choose another name. If an earlier run of this exact command asked a human to create the project and they did, re-run with `--resume`
|
||||||
- new project: The configured access path has no write path (Super Productivity's `access: "snapshot"`) -> Not transient - point at the `access: "api"` instance the error names. A `--resume` retry refuses the same way, since nothing about the config changes by asking again
|
- new project: The configured access path has no write path (Super Productivity's `access: "snapshot"`) -> Not transient - point at the `access: "api"` instance the error names. A `--resume` retry refuses the same way, since nothing about the config changes by asking again
|
||||||
- new project: The page write failed after the tracker project was confirmed to exist -> Fix the write error, then re-run with `--resume` - a plain re-run is refused as a tracker collision
|
- new project: The page write failed after the tracker project was confirmed to exist -> Fix the write error, then re-run with `--resume` - a plain re-run is refused as a tracker collision
|
||||||
@@ -1035,7 +1038,7 @@ Append a formatted entry to `kb/log.md`.
|
|||||||
|
|
||||||
**SYNOPSIS**
|
**SYNOPSIS**
|
||||||
|
|
||||||
- `wikitool log append --op ingest|query|lint|create|update|delete|rename|move --title "..." [--body "..."|--body-file path]`
|
- `wikitool log append --op ingest|lint|create|update|delete|rename|move|query --title "..." [--body "..."|--body-file path]`
|
||||||
|
|
||||||
**PROPERTIES**
|
**PROPERTIES**
|
||||||
|
|
||||||
@@ -1069,6 +1072,7 @@ Append a formatted entry to `kb/log.md`.
|
|||||||
|
|
||||||
- Appends one entry to `kb/log.md`: a `## [YYYY-MM-DD] <op> | <title>` heading, the body if one is given, and a `---` separator.
|
- Appends one entry to `kb/log.md`: a `## [YYYY-MM-DD] <op> | <title>` heading, the body if one is given, and a `---` separator.
|
||||||
- Not idempotent: every successful run appends a new entry, including a repeated one.
|
- Not idempotent: every successful run appends a new entry, including a repeated one.
|
||||||
|
- `query` is a legacy value: older versions wrote one entry per read-only query. It is still accepted so existing logs and an instance's own instructions keep working, but the stack no longer writes it - a read is not an operation on the wiki.
|
||||||
|
|
||||||
**SEE ALSO**
|
**SEE ALSO**
|
||||||
|
|
||||||
@@ -1623,6 +1627,59 @@ Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`,
|
|||||||
- `wikitool raw accept` - promotes the folder into `raw/`
|
- `wikitool raw accept` - promotes the folder into `raw/`
|
||||||
- `instructions/wiki-ingest/SKILL.md` - where a PDF, mail or Office file to ingest starts
|
- `instructions/wiki-ingest/SKILL.md` - where a PDF, mail or Office file to ingest starts
|
||||||
|
|
||||||
|
#### `raw clarify`
|
||||||
|
|
||||||
|
Write the operator's answers to an ingest's questions about a source as a companion file in `incoming/`, to be promoted with the source instead of as a source of its own.
|
||||||
|
|
||||||
|
**SYNOPSIS**
|
||||||
|
|
||||||
|
- `wikitool raw clarify incoming/<entry> --item "<answer>" [--item "<answer>" ...]` - A file, a file of a stem bundle, or a folder in `incoming/`: write `<stem>.clarifications.md` beside it, or `clarifications.md` inside the folder
|
||||||
|
- `wikitool raw clarify --page "<Title>" --item "<answer>" [--item "<answer>" ...]` - A source already in `raw/`: write the companion file to `incoming/` and print the `raw accept --page` line that adds it to the source's bundle
|
||||||
|
|
||||||
|
**PROPERTIES**
|
||||||
|
|
||||||
|
- effect: write
|
||||||
|
- idempotent: no
|
||||||
|
- atomic: Yes - everything is checked before the one write, and the file is created exclusively, so an existing file is never overwritten
|
||||||
|
- budget: counted
|
||||||
|
- network: no
|
||||||
|
|
||||||
|
**EXAMPLES**
|
||||||
|
|
||||||
|
- `tools/wikitool raw clarify incoming/meeting.vtt --item "Termindatum: 2026-11-12"`
|
||||||
|
- `tools/wikitool raw clarify incoming/workshop --item "Teilnehmer: A, B" --item "KI = künstliche Intelligenz"`
|
||||||
|
- `tools/wikitool raw clarify --page "Source - Meeting" --item "Projekt: Alpha"`
|
||||||
|
|
||||||
|
**EXIT STATUS**
|
||||||
|
|
||||||
|
- 0 success
|
||||||
|
- 1 No `--item`, an empty or multi-line one, an entry that is not directly in `incoming/`, a captured bundle, or neither (or both of) an entry and `--page`
|
||||||
|
- 1 `--page` names no page, or one without `raw_files:`
|
||||||
|
|
||||||
|
**ON FAILURE**
|
||||||
|
|
||||||
|
- No `--item`, an empty or multi-line one, an entry that is not directly in `incoming/`, a captured bundle, or neither (or both of) an entry and `--page` -> Nothing was written. Fix the call and retry once
|
||||||
|
- `--page` names no page, or one without `raw_files:` -> Nothing was written. Check the title with `wikitool search`, then retry once
|
||||||
|
|
||||||
|
**NEVER**
|
||||||
|
|
||||||
|
- Never put the operator's unprompted new content in a clarification - it is a source of its own.
|
||||||
|
- Never write a clarification by hand into `raw/`; `raw accept` promotes it.
|
||||||
|
|
||||||
|
**NOTES**
|
||||||
|
|
||||||
|
- Writes into `incoming/` only, never into `raw/`, and reads no network. The name and the place are computed, never chosen: `incoming/<stem>.clarifications.md` for a file or a stem bundle, `incoming/<folder>/clarifications.md` for a folder; a taken name gets `-2`, `-3` before the extension, and no existing file is overwritten.
|
||||||
|
- The file starts with a fixed header (`kind`, `written_by`, `clarifies` - the file(s) it belongs to, `answered` - today's date, `by`), then one bullet per `--item`, word for word as passed. An item is one line; its language is the one the operator answered in.
|
||||||
|
- What belongs in it is what this ingest session asked about this source and the operator answered in a few points - the date of the recording, who took part, an abbreviation, a transcription error. What the operator adds unprompted, or says about a subject of its own, stays a source of its own (`instructions/wiki-ingest/SKILL.md`).
|
||||||
|
- `raw pending` lists the companion file with its original as one candidate, and `raw accept` promotes both as one bundle named after the original, whatever order the files are passed in. A companion file with no original in the call (or, with `--page`, in the page's raw_files:) is refused.
|
||||||
|
- `--page` names the file after the stem of the source's first file and prints the `raw accept --page` line with the page's own `fidelity` and `authority` - a bundle has one pair, and the companion file inherits it.
|
||||||
|
|
||||||
|
**SEE ALSO**
|
||||||
|
|
||||||
|
- `raw/CONTRACT.md` "Getting a file in: incoming/" - the companion file and its bundle
|
||||||
|
- `wikitool raw accept` - promotes the companion file with its original
|
||||||
|
- `instructions/wiki-ingest/SKILL.md` - when to ask, and where the answer goes
|
||||||
|
|
||||||
#### `raw capture`
|
#### `raw capture`
|
||||||
|
|
||||||
Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
Capture documentation from a git repository into `incoming/<bundle>/`, with a manifest naming the repository, ref rule and commit, for `raw accept` to promote.
|
||||||
@@ -2109,7 +2166,7 @@ Fetch `<remote>/<branch>` and bring the local branch up to date with it.
|
|||||||
|
|
||||||
- effect: write
|
- effect: write
|
||||||
- idempotent: yes
|
- idempotent: yes
|
||||||
- atomic: No - fetch, then at most one merge/rebase attempt, aborted cleanly on failure with the working tree restored; a success that merged generated files then rewrites the catalog
|
- atomic: No - fetch, then at most one merge/rebase attempt, aborted cleanly on failure with the working tree restored; a success that merged generated files then rewrites the catalog, unless `kb/log.md` was the only one
|
||||||
- budget: counted
|
- budget: counted
|
||||||
- network: yes
|
- network: yes
|
||||||
- gates: rebase-review
|
- gates: rebase-review
|
||||||
@@ -2142,7 +2199,7 @@ Fetch `<remote>/<branch>` and bring the local branch up to date with it.
|
|||||||
**NOTES**
|
**NOTES**
|
||||||
|
|
||||||
- Fetches `<remote>/<branch>`, then: fast-forwards when only the remote moved; rebases the local commits on top when both sides moved but touched disjoint files; exits 42 (Rebase-Review Gate) when both sides touched the same file.
|
- Fetches `<remote>/<branch>`, then: fast-forwards when only the remote moved; rebases the local commits on top when both sides moved but touched disjoint files; exits 42 (Rebase-Review Gate) when both sides touched the same file.
|
||||||
- Files `wikitool` generates (`kb/index.md`, `kb/log.md`, `kb/provenance.md`, every `kb/**/INDEX.md`) never count as an overlap and never reach the gate. Where they are what stops git - uncommitted ones in the way of a fast-forward or rebase, or a rebase conflict in them - they are merged mechanically: `kb/log.md` becomes the incoming log plus the entries only this side appended, and the catalog and `kb/provenance.md` are regenerated from the merged pages and left as an uncommitted change. A reconcile git can do on its own is unchanged and regenerates nothing.
|
- Files `wikitool` generates (`kb/index.md`, `kb/log.md`, `kb/provenance.md`, every `kb/**/INDEX.md`) never count as an overlap and never reach the gate. Where they are what stops git - uncommitted ones in the way of a fast-forward or rebase, or a rebase conflict in them - they are merged mechanically: `kb/log.md` becomes the incoming log plus the entries only this side appended, and the catalog and `kb/provenance.md` are regenerated from the merged pages and left as an uncommitted change. When only `kb/log.md` stood in the way - an open log entry, nothing else generated - the catalog is not rebuilt: the incoming one stays, and just the local entries are appended again. A reconcile git can do on its own is unchanged and regenerates nothing.
|
||||||
- Uncommitted changes that no incoming commit touches do not stop a rebase: they are carried through it (`git rebase --autostash`) and come back unchanged.
|
- Uncommitted changes that no incoming commit touches do not stop a rebase: they are carried through it (`git rebase --autostash`) and come back unchanged.
|
||||||
- Before anything is set aside, the working tree is stored as a commit under `refs/wikitool/reconcile-backup`. A successful reconcile drops it; a failed one restores the working tree and names the ref.
|
- Before anything is set aside, the working tree is stored as a commit under `refs/wikitool/reconcile-backup`. A successful reconcile drops it; a failed one restores the working tree and names the ref.
|
||||||
- A refused call performs no rebase attempt and leaves the branch where it was.
|
- A refused call performs no rebase attempt and leaves the branch where it was.
|
||||||
@@ -2220,7 +2277,7 @@ Reconcile with `<remote>/<branch>`, then stage all changes, commit, and push.
|
|||||||
- Order: branch check and Publish-Remote Gate, then the reconcile with `<remote>/<branch>`, then the Mass-Update Gate, then `git add -A`, commit and push. `--no-push` skips all but the Mass-Update Gate and the commit.
|
- Order: branch check and Publish-Remote Gate, then the reconcile with `<remote>/<branch>`, then the Mass-Update Gate, then `git add -A`, commit and push. `--no-push` skips all but the Mass-Update Gate and the commit.
|
||||||
- Without `--no-push`, a remote that is not configured or cannot be reached ends the call with exit 1 at the reconcile - before the gate, `git add` and the commit, and also on a clean tree. Nothing is committed, the index and the working tree are unchanged, and the message names `--no-push` as the way to a local commit. The next `publish` that reaches the remote pushes that commit along with whatever is new. A remote that answers but has no `<branch>` yet (a new, empty repository) is not this case: the first publish of an instance commits and pushes as before.
|
- Without `--no-push`, a remote that is not configured or cannot be reached ends the call with exit 1 at the reconcile - before the gate, `git add` and the commit, and also on a clean tree. Nothing is committed, the index and the working tree are unchanged, and the message names `--no-push` as the way to a local commit. The next `publish` that reaches the remote pushes that commit along with whatever is new. A remote that answers but has no `<branch>` yet (a new, empty repository) is not this case: the first publish of an instance commits and pushes as before.
|
||||||
- Reconcile: fetches `<remote>/<branch>`, fast-forwards when only the remote moved, rebases the local commits on top when both sides moved but touched disjoint files, and exits 42 (Rebase-Review Gate) when both sides touched the same file. A refused reconcile performs no rebase attempt. The `--confirm-rebase` token covers the exact upstream state and the set of files touched on both sides.
|
- Reconcile: fetches `<remote>/<branch>`, fast-forwards when only the remote moved, rebases the local commits on top when both sides moved but touched disjoint files, and exits 42 (Rebase-Review Gate) when both sides touched the same file. A refused reconcile performs no rebase attempt. The `--confirm-rebase` token covers the exact upstream state and the set of files touched on both sides.
|
||||||
- Generated files are never an overlap: where they are all that stops the reconcile, it merges them as `sync` does (both sides' log entries kept, the catalog and `kb/provenance.md` regenerated) and carries uncommitted changes no incoming commit touches through the rebase. The proactive reconcile runs before staging, so this publish commits the regenerated files - with `--path` too, see there; on the retry after a rejected push they get a commit of their own before the second push.
|
- Generated files are never an overlap: where they are all that stops the reconcile, it merges them as `sync` does (both sides' log entries kept, the catalog and `kb/provenance.md` regenerated unless the log alone stood in the way) and carries uncommitted changes no incoming commit touches through the rebase. The proactive reconcile runs before staging, so this publish commits the regenerated files - with `--path` too, see there; on the retry after a rejected push they get a commit of their own before the second push.
|
||||||
- The push target must be the checked-out branch; this is checked before anything is staged. The unborn branch of a fresh `git init -b main` counts as checked out, so the first publish of a new instance works; a real detached HEAD is refused.
|
- The push target must be the checked-out branch; this is checked before anything is staged. The unborn branch of a fresh `git init -b main` counts as checked out, so the first publish of a new instance works; a real detached HEAD is refused.
|
||||||
- With nothing new to stage, a local commit the remote lacks is still pushed: one left behind by an earlier publish whose push failed, or every commit when the remote answers but does not have the branch yet (a new, empty remote repository).
|
- With nothing new to stage, a local commit the remote lacks is still pushed: one left behind by an earlier publish whose push failed, or every commit when the remote answers but does not have the branch yet (a new, empty remote repository).
|
||||||
- A rejected push that finds the remote unreachable on its one retry reports the original push error.
|
- A rejected push that finds the remote unreachable on its one retry reports the original push error.
|
||||||
@@ -4185,7 +4242,8 @@ Check that this instance is correctly configured.
|
|||||||
- **The MCP server** (`chemenu/mcp/`) is that second adapter: `search`,
|
- **The MCP server** (`chemenu/mcp/`) is that second adapter: `search`,
|
||||||
`types`, `describe_type`, `lint` and `status` over `chemenu.api`, on `stdio`
|
`types`, `describe_type`, `lint` and `status` over `chemenu.api`, on `stdio`
|
||||||
or `streamable-http`. Its dependency is optional and lives in
|
or `streamable-http`. Its dependency is optional and lives in
|
||||||
`requirements-mcp.txt`, so a CLI-only instance does not install it. Five of
|
`requirements-mcp.txt` (installed from its lock, `requirements-mcp.lock`), so a CLI-only
|
||||||
|
instance does not install it. Five of
|
||||||
its tools are structurally read-only - nothing under
|
its tools are structurally read-only - nothing under
|
||||||
`commands/` is importable from the server, so `new`/`touch`/`xref`/`cite`/
|
`commands/` is importable from the server, so `new`/`touch`/`xref`/`cite`/
|
||||||
`publish`/`migrate` are unreachable rather than filtered - and every
|
`publish`/`migrate` are unreachable rather than filtered - and every
|
||||||
@@ -4239,12 +4297,13 @@ type-specs and conventions rather than an instance's. There:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd tools
|
cd tools
|
||||||
.venv/bin/pip install pytest pytest-cov # one time; pytest-cov is optional
|
.venv/bin/python -m pip install --require-hashes -r requirements-dev.lock # one time
|
||||||
.venv/bin/python -m pytest -q # add --cov for a coverage report
|
.venv/bin/python -m pytest -q # add --cov for a coverage report
|
||||||
```
|
```
|
||||||
|
|
||||||
Neither is in `requirements.txt`, and `pytest-cov` is CI-only by intent: `requirements.txt` is
|
The test tools sit in `requirements-dev.txt` and its lock, not in `requirements.txt`: that one
|
||||||
what an instance needs at runtime, and an instance does not measure this suite.
|
is what an instance needs at runtime, and an instance does not run this suite. Both, and the
|
||||||
|
`lock_requirements.py` that writes every lock, are dev-only as well.
|
||||||
|
|
||||||
## Maintenance schedule
|
## Maintenance schedule
|
||||||
|
|
||||||
|
|||||||
+25
-8
@@ -27,11 +27,23 @@ pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1 # PowerShell
|
|||||||
|
|
||||||
The preflight is the one way a checkout gets its environment: it checks the
|
The preflight is the one way a checkout gets its environment: it checks the
|
||||||
tools listed in `prerequisites.txt`, records their absolute paths in
|
tools listed in `prerequisites.txt`, records their absolute paths in
|
||||||
`../.wikitool-tools.json`, creates `.venv` and installs `requirements.txt` into
|
`../.wikitool-tools.json`, creates `.venv` and installs `requirements.lock` into
|
||||||
it with `-m pip`. It is POSIX sh because it has to run before Python is known
|
it with `-m pip --require-hashes`. It is POSIX sh because it has to run before Python is known
|
||||||
to exist; exit 42 means the user has to act, and its output says how. The
|
to exist; exit 42 means the user has to act, and its output says how. The
|
||||||
procedure an agent follows around it is `instructions/preflight.md`.
|
procedure an agent follows around it is `instructions/preflight.md`.
|
||||||
|
|
||||||
|
Python is admitted in a span, both ends in `prerequisites.txt` (3.13 to 3.14): what CI checks
|
||||||
|
is exactly what the preflight and `doctor` accept. A `.venv` built on a Python outside it is
|
||||||
|
built again on the one the preflight found.
|
||||||
|
|
||||||
|
Every `requirements*.txt` holds lower bounds only and is never installed itself. Beside each
|
||||||
|
sits a `.lock` with exact versions and SHA-256 hashes for everything it resolves to, written
|
||||||
|
from it with a 7-day cooldown on new releases; the preflight stamps the lock's hash into
|
||||||
|
`.venv/.chemenu-requirements.sha256` and installs it again whenever it changes, so an
|
||||||
|
instance follows the lock of the stack it runs, up or down. The three locks resolve against
|
||||||
|
each other, so a package that sits in two has one version. They are written in the origin
|
||||||
|
repository, never by hand.
|
||||||
|
|
||||||
Each release also attaches `preflight.sh` and `preflight.ps1` as assets, for the first install
|
Each release also attaches `preflight.sh` and `preflight.ps1` as assets, for the first install
|
||||||
before any tree exists. `release.yml` writes the download address of that same release into two
|
before any tree exists. `release.yml` writes the download address of that same release into two
|
||||||
placeholder lines of the copy (`RELEASE_ARCHIVE_URL`/`RELEASE_CHECKSUM_URL` in the shell script,
|
placeholder lines of the copy (`RELEASE_ARCHIVE_URL`/`RELEASE_CHECKSUM_URL` in the shell script,
|
||||||
@@ -74,7 +86,7 @@ but are imported only when a PDF or an Outlook `.msg` is derived, so a missing o
|
|||||||
that format alone; `doctor` reports each.
|
that format alone; `doctor` reports each.
|
||||||
|
|
||||||
Playwright is the one package that is not in `requirements.txt`: it sits in
|
Playwright is the one package that is not in `requirements.txt`: it sits in
|
||||||
`requirements-browser.txt`, which the preflight installs - together with the Chromium it
|
`requirements-browser.txt` (installed from its lock), which the preflight installs - together with the Chromium it
|
||||||
drives, into `.venv/ms-playwright` - only when the user runs it with `--with browser`, and
|
drives, into `.venv/ms-playwright` - only when the user runs it with `--with browser`, and
|
||||||
keeps up to date from then on (`.venv/.chemenu-browser.sha256` remembers the choice). Only
|
keeps up to date from then on (`.venv/.chemenu-browser.sha256` remembers the choice). Only
|
||||||
`raw login` and a page a site handler declares `render` need it; `browser.py` imports it
|
`raw login` and a page a site handler declares `render` need it; `browser.py` imports it
|
||||||
@@ -288,7 +300,13 @@ ignoring generated copies.
|
|||||||
|
|
||||||
The suite exists in the origin repository only: `dist export` leaves out `chemenu/tests/`,
|
The suite exists in the origin repository only: `dist export` leaves out `chemenu/tests/`,
|
||||||
`pytest.ini` and `.coveragerc`, because the suite tests that repository's own type-specs and
|
`pytest.ini` and `.coveragerc`, because the suite tests that repository's own type-specs and
|
||||||
conventions, not an instance's.
|
conventions, not an instance's. The same goes for the test tools - `requirements-dev.txt` and
|
||||||
|
its lock (pytest, pytest-cov, radicale, pip-audit, uv) - and `lock_requirements.py`, which
|
||||||
|
writes every lock; `instructions/dev/dependency-locks.md` has the procedure.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
.venv/bin/python -m pip install --require-hashes -r requirements-dev.lock # one time
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd tools && .venv/bin/python -m pytest -q
|
cd tools && .venv/bin/python -m pytest -q
|
||||||
@@ -300,13 +318,12 @@ cd tools && .venv/bin/python -m pytest -q
|
|||||||
Coverage is optional locally and measured on every CI run:
|
Coverage is optional locally and measured on every CI run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
.venv/bin/pip install pytest-cov # one time, CI-only dependency
|
|
||||||
.venv/bin/python -m pytest -q --cov
|
.venv/bin/python -m pytest -q --cov
|
||||||
```
|
```
|
||||||
|
|
||||||
`pytest-cov` is deliberately not in `requirements.txt`: that file is what an *instance*
|
`pytest-cov` is deliberately not in `requirements.txt` but in `requirements-dev.txt`: the
|
||||||
needs at runtime and ships with `dist export`, and an instance does not measure this
|
first is what an *instance* needs at runtime and ships with `dist export`, and an instance
|
||||||
suite. Configuration is `.coveragerc` (coverage.py does not read `pytest.ini`), which
|
does not measure this suite. Configuration is `.coveragerc` (coverage.py does not read `pytest.ini`), which
|
||||||
measures `chemenu/` without `chemenu/tests/` and sets no threshold - the origin repository's developer guide, `docs/dev/development.md`
|
measures `chemenu/` without `chemenu/tests/` and sets no threshold - the origin repository's developer guide, `docs/dev/development.md`
|
||||||
§ "How much of the stack the suite reaches", has the measured number and how to read it.
|
§ "How much of the stack the suite reaches", has the measured number and how to read it.
|
||||||
|
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ GROUPS: tuple[tuple[str, tuple[str, ...]], ...] = (
|
|||||||
"sources coverage", "sources trace", "sources rebuild-index",
|
"sources coverage", "sources trace", "sources rebuild-index",
|
||||||
)),
|
)),
|
||||||
("Raw material and uploads", (
|
("Raw material and uploads", (
|
||||||
"raw fetch", "raw login", "raw derive", "raw capture", "raw status", "raw pending", "raw accept",
|
"raw fetch", "raw login", "raw derive", "raw clarify", "raw capture", "raw status", "raw pending", "raw accept",
|
||||||
"upload collect", "upload list", "upload show", "upload accept", "upload reject",
|
"upload collect", "upload list", "upload show", "upload accept", "upload reject",
|
||||||
)),
|
)),
|
||||||
("Git", (
|
("Git", (
|
||||||
|
|||||||
@@ -130,7 +130,15 @@ TOOLS_EXCLUDE_DIRS = {".venv", "__pycache__", ".pytest_cache", ".wikitool_sessio
|
|||||||
# own decisions - so in an exported tree a quarter of it fails, and `pytest` is
|
# own decisions - so in an exported tree a quarter of it fails, and `pytest` is
|
||||||
# not in requirements.txt to run it with anyway. Matched by exact path, not by
|
# not in requirements.txt to run it with anyway. Matched by exact path, not by
|
||||||
# name: a directory called `tests` elsewhere under tools/ would be machinery.
|
# name: a directory called `tests` elsewhere under tools/ would be machinery.
|
||||||
TOOLS_DEV_ONLY = frozenset({"chemenu/tests", "pytest.ini", ".coveragerc"})
|
#
|
||||||
|
# The dependency locks go the same way in part (Gitea #245): an instance ships the
|
||||||
|
# three runtime locks it installs from, but not the test tools' source and lock
|
||||||
|
# (`requirements-dev.*`) nor the script that writes every lock - resolving needs
|
||||||
|
# `uv` and the source files' history, which belong to the origin repository.
|
||||||
|
TOOLS_DEV_ONLY = frozenset({
|
||||||
|
"chemenu/tests", "pytest.ini", ".coveragerc",
|
||||||
|
"requirements-dev.txt", "requirements-dev.lock", "lock_requirements.py",
|
||||||
|
})
|
||||||
|
|
||||||
# The rest of coverage's output lands beside the code rather than in a directory
|
# The rest of coverage's output lands beside the code rather than in a directory
|
||||||
# of its own - `.coverage`, `coverage.xml`, and `.coverage.<host>.<pid>` under a
|
# of its own - `.coverage`, `coverage.xml`, and `.coverage.<host>.<pid>` under a
|
||||||
|
|||||||
@@ -57,11 +57,15 @@ EXPORT_HOW_TO = "docs/how-to/export-to-a-synced-folder.md"
|
|||||||
|
|
||||||
|
|
||||||
def check_python() -> Check:
|
def check_python() -> Check:
|
||||||
|
"""The Python `wikitool` runs on - tools/.venv's - against the span
|
||||||
|
tools/prerequisites.txt admits, the same line the preflight reads."""
|
||||||
version = sys.version_info
|
version = sys.version_info
|
||||||
if version < (3, 11):
|
python = prerequisites.load_manifest().tool("python")
|
||||||
|
if not python.admits(version.major, version.minor):
|
||||||
return Check(
|
return Check(
|
||||||
"python", "FAIL", f"Python {version.major}.{version.minor} found, need >= 3.11",
|
"python", "FAIL",
|
||||||
f"Install Python 3.11+, then: {PREFLIGHT_FIX}",
|
f"tools/.venv runs on Python {version.major}.{version.minor}, the stack needs {python.span()}",
|
||||||
|
f"Install Python {python.span()}, then: {PREFLIGHT_FIX} - it rebuilds tools/.venv on it",
|
||||||
)
|
)
|
||||||
return Check("python", "OK", f"Python {version.major}.{version.minor}.{version.micro}")
|
return Check("python", "OK", f"Python {version.major}.{version.minor}.{version.micro}")
|
||||||
|
|
||||||
|
|||||||
@@ -859,7 +859,9 @@ def rebase_review_token(remote: str, branch: str, local_before: str, remote_tip:
|
|||||||
#
|
#
|
||||||
# The path below takes the generated files out of git's way and puts the result back
|
# The path below takes the generated files out of git's way and puts the result back
|
||||||
# together mechanically: the log is the incoming version plus what only this side appended,
|
# together mechanically: the log is the incoming version plus what only this side appended,
|
||||||
# and the catalog and kb/provenance.md are regenerated from the merged pages. It runs only
|
# and the catalog and kb/provenance.md are regenerated from the merged pages - unless the log
|
||||||
|
# was the only generated file in the way: then the incoming catalog is already right for the
|
||||||
|
# incoming pages, and only the log entries are appended again. It runs only
|
||||||
# where git would otherwise have failed, so a reconcile that succeeds today is unchanged -
|
# where git would otherwise have failed, so a reconcile that succeeds today is unchanged -
|
||||||
# in particular it does not rebuild, because `index rebuild` stamps today's date into
|
# in particular it does not rebuild, because `index rebuild` stamps today's date into
|
||||||
# kb/index.md and every `sync` would then end with a modified file.
|
# kb/index.md and every `sync` would then end with a modified file.
|
||||||
@@ -1049,22 +1051,34 @@ def _resolve_generated_conflicts() -> Optional[str]:
|
|||||||
|
|
||||||
def _rebase_resolving_generated(remote_ref: str) -> tuple[bool, str, bool]:
|
def _rebase_resolving_generated(remote_ref: str) -> tuple[bool, str, bool]:
|
||||||
"""`git rebase --autostash <remote_ref>`, resolving each step whose conflicts are all in
|
"""`git rebase --autostash <remote_ref>`, resolving each step whose conflicts are all in
|
||||||
generated files. Returns (succeeded, detail, resolved anything). Any other stop is aborted,
|
generated files. Returns (succeeded, detail, resolved a generated file other than the log - the
|
||||||
|
log's own conflicts are merged without needing a rebuild). Any other stop is aborted,
|
||||||
which also hands the autostash back."""
|
which also hands the autostash back."""
|
||||||
result = _run(["git", "rebase", "--autostash", remote_ref], env=_NO_EDITOR)
|
result = _run(["git", "rebase", "--autostash", remote_ref], env=_NO_EDITOR)
|
||||||
resolved = False
|
resolved = False
|
||||||
while result.returncode != 0:
|
while result.returncode != 0:
|
||||||
if not _rebase_in_progress():
|
if not _rebase_in_progress():
|
||||||
return False, result.stderr, resolved
|
return False, result.stderr, resolved
|
||||||
|
listed = _run(["git", "diff", "--name-only", "--diff-filter=U", "-z"]).stdout
|
||||||
|
unmerged = [path for path in listed.split("\0") if path]
|
||||||
reason = _resolve_generated_conflicts()
|
reason = _resolve_generated_conflicts()
|
||||||
if reason:
|
if reason:
|
||||||
_run(["git", "rebase", "--abort"])
|
_run(["git", "rebase", "--abort"])
|
||||||
return False, f"{reason}\n{result.stderr}", resolved
|
return False, f"{reason}\n{result.stderr}", resolved
|
||||||
resolved = True
|
# A conflict in the log alone is resolved by the append-merge and leaves the catalog
|
||||||
|
# as the incoming commits wrote it; only another generated file needs a rebuild.
|
||||||
|
resolved = resolved or any(path != GENERATED_LOG for path in unmerged)
|
||||||
result = _run(["git", "rebase", "--continue"], env=_NO_EDITOR)
|
result = _run(["git", "rebase", "--continue"], env=_NO_EDITOR)
|
||||||
return True, "", resolved
|
return True, "", resolved
|
||||||
|
|
||||||
|
|
||||||
|
def append_log_suffix(log_suffix: bytes) -> None:
|
||||||
|
"""Append what only this side added to kb/log.md back onto the incoming version."""
|
||||||
|
if log_suffix:
|
||||||
|
with (config.ROOT / GENERATED_LOG).open("ab") as log:
|
||||||
|
log.write(log_suffix)
|
||||||
|
|
||||||
|
|
||||||
def regenerate_generated(log_suffix: bytes = b"") -> None:
|
def regenerate_generated(log_suffix: bytes = b"") -> None:
|
||||||
"""Append `log_suffix` to kb/log.md, then rewrite the catalog and kb/provenance.md from the
|
"""Append `log_suffix` to kb/log.md, then rewrite the catalog and kb/provenance.md from the
|
||||||
pages in the working tree - what `index rebuild` and `sources rebuild-index` write. The log
|
pages in the working tree - what `index rebuild` and `sources rebuild-index` write. The log
|
||||||
@@ -1072,9 +1086,7 @@ def regenerate_generated(log_suffix: bytes = b"") -> None:
|
|||||||
from chemenu.commands.index_build import write_index
|
from chemenu.commands.index_build import write_index
|
||||||
from chemenu.commands.provenance_cmd import write_provenance_index
|
from chemenu.commands.provenance_cmd import write_provenance_index
|
||||||
|
|
||||||
if log_suffix:
|
append_log_suffix(log_suffix)
|
||||||
with (config.ROOT / GENERATED_LOG).open("ab") as log:
|
|
||||||
log.write(log_suffix)
|
|
||||||
write_index(config.KB_DIR)
|
write_index(config.KB_DIR)
|
||||||
write_provenance_index(config.KB_DIR, config.RAW_DIR)
|
write_provenance_index(config.KB_DIR, config.RAW_DIR)
|
||||||
|
|
||||||
@@ -1084,9 +1096,13 @@ def _around_generated(generated: list[str], operation, regenerate: bool) -> tupl
|
|||||||
(succeeded, detail, resolved generated conflicts) - and then either regenerate or put
|
(succeeded, detail, resolved generated conflicts) - and then either regenerate or put
|
||||||
everything back. Returns (succeeded, detail, regenerated).
|
everything back. Returns (succeeded, detail, regenerated).
|
||||||
|
|
||||||
Regenerates when something generated was set aside or resolved, or when `regenerate` says
|
Regenerates the catalog and kb/provenance.md when a generated file other than kb/log.md
|
||||||
both sides' commits touched a generated file - a textual merge of two catalogs can succeed
|
was set aside or had a conflict resolved, or when `regenerate` says both sides' commits
|
||||||
and still be wrong. The backup ref is dropped on success and kept, and named, on any
|
touched a generated file - a textual merge of two catalogs can succeed and still be wrong.
|
||||||
|
When kb/log.md was all that stood in the way, the catalog the incoming commits brought is
|
||||||
|
already right for the incoming pages, and only the local log entries are appended again:
|
||||||
|
rebuilding would stamp today's date into kb/index.md and leave a changed file behind that
|
||||||
|
no local change explains. The backup ref is dropped on success and kept, and named, on any
|
||||||
failure."""
|
failure."""
|
||||||
backup = _back_up_working_tree()
|
backup = _back_up_working_tree()
|
||||||
if backup is None:
|
if backup is None:
|
||||||
@@ -1105,9 +1121,11 @@ def _around_generated(generated: list[str], operation, regenerate: bool) -> tupl
|
|||||||
f"{detail.rstrip()}\nThe working tree was restored; as it stood before, it is also "
|
f"{detail.rstrip()}\nThe working tree was restored; as it stood before, it is also "
|
||||||
f"kept at {BACKUP_REF} ({backup[:12]})."
|
f"kept at {BACKUP_REF} ({backup[:12]})."
|
||||||
), False
|
), False
|
||||||
regenerated = bool(generated) or resolved or regenerate
|
regenerated = any(path != GENERATED_LOG for path in generated) or resolved or regenerate
|
||||||
if regenerated:
|
if regenerated:
|
||||||
regenerate_generated(aside.log_suffix)
|
regenerate_generated(aside.log_suffix)
|
||||||
|
else:
|
||||||
|
append_log_suffix(aside.log_suffix)
|
||||||
_run(["git", "update-ref", "-d", BACKUP_REF])
|
_run(["git", "update-ref", "-d", BACKUP_REF])
|
||||||
return True, "", regenerated
|
return True, "", regenerated
|
||||||
|
|
||||||
@@ -1119,7 +1137,8 @@ class ReconcileOutcome:
|
|||||||
"up-to-date", "fast-forwarded", "local-ahead", "rebased", "needs-review", "conflict".
|
"up-to-date", "fast-forwarded", "local-ahead", "rebased", "needs-review", "conflict".
|
||||||
The first three are the ways the fetch can fail; `detail` then carries the remote's URL.
|
The first three are the ways the fetch can fail; `detail` then carries the remote's URL.
|
||||||
`regenerated` says the catalog and kb/provenance.md were rewritten afterwards and are an
|
`regenerated` says the catalog and kb/provenance.md were rewritten afterwards and are an
|
||||||
uncommitted change now."""
|
uncommitted change now. It stays False when only kb/log.md was set aside: its local entries
|
||||||
|
are appended again and the catalog is the incoming one."""
|
||||||
status: str
|
status: str
|
||||||
pulled_commits: list[str] = field(default_factory=list)
|
pulled_commits: list[str] = field(default_factory=list)
|
||||||
overlap_files: list[str] = field(default_factory=list)
|
overlap_files: list[str] = field(default_factory=list)
|
||||||
@@ -1407,7 +1426,7 @@ def apply_reconcile(outcome: ReconcileOutcome, remote: str, branch: str, command
|
|||||||
idempotent=cli_contract.Idempotent.YES,
|
idempotent=cli_contract.Idempotent.YES,
|
||||||
atomic="No - fetch, then at most one merge/rebase attempt, aborted cleanly on failure "
|
atomic="No - fetch, then at most one merge/rebase attempt, aborted cleanly on failure "
|
||||||
"with the working tree restored; a success that merged generated files then rewrites "
|
"with the working tree restored; a success that merged generated files then rewrites "
|
||||||
"the catalog",
|
"the catalog, unless `kb/log.md` was the only one",
|
||||||
budget=cli_contract.Budget.COUNTED,
|
budget=cli_contract.Budget.COUNTED,
|
||||||
network=cli_contract.Network.YES,
|
network=cli_contract.Network.YES,
|
||||||
gates=("rebase-review",),
|
gates=("rebase-review",),
|
||||||
@@ -1421,8 +1440,11 @@ def apply_reconcile(outcome: ReconcileOutcome, remote: str, branch: str, command
|
|||||||
"what stops git - uncommitted ones in the way of a fast-forward or rebase, or a rebase "
|
"what stops git - uncommitted ones in the way of a fast-forward or rebase, or a rebase "
|
||||||
"conflict in them - they are merged mechanically: `kb/log.md` becomes the incoming log "
|
"conflict in them - they are merged mechanically: `kb/log.md` becomes the incoming log "
|
||||||
"plus the entries only this side appended, and the catalog and `kb/provenance.md` are "
|
"plus the entries only this side appended, and the catalog and `kb/provenance.md` are "
|
||||||
"regenerated from the merged pages and left as an uncommitted change. A reconcile git "
|
"regenerated from the merged pages and left as an uncommitted change. When only "
|
||||||
"can do on its own is unchanged and regenerates nothing.",
|
"`kb/log.md` stood in the way - an open log entry, nothing else generated - the "
|
||||||
|
"catalog is not rebuilt: the incoming one stays, and just the local entries are "
|
||||||
|
"appended again. A reconcile git can do on its own is unchanged and regenerates "
|
||||||
|
"nothing.",
|
||||||
"Uncommitted changes that no incoming commit touches do not stop a rebase: they are "
|
"Uncommitted changes that no incoming commit touches do not stop a rebase: they are "
|
||||||
"carried through it (`git rebase --autostash`) and come back unchanged.",
|
"carried through it (`git rebase --autostash`) and come back unchanged.",
|
||||||
"Before anything is set aside, the working tree is stored as a commit under "
|
"Before anything is set aside, the working tree is stored as a commit under "
|
||||||
@@ -1602,7 +1624,7 @@ def commit_regenerated(remote: str, branch: str) -> None:
|
|||||||
"upstream state and the set of files touched on both sides.",
|
"upstream state and the set of files touched on both sides.",
|
||||||
"Generated files are never an overlap: where they are all that stops the reconcile, it "
|
"Generated files are never an overlap: where they are all that stops the reconcile, it "
|
||||||
"merges them as `sync` does (both sides' log entries kept, the catalog and "
|
"merges them as `sync` does (both sides' log entries kept, the catalog and "
|
||||||
"`kb/provenance.md` regenerated) and carries uncommitted changes no incoming commit "
|
"`kb/provenance.md` regenerated unless the log alone stood in the way) and carries uncommitted changes no incoming commit "
|
||||||
"touches through the rebase. The proactive reconcile runs before staging, so this "
|
"touches through the rebase. The proactive reconcile runs before staging, so this "
|
||||||
"publish commits the regenerated files - with `--path` too, see there; on the retry "
|
"publish commits the regenerated files - with `--path` too, see there; on the retry "
|
||||||
"after a rejected push they get a commit of their own before the second push.",
|
"after a rejected push they get a commit of their own before the second push.",
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ def ingests_since_last_lint(entries: list[tuple[str, str, str]]) -> int:
|
|||||||
path="log append",
|
path="log append",
|
||||||
summary="Append a formatted entry to `kb/log.md`.",
|
summary="Append a formatted entry to `kb/log.md`.",
|
||||||
synopsis=(cli_contract.Variant(
|
synopsis=(cli_contract.Variant(
|
||||||
usage="log append --op ingest|query|lint|create|update|delete|rename|move "
|
usage="log append --op ingest|lint|create|update|delete|rename|move|query "
|
||||||
'--title "..." [--body "..."|--body-file path]',
|
'--title "..." [--body "..."|--body-file path]',
|
||||||
),),
|
),),
|
||||||
properties=cli_contract.Properties(
|
properties=cli_contract.Properties(
|
||||||
@@ -68,6 +68,9 @@ def ingests_since_last_lint(entries: list[tuple[str, str, str]]) -> int:
|
|||||||
"Appends one entry to `kb/log.md`: a `## [YYYY-MM-DD] <op> | <title>` heading, the body "
|
"Appends one entry to `kb/log.md`: a `## [YYYY-MM-DD] <op> | <title>` heading, the body "
|
||||||
"if one is given, and a `---` separator.",
|
"if one is given, and a `---` separator.",
|
||||||
"Not idempotent: every successful run appends a new entry, including a repeated one.",
|
"Not idempotent: every successful run appends a new entry, including a repeated one.",
|
||||||
|
"`query` is a legacy value: older versions wrote one entry per read-only query. It is "
|
||||||
|
"still accepted so existing logs and an instance's own instructions keep working, but "
|
||||||
|
"the stack no longer writes it - a read is not an operation on the wiki.",
|
||||||
),
|
),
|
||||||
failures=(
|
failures=(
|
||||||
cli_contract.Failure(
|
cli_contract.Failure(
|
||||||
@@ -94,7 +97,9 @@ def ingests_since_last_lint(entries: list[tuple[str, str, str]]) -> int:
|
|||||||
),
|
),
|
||||||
))
|
))
|
||||||
def log_append(
|
def log_append(
|
||||||
op: str = typer.Option(..., "--op", help="|".join(VALID_OPS)),
|
op: str = typer.Option(
|
||||||
|
..., "--op", help="|".join(VALID_OPS) + " (query: legacy, no longer written by the stack)",
|
||||||
|
),
|
||||||
title: str = typer.Option(..., "--title", help="Brief description, e.g. a source path"),
|
title: str = typer.Option(..., "--title", help="Brief description, e.g. a source path"),
|
||||||
body: str = typer.Option("", "--body", help="Optional multi-line details"),
|
body: str = typer.Option("", "--body", help="Optional multi-line details"),
|
||||||
body_file: Optional[Path] = typer.Option(None, "--body-file", help="Read the body from a file instead of --body"),
|
body_file: Optional[Path] = typer.Option(None, "--body-file", help="Read the body from a file instead of --body"),
|
||||||
|
|||||||
@@ -465,6 +465,14 @@ def _ensure_tracker_project(page_title: str, *, resume: bool) -> Optional[str]:
|
|||||||
cause="`--resume` with a type other than `project`",
|
cause="`--resume` with a type other than `project`",
|
||||||
reaction="Drop `--resume` and retry once",
|
reaction="Drop `--resume` and retry once",
|
||||||
),
|
),
|
||||||
|
cli_contract.Failure(
|
||||||
|
label="new project",
|
||||||
|
cause="The name is already the title of a `kb/` page - typically the entity page of "
|
||||||
|
"the artifact the project concerns",
|
||||||
|
reaction="Not transient - name the project after its undertaking or outcome "
|
||||||
|
"(`kb/CONVENTIONS.md` § Naming) and retry once. Nothing was created, no tracker "
|
||||||
|
"project either",
|
||||||
|
),
|
||||||
cli_contract.Failure(
|
cli_contract.Failure(
|
||||||
label="new project",
|
label="new project",
|
||||||
cause="The name is already taken in the tracker (case-insensitively; for `caldav` "
|
cause="The name is already taken in the tracker (case-insensitively; for `caldav` "
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ subcommands are listed in `-h` and in the generated command reference.
|
|||||||
"""
|
"""
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
from chemenu.commands.raw import accept, pending, fetch, login, derive, capture
|
from chemenu.commands.raw import accept, pending, fetch, login, derive, capture, clarify
|
||||||
|
|
||||||
app = typer.Typer(help="Bring raw material into incoming/, and promote it from there into raw/.")
|
app = typer.Typer(help="Bring raw material into incoming/, and promote it from there into raw/.")
|
||||||
|
|
||||||
@@ -16,5 +16,6 @@ app.command("pending")(pending.raw_pending_command)
|
|||||||
app.command("fetch")(fetch.raw_fetch_command)
|
app.command("fetch")(fetch.raw_fetch_command)
|
||||||
app.command("login")(login.raw_login_command)
|
app.command("login")(login.raw_login_command)
|
||||||
app.command("derive")(derive.raw_derive_command)
|
app.command("derive")(derive.raw_derive_command)
|
||||||
|
app.command("clarify")(clarify.raw_clarify_command)
|
||||||
app.command("capture")(capture.raw_capture_command)
|
app.command("capture")(capture.raw_capture_command)
|
||||||
app.command("status")(capture.raw_status_command)
|
app.command("status")(capture.raw_status_command)
|
||||||
@@ -33,6 +33,59 @@ def _incoming_dir() -> Path:
|
|||||||
return config.ROOT / "incoming"
|
return config.ROOT / "incoming"
|
||||||
|
|
||||||
|
|
||||||
|
# The companion file of a source (Gitea #241): the operator's answers to what the ingest
|
||||||
|
# asked about it. Beside the original it is `<stem>.clarifications[-N].md`; inside a
|
||||||
|
# folder it is `clarifications[-N].md`. The pattern stands here and nowhere else -
|
||||||
|
# `raw clarify` writes the names, `raw pending` and `raw accept` read them.
|
||||||
|
CLARIFICATIONS_KIND = "clarifications"
|
||||||
|
_CLARIFICATION_BESIDE = re.compile(r"^(?P<stem>.+)\.clarifications(?:-\d+)?\.md$")
|
||||||
|
|
||||||
|
|
||||||
|
def _clarification_stem(name: str) -> Optional[str]:
|
||||||
|
"""The stem of the original a companion file named `name` belongs to, or
|
||||||
|
None when `name` is not one."""
|
||||||
|
match = _CLARIFICATION_BESIDE.match(name)
|
||||||
|
return match.group("stem") if match else None
|
||||||
|
|
||||||
|
|
||||||
|
def _is_clarification(path: Path) -> bool:
|
||||||
|
return _clarification_stem(path.name) is not None
|
||||||
|
|
||||||
|
|
||||||
|
def _source_stem(path: Path) -> str:
|
||||||
|
"""The stem a top-level file of `incoming/` is grouped and named by: its
|
||||||
|
own, except that a companion file belongs to its original's."""
|
||||||
|
return _clarification_stem(path.name) or path.stem
|
||||||
|
|
||||||
|
|
||||||
|
def _clarification_name(stem: str, taken) -> str:
|
||||||
|
"""`<stem>.clarifications.md`, with `-2`, `-3` before the extension while
|
||||||
|
`taken(name)` says the name is in use - the rule `raw derive` uses."""
|
||||||
|
name = f"{stem}.{CLARIFICATIONS_KIND}.md"
|
||||||
|
number = 2
|
||||||
|
while taken(name):
|
||||||
|
name = f"{stem}.{CLARIFICATIONS_KIND}-{number}.md"
|
||||||
|
number += 1
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
def _check_clarifications(resolved: list[Path], existing_raw_paths: list[Path]) -> None:
|
||||||
|
"""A companion file belongs to an original: one in this call or one the
|
||||||
|
`--page` page already holds, with the same stem. A clarification of nothing
|
||||||
|
is not a source."""
|
||||||
|
originals = {p.stem for p in resolved if not _is_clarification(p)}
|
||||||
|
originals |= {p.stem for p in existing_raw_paths if not _is_clarification(p)}
|
||||||
|
for path in resolved:
|
||||||
|
stem = _clarification_stem(path.name)
|
||||||
|
if stem is not None and stem not in originals:
|
||||||
|
raise _Refused(
|
||||||
|
f"{rel_path(path)} is a clarification of {stem!r}, and no file of that name is in "
|
||||||
|
"this call or already in the --page page's raw_files:. A clarification is not a "
|
||||||
|
"source of its own - pass its original in the same call, or use --page for a "
|
||||||
|
"source that is already in raw/."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _resolve(raw: Path) -> Path:
|
def _resolve(raw: Path) -> Path:
|
||||||
return raw if raw.is_absolute() else config.ROOT / raw
|
return raw if raw.is_absolute() else config.ROOT / raw
|
||||||
|
|
||||||
@@ -210,6 +263,7 @@ def _plan_file_moves(
|
|||||||
# (Gitea #58 decision 3): from the second file on, never before. Whenever
|
# (Gitea #58 decision 3): from the second file on, never before. Whenever
|
||||||
# --page targets an existing page it always has >=1 raw file already
|
# --page targets an existing page it always has >=1 raw file already
|
||||||
# (types/source.md requires raw_files:), so bundling always applies there.
|
# (types/source.md requires raw_files:), so bundling always applies there.
|
||||||
|
_check_clarifications(resolved, existing_raw_paths)
|
||||||
total = len(existing_raw_paths) + len(resolved)
|
total = len(existing_raw_paths) + len(resolved)
|
||||||
bundle_dir: Optional[Path] = None
|
bundle_dir: Optional[Path] = None
|
||||||
if len(existing_raw_paths) >= 2:
|
if len(existing_raw_paths) >= 2:
|
||||||
@@ -227,10 +281,13 @@ def _plan_file_moves(
|
|||||||
# directory, never at today's shard - the file's capture date is
|
# directory, never at today's shard - the file's capture date is
|
||||||
# whatever it always was, and a bundle mixing an old and a new
|
# whatever it always was, and a bundle mixing an old and a new
|
||||||
# shard would have no single correct address.
|
# shard would have no single correct address.
|
||||||
primary = existing_raw_paths[0]
|
primary = next(
|
||||||
|
(p for p in existing_raw_paths if not _is_clarification(p)), existing_raw_paths[0]
|
||||||
|
)
|
||||||
bundle_dir = primary.parent / primary.stem
|
bundle_dir = primary.parent / primary.stem
|
||||||
else:
|
else:
|
||||||
primary = resolved[0]
|
# named after the original, whatever order the call lists it in (Gitea #241)
|
||||||
|
primary = next((p for p in resolved if not _is_clarification(p)), resolved[0])
|
||||||
bundle_dir = _shard_dir() / primary.stem
|
bundle_dir = _shard_dir() / primary.stem
|
||||||
|
|
||||||
moves: list[tuple[Path, Path]] = []
|
moves: list[tuple[Path, Path]] = []
|
||||||
|
|||||||
@@ -0,0 +1,256 @@
|
|||||||
|
"""`wikitool raw clarify` - the operator's answers to what an ingest asked about a source,
|
||||||
|
written as a companion file beside the source instead of as a second source (Gitea #241).
|
||||||
|
|
||||||
|
Like `raw fetch` and `raw derive` it ends in `incoming/`, never in `raw/`: `raw accept`
|
||||||
|
promotes the companion file with its original as one bundle. The name and the place are
|
||||||
|
computed, never chosen; the answers go in as the operator gave them, one line each.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Annotated, Optional
|
||||||
|
|
||||||
|
import typer
|
||||||
|
from rich.markup import escape
|
||||||
|
|
||||||
|
from chemenu import cli_contract, config, repo_capture, web_capture
|
||||||
|
from chemenu.commands._util import fail, path_budget_problem_for, rel_path, success
|
||||||
|
from chemenu.commands.raw._common import (
|
||||||
|
CLARIFICATIONS_KIND,
|
||||||
|
_Refused,
|
||||||
|
_check_directly_in_incoming,
|
||||||
|
_clarification_name,
|
||||||
|
_incoming_dir,
|
||||||
|
_is_clarification,
|
||||||
|
_refusals_fail,
|
||||||
|
_resolve,
|
||||||
|
_shard_dir,
|
||||||
|
_source_stem,
|
||||||
|
_walk_folder,
|
||||||
|
_write_exclusive,
|
||||||
|
)
|
||||||
|
from chemenu.kb_scan import load_kb_pages
|
||||||
|
from chemenu.provenance import source_raw_files
|
||||||
|
|
||||||
|
FOLDER_NAME = f"{CLARIFICATIONS_KIND}.md"
|
||||||
|
_LISTED_FILES = 10
|
||||||
|
|
||||||
|
|
||||||
|
def _check_items(items: list[str]) -> list[str]:
|
||||||
|
if not items:
|
||||||
|
raise _Refused("Pass at least one --item: a clarification without an answer is no file.")
|
||||||
|
cleaned = []
|
||||||
|
for item in items:
|
||||||
|
text = item.strip()
|
||||||
|
if not text:
|
||||||
|
raise _Refused("An --item is empty.")
|
||||||
|
if "\n" in text or "\r" in text:
|
||||||
|
raise _Refused(
|
||||||
|
f"--item {text.splitlines()[0]!r} spans lines. One item is one line - pass one "
|
||||||
|
"--item per point."
|
||||||
|
)
|
||||||
|
cleaned.append(text)
|
||||||
|
return cleaned
|
||||||
|
|
||||||
|
|
||||||
|
def _render(items: list[str], files: list[str], *, answered: str) -> bytes:
|
||||||
|
shown = files[:_LISTED_FILES]
|
||||||
|
if len(files) > _LISTED_FILES:
|
||||||
|
shown.append(f"... and {len(files) - _LISTED_FILES} more")
|
||||||
|
header = web_capture.header([
|
||||||
|
("kind", CLARIFICATIONS_KIND),
|
||||||
|
("written_by", "wikitool raw clarify"),
|
||||||
|
("clarifies", shown),
|
||||||
|
("answered", answered),
|
||||||
|
("by", "operator, in the ingest dialog"),
|
||||||
|
])
|
||||||
|
body = "\n".join(f"- {item}" for item in items)
|
||||||
|
return (header + "\n" + body + "\n").encode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def _plan_entry(entry: Path, items: list[str]) -> tuple[Path, bytes]:
|
||||||
|
"""The file for an entry of `incoming/`: where it goes and what it holds."""
|
||||||
|
incoming = _incoming_dir()
|
||||||
|
_check_directly_in_incoming(entry, incoming)
|
||||||
|
if entry.name.startswith(".") or entry.is_symlink():
|
||||||
|
raise _Refused(f"{rel_path(entry)} is hidden or a symlink - raw clarify does not take it.")
|
||||||
|
if entry.is_dir():
|
||||||
|
if (entry / repo_capture.MANIFEST_NAME).is_file():
|
||||||
|
raise _Refused(
|
||||||
|
f"{rel_path(entry)}/ is a captured bundle; its manifest describes exactly what it "
|
||||||
|
"holds, so a file added to it would not match it."
|
||||||
|
)
|
||||||
|
files, _dirs, _refused = _walk_folder(entry)
|
||||||
|
if not files:
|
||||||
|
raise _Refused(f"{rel_path(entry)}/ holds no file to clarify.")
|
||||||
|
name = _clarification_name(
|
||||||
|
"", lambda n: os.path.lexists(entry / n.removeprefix("."))
|
||||||
|
).removeprefix(".")
|
||||||
|
target = entry / name
|
||||||
|
listed = sorted(p.relative_to(entry).as_posix() for p in files)
|
||||||
|
listed = [f"{entry.name}/{p}" for p in listed]
|
||||||
|
budget = _shard_dir() / entry.name / name
|
||||||
|
else:
|
||||||
|
if not entry.is_file():
|
||||||
|
raise _Refused(f"{rel_path(entry)} does not exist.")
|
||||||
|
if _is_clarification(entry):
|
||||||
|
raise _Refused(f"{rel_path(entry)} is itself a clarification - clarify its original.")
|
||||||
|
stem = _source_stem(entry)
|
||||||
|
name = _clarification_name(stem, lambda n: os.path.lexists(incoming / n))
|
||||||
|
target = incoming / name
|
||||||
|
group = sorted(
|
||||||
|
(p for p in incoming.iterdir()
|
||||||
|
if p.is_file() and not p.name.startswith(".") and not _is_clarification(p)
|
||||||
|
and _source_stem(p) == stem),
|
||||||
|
key=lambda p: os.fsencode(p.name),
|
||||||
|
)
|
||||||
|
listed = [p.name for p in group]
|
||||||
|
budget = _shard_dir() / stem / name
|
||||||
|
problem = path_budget_problem_for(budget)
|
||||||
|
if problem:
|
||||||
|
raise _Refused(f"Cannot write {problem}. The name comes from the source in incoming/: shorten it.")
|
||||||
|
return target, _render(items, listed, answered=datetime.date.today().isoformat())
|
||||||
|
|
||||||
|
|
||||||
|
def _plan_page(title: str, items: list[str]):
|
||||||
|
"""The file for a source that is already in `raw/`: named after the stem of
|
||||||
|
its original, and the `raw accept --page` line that promotes it."""
|
||||||
|
pages = load_kb_pages(config.KB_DIR)
|
||||||
|
page = pages.get(title)
|
||||||
|
if page is None:
|
||||||
|
raise _Refused(f"No page titled '{title}' found under kb/.")
|
||||||
|
existing = [config.ROOT / p for p in source_raw_files(page)]
|
||||||
|
if not existing:
|
||||||
|
raise _Refused(f"'{title}' has no raw_files: - there is no source to clarify.")
|
||||||
|
for path in existing:
|
||||||
|
captured = repo_capture.captured_bundle_of(path, config.RAW_DIR)
|
||||||
|
if captured is not None:
|
||||||
|
raise _Refused(
|
||||||
|
f"'{title}' is a captured bundle ({rel_path(captured)}/); its manifest describes "
|
||||||
|
"exactly what it holds, so a file added to it would not match it."
|
||||||
|
)
|
||||||
|
originals = [p for p in existing if not _is_clarification(p)]
|
||||||
|
if not originals:
|
||||||
|
raise _Refused(f"'{title}' holds only clarifications in raw_files:.")
|
||||||
|
incoming = _incoming_dir()
|
||||||
|
# names in the directory the source's files sit in - its bundle, or the shard of a lone file
|
||||||
|
held = {p.name for p in existing}
|
||||||
|
if existing[0].parent.is_dir():
|
||||||
|
held |= {c.name for c in existing[0].parent.iterdir()}
|
||||||
|
stem = originals[0].stem
|
||||||
|
name = _clarification_name(stem, lambda n: n in held or os.path.lexists(incoming / n))
|
||||||
|
problem = path_budget_problem_for(originals[0].parent / stem / name)
|
||||||
|
if problem:
|
||||||
|
raise _Refused(f"Cannot write {problem}. The name comes from the source's file: it is too long.")
|
||||||
|
fidelity = page.frontmatter.get("fidelity") or "<fidelity>"
|
||||||
|
authority = page.frontmatter.get("authority") or "<authority>"
|
||||||
|
target = incoming / name
|
||||||
|
content = _render(items, [p.name for p in existing], answered=datetime.date.today().isoformat())
|
||||||
|
line = (
|
||||||
|
f'tools/wikitool raw accept --page "{title}" --fidelity {fidelity} '
|
||||||
|
f"--authority {authority} {rel_path(target)}"
|
||||||
|
)
|
||||||
|
return target, content, line
|
||||||
|
|
||||||
|
|
||||||
|
@cli_contract.record(cli_contract.CommandRecord(
|
||||||
|
path="raw clarify",
|
||||||
|
summary="Write the operator's answers to an ingest's questions about a source as a companion "
|
||||||
|
"file in `incoming/`, to be promoted with the source instead of as a source of its own.",
|
||||||
|
synopsis=(
|
||||||
|
cli_contract.Variant(
|
||||||
|
usage='raw clarify incoming/<entry> --item "<answer>" [--item "<answer>" ...]',
|
||||||
|
notes="A file, a file of a stem bundle, or a folder in `incoming/`: write "
|
||||||
|
"`<stem>.clarifications.md` beside it, or `clarifications.md` inside the folder",
|
||||||
|
),
|
||||||
|
cli_contract.Variant(
|
||||||
|
usage='raw clarify --page "<Title>" --item "<answer>" [--item "<answer>" ...]',
|
||||||
|
notes="A source already in `raw/`: write the companion file to `incoming/` and print "
|
||||||
|
"the `raw accept --page` line that adds it to the source's bundle",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
properties=cli_contract.Properties(
|
||||||
|
effect=cli_contract.Effect.WRITE,
|
||||||
|
idempotent=cli_contract.Idempotent.NO,
|
||||||
|
atomic="Yes - everything is checked before the one write, and the file is created "
|
||||||
|
"exclusively, so an existing file is never overwritten",
|
||||||
|
budget=cli_contract.Budget.COUNTED,
|
||||||
|
network=cli_contract.Network.NO,
|
||||||
|
),
|
||||||
|
notes=(
|
||||||
|
"Writes into `incoming/` only, never into `raw/`, and reads no network. The name and the "
|
||||||
|
"place are computed, never chosen: `incoming/<stem>.clarifications.md` for a file or a "
|
||||||
|
"stem bundle, `incoming/<folder>/clarifications.md` for a folder; a taken name gets "
|
||||||
|
"`-2`, `-3` before the extension, and no existing file is overwritten.",
|
||||||
|
"The file starts with a fixed header (`kind`, `written_by`, `clarifies` - the file(s) it "
|
||||||
|
"belongs to, `answered` - today's date, `by`), then one bullet per `--item`, word for "
|
||||||
|
"word as passed. An item is one line; its language is the one the operator answered in.",
|
||||||
|
"What belongs in it is what this ingest session asked about this source and the operator "
|
||||||
|
"answered in a few points - the date of the recording, who took part, an abbreviation, a "
|
||||||
|
"transcription error. What the operator adds unprompted, or says about a subject of its "
|
||||||
|
"own, stays a source of its own (`instructions/wiki-ingest/SKILL.md`).",
|
||||||
|
"`raw pending` lists the companion file with its original as one candidate, and `raw "
|
||||||
|
"accept` promotes both as one bundle named after the original, whatever order the "
|
||||||
|
"files are passed in. A companion file with no original in the call (or, with `--page`, "
|
||||||
|
"in the page's raw_files:) is refused.",
|
||||||
|
"`--page` names the file after the stem of the source's first file and prints the `raw "
|
||||||
|
"accept --page` line with the page's own `fidelity` and `authority` - a bundle has one "
|
||||||
|
"pair, and the companion file inherits it.",
|
||||||
|
),
|
||||||
|
failures=(
|
||||||
|
cli_contract.Failure(
|
||||||
|
cause="No `--item`, an empty or multi-line one, an entry that is not directly in "
|
||||||
|
"`incoming/`, a captured bundle, or neither (or both of) an entry and `--page`",
|
||||||
|
reaction="Nothing was written. Fix the call and retry once",
|
||||||
|
),
|
||||||
|
cli_contract.Failure(
|
||||||
|
cause="`--page` names no page, or one without `raw_files:`",
|
||||||
|
reaction="Nothing was written. Check the title with `wikitool search`, then retry once",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
examples=(
|
||||||
|
'tools/wikitool raw clarify incoming/meeting.vtt --item "Termindatum: 2026-11-12"',
|
||||||
|
'tools/wikitool raw clarify incoming/workshop --item "Teilnehmer: A, B" --item "KI = künstliche Intelligenz"',
|
||||||
|
'tools/wikitool raw clarify --page "Source - Meeting" --item "Projekt: Alpha"',
|
||||||
|
),
|
||||||
|
never=(
|
||||||
|
"Never put the operator's unprompted new content in a clarification - it is a source of "
|
||||||
|
"its own.",
|
||||||
|
"Never write a clarification by hand into `raw/`; `raw accept` promotes it.",
|
||||||
|
),
|
||||||
|
see_also=(
|
||||||
|
"`raw/CONTRACT.md` \"Getting a file in: incoming/\" - the companion file and its bundle",
|
||||||
|
"`wikitool raw accept` - promotes the companion file with its original",
|
||||||
|
"`instructions/wiki-ingest/SKILL.md` - when to ask, and where the answer goes",
|
||||||
|
),
|
||||||
|
))
|
||||||
|
def raw_clarify_command(
|
||||||
|
entry: Annotated[Optional[Path], typer.Argument(
|
||||||
|
help="A file or folder directly in incoming/ (omit with --page)"
|
||||||
|
)] = None,
|
||||||
|
item: Annotated[Optional[list[str]], typer.Option(
|
||||||
|
"--item", help="One answer, one line; repeat for more"
|
||||||
|
)] = None,
|
||||||
|
page: Annotated[Optional[str], typer.Option(
|
||||||
|
"--page", help="Clarify the source of this existing page instead of an entry of incoming/"
|
||||||
|
)] = None,
|
||||||
|
):
|
||||||
|
"""Write the operator's answers about a source as a companion file in
|
||||||
|
incoming/. See raw/CONTRACT.md "Getting a file in: incoming/"."""
|
||||||
|
if (entry is None) == (page is None):
|
||||||
|
fail("Pass either a file or folder in incoming/, or --page \"<Title>\" - exactly one of them.")
|
||||||
|
items = _refusals_fail(_check_items, list(item or []))
|
||||||
|
if page is not None:
|
||||||
|
target, content, line = _refusals_fail(_plan_page, page, items)
|
||||||
|
_write_exclusive([(target, content)])
|
||||||
|
success(escape(f"Wrote {rel_path(target)} ({len(items)} item(s))."))
|
||||||
|
typer.echo(f" Next:\n {line}")
|
||||||
|
return
|
||||||
|
target, content = _refusals_fail(_plan_entry, _resolve(entry), items)
|
||||||
|
_write_exclusive([(target, content)])
|
||||||
|
success(escape(
|
||||||
|
f"Wrote {rel_path(target)} ({len(items)} item(s)). `raw accept` promotes it with its "
|
||||||
|
"original as one source."
|
||||||
|
))
|
||||||
@@ -27,6 +27,7 @@ from chemenu.commands.raw._common import (
|
|||||||
_check_files,
|
_check_files,
|
||||||
_derive_hint,
|
_derive_hint,
|
||||||
_incoming_dir,
|
_incoming_dir,
|
||||||
|
_source_stem,
|
||||||
_plan_captured_folder,
|
_plan_captured_folder,
|
||||||
_plan_file_moves,
|
_plan_file_moves,
|
||||||
_plan_folder,
|
_plan_folder,
|
||||||
@@ -81,7 +82,8 @@ def _pending_candidates() -> list[_Candidate]:
|
|||||||
"""The candidates in `incoming/`, oldest first (Gitea #112 E1/E5).
|
"""The candidates in `incoming/`, oldest first (Gitea #112 E1/E5).
|
||||||
|
|
||||||
Only top-level entries count; dotfiles and empty directories are none.
|
Only top-level entries count; dotfiles and empty directories are none.
|
||||||
Top-level files sharing a stem are one `bundle` - a `raw fetch` pair. A top-level folder is one `folder`, with every
|
Top-level files sharing a stem are one `bundle` - a `raw fetch` pair, or a file with its
|
||||||
|
`<stem>.clarifications.md` (Gitea #241). A top-level folder is one `folder`, with every
|
||||||
file below it. A unit is as new as its newest part, so a bundle or folder
|
file below it. A unit is as new as its newest part, so a bundle or folder
|
||||||
sorts by the newest mtime it holds; a tie goes by the path's bytes."""
|
sorts by the newest mtime it holds; a tie goes by the path's bytes."""
|
||||||
incoming = _incoming_dir()
|
incoming = _incoming_dir()
|
||||||
@@ -104,7 +106,7 @@ def _pending_candidates() -> list[_Candidate]:
|
|||||||
"folder", (entry,), count, newest, _refusal(check, entry)
|
"folder", (entry,), count, newest, _refusal(check, entry)
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
by_stem.setdefault(entry.stem, []).append(entry)
|
by_stem.setdefault(_source_stem(entry), []).append(entry)
|
||||||
for paths in by_stem.values():
|
for paths in by_stem.values():
|
||||||
paths.sort(key=lambda p: os.fsencode(p.name))
|
paths.sort(key=lambda p: os.fsencode(p.name))
|
||||||
candidates.append(_Candidate(
|
candidates.append(_Candidate(
|
||||||
|
|||||||
+10
-8
@@ -142,12 +142,14 @@ def reset() -> None:
|
|||||||
"""Drop every assignment onto a managed path name, back to resolution.
|
"""Drop every assignment onto a managed path name, back to resolution.
|
||||||
|
|
||||||
The test suite calls this between tests, and it is not optional there.
|
The test suite calls this between tests, and it is not optional there.
|
||||||
`monkeypatch.setattr(config, "KB_DIR", tmp)` records the old value by
|
Up to pytest 9.1, `monkeypatch.setattr(config, "KB_DIR", tmp)` recorded
|
||||||
*reading* it - which resolves it - and its undo then writes that resolved
|
the old value by *reading* it - which resolves it - and its undo then
|
||||||
path back as a real attribute. The name is bound from then on, so the next
|
wrote that resolved path back as a real attribute. The name was bound from
|
||||||
caller to repoint only `ROOT` gets a `KB_DIR` still aimed at the previous
|
then on, so the next caller to repoint only `ROOT` got a `KB_DIR` still
|
||||||
tree: exactly the half-repointed state this module was rewritten to make
|
aimed at the previous tree: exactly the half-repointed state this module
|
||||||
unconstructible, rebuilt by the cleanup rather than by the test.
|
was rewritten to make unconstructible, rebuilt by the cleanup rather than
|
||||||
|
by the test. The suite now repoints through `conftest.set_config_path`,
|
||||||
|
which patches the module dict as a dict, and still resets as a backstop.
|
||||||
"""
|
"""
|
||||||
for name in MANAGED_PATHS:
|
for name in MANAGED_PATHS:
|
||||||
globals().pop(name, None)
|
globals().pop(name, None)
|
||||||
@@ -157,8 +159,8 @@ def __getattr__(name: str):
|
|||||||
"""Resolve `ROOT` and the paths under it on access (PEP 562).
|
"""Resolve `ROOT` and the paths under it on access (PEP 562).
|
||||||
|
|
||||||
Only reached for names *not* in the module dict, so an explicit assignment
|
Only reached for names *not* in the module dict, so an explicit assignment
|
||||||
- `monkeypatch.setattr(config, "ROOT", tmp)` - keeps working and now also
|
- `config.ROOT = tmp`, or the suite's `set_config_path` - keeps working and
|
||||||
carries the derived paths with it, which is the bug this replaces.
|
now also carries the derived paths with it, which is the bug this replaces.
|
||||||
"""
|
"""
|
||||||
if name == "ROOT":
|
if name == "ROOT":
|
||||||
return resolve_root()
|
return resolve_root()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Wiki Log
|
# Wiki Log
|
||||||
|
|
||||||
This is the chronological audit log of all operations on the wiki.
|
This is the audit log of the operations on the wiki, in the order the entries arrived.
|
||||||
Each entry records what happened, when, and with what result.
|
Each entry records what happened, when, and with what result.
|
||||||
|
|
||||||
## Entry Format
|
## Entry Format
|
||||||
@@ -13,6 +13,6 @@ Each entry records what happened, when, and with what result.
|
|||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
Operation types: `ingest`, `query`, `lint`, `create`, `update`, `delete`
|
Operation types: `ingest`, `lint`, `create`, `update`, `delete`, `rename`, `move`
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -12,7 +12,7 @@ neither can drift silently:
|
|||||||
preflight and `doctor` read it. `INSTALL.md` carries it as a generated
|
preflight and `doctor` read it. `INSTALL.md` carries it as a generated
|
||||||
region per platform value (`<!-- wikitool:prerequisites -->` for `all`,
|
region per platform value (`<!-- wikitool:prerequisites -->` for `all`,
|
||||||
`<!-- wikitool:prerequisites-<platform> -->` otherwise), rendered from the
|
`<!-- wikitool:prerequisites-<platform> -->` otherwise), rendered from the
|
||||||
label and minimum version only. The manifest's `why` field stays out: it
|
label and version bounds only. The manifest's `why` field stays out: it
|
||||||
explains a tool to whoever reads the preflight's own output, while the
|
explains a tool to whoever reads the preflight's own output, while the
|
||||||
region only says what to install. A region is never placed by the tool -
|
region only says what to install. A region is never placed by the tool -
|
||||||
where it goes is the human document's own decision - so a missing one is
|
where it goes is the human document's own decision - so a missing one is
|
||||||
@@ -63,12 +63,19 @@ def region_name(platform: str) -> str:
|
|||||||
return REGION_PREFIX if platform == "all" else f"{REGION_PREFIX}-{platform}"
|
return REGION_PREFIX if platform == "all" else f"{REGION_PREFIX}-{platform}"
|
||||||
|
|
||||||
|
|
||||||
|
def _bounds(tool: prerequisites.Tool) -> str:
|
||||||
|
if tool.minimum and tool.maximum:
|
||||||
|
return f" {tool.minimum} – {tool.maximum}"
|
||||||
|
if tool.minimum:
|
||||||
|
return f" ≥ {tool.minimum}"
|
||||||
|
if tool.maximum:
|
||||||
|
return f" ≤ {tool.maximum}"
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def render_lines(tools: tuple[prerequisites.Tool, ...]) -> list[str]:
|
def render_lines(tools: tuple[prerequisites.Tool, ...]) -> list[str]:
|
||||||
"""One list item per tool - label and minimum version, nothing in a language."""
|
"""One list item per tool - label and version bounds, nothing in a language."""
|
||||||
return [
|
return [f"- **{tool.label}**{_bounds(tool)}" for tool in tools]
|
||||||
f"- **{tool.label}**" + (f" ≥ {tool.minimum}" if tool.minimum else "")
|
|
||||||
for tool in tools
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def expected_regions(manifest: prerequisites.Manifest) -> dict[str, str]:
|
def expected_regions(manifest: prerequisites.Manifest) -> dict[str, str]:
|
||||||
|
|||||||
@@ -45,6 +45,29 @@ class Tool:
|
|||||||
platforms: str
|
platforms: str
|
||||||
label: str
|
label: str
|
||||||
why: str
|
why: str
|
||||||
|
maximum: Optional[str] = None
|
||||||
|
|
||||||
|
def admits(self, major: int, minor: int) -> bool:
|
||||||
|
"""Whether major.minor lies within this tool's bounds, both inclusive."""
|
||||||
|
have = (major, minor)
|
||||||
|
return ((self.minimum is None or have >= version_tuple(self.minimum))
|
||||||
|
and (self.maximum is None or have <= version_tuple(self.maximum)))
|
||||||
|
|
||||||
|
def span(self) -> str:
|
||||||
|
"""The admitted versions in words: `3.13 to 3.14`, `7 or newer`, or ``."""
|
||||||
|
if self.minimum and self.maximum:
|
||||||
|
return f"{self.minimum} to {self.maximum}"
|
||||||
|
if self.minimum:
|
||||||
|
return f"{self.minimum} or newer"
|
||||||
|
if self.maximum:
|
||||||
|
return f"{self.maximum} or older"
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def version_tuple(text: str) -> tuple[int, int]:
|
||||||
|
"""`3.13` -> (3, 13), `7` -> (7, 0) - the major.minor the manifest names."""
|
||||||
|
major, _, minor = text.partition(".")
|
||||||
|
return int(major), int(minor or 0)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@@ -64,6 +87,12 @@ class Manifest:
|
|||||||
def tools_for(self, platform: str) -> tuple[Tool, ...]:
|
def tools_for(self, platform: str) -> tuple[Tool, ...]:
|
||||||
return tuple(t for t in self.tools if t.platforms in ("all", platform))
|
return tuple(t for t in self.tools if t.platforms in ("all", platform))
|
||||||
|
|
||||||
|
def tool(self, name: str) -> Tool:
|
||||||
|
for candidate in self.tools:
|
||||||
|
if candidate.name == name:
|
||||||
|
return candidate
|
||||||
|
raise KeyError(name)
|
||||||
|
|
||||||
|
|
||||||
def manifest_path() -> Path:
|
def manifest_path() -> Path:
|
||||||
return config._PACKAGE_ROOT / "tools" / "prerequisites.txt"
|
return config._PACKAGE_ROOT / "tools" / "prerequisites.txt"
|
||||||
@@ -82,7 +111,8 @@ def load_manifest(path: Optional[Path] = None) -> Manifest:
|
|||||||
limits[fields[1]] = int(fields[2])
|
limits[fields[1]] = int(fields[2])
|
||||||
elif fields[0] == "tool":
|
elif fields[0] == "tool":
|
||||||
minimum = None if fields[2] == "-" else fields[2]
|
minimum = None if fields[2] == "-" else fields[2]
|
||||||
tools.append(Tool(fields[1], minimum, fields[3], fields[4], fields[5]))
|
maximum = None if fields[3] == "-" else fields[3]
|
||||||
|
tools.append(Tool(fields[1], minimum, fields[4], fields[5], fields[6], maximum))
|
||||||
elif fields[0] == "optional":
|
elif fields[0] == "optional":
|
||||||
optional.append(OptionalTool(fields[1], fields[2], fields[3]))
|
optional.append(OptionalTool(fields[1], fields[2], fields[3]))
|
||||||
return Manifest(limits, tuple(tools), tuple(optional))
|
return Manifest(limits, tuple(tools), tuple(optional))
|
||||||
|
|||||||
@@ -177,11 +177,13 @@ def hermetic_environment(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
|||||||
monkeypatch.setattr(toolpaths, "tools_file", lambda: home / toolpaths.FILE_NAME)
|
monkeypatch.setattr(toolpaths, "tools_file", lambda: home / toolpaths.FILE_NAME)
|
||||||
|
|
||||||
# The same hole as the environment above, one layer in: `config` resolves
|
# The same hole as the environment above, one layer in: `config` resolves
|
||||||
# its paths on access, and `monkeypatch.setattr(config, "KB_DIR", ...)`
|
# its paths on access, and an assignment onto one of them - a test that
|
||||||
# undoes itself by writing the *resolved* old path back as a real
|
# sets `config.KB_DIR = ...` by hand - outlives the test and hands the next
|
||||||
# attribute. That binding outlives the test and hands the next one a
|
# one a corpus directory belonging to the previous tree. Cleared on both
|
||||||
# corpus directory belonging to the previous tree. Cleared on both sides,
|
# sides, so neither a leak from before nor one from this test can be
|
||||||
# so neither a leak from before nor one from this test can be inherited.
|
# inherited. A test repoints a path with `set_config_path()` below, whose
|
||||||
|
# undo copes with this reset having run first; `pytest_runtest_teardown`
|
||||||
|
# fails any test that still leaves one bound after `monkeypatch` is done.
|
||||||
# One layer further in again: `conventions` parses `kb/CONVENTIONS.md` once
|
# One layer further in again: `conventions` parses `kb/CONVENTIONS.md` once
|
||||||
# and keys the result on the file's own path and stat, so a repointed
|
# and keys the result on the file's own path and stat, so a repointed
|
||||||
# `KB_DIR` cannot be answered out of it. `telemetry.policy` caches the same
|
# `KB_DIR` cannot be answered out of it. `telemetry.policy` caches the same
|
||||||
@@ -200,6 +202,61 @@ def hermetic_environment(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
|||||||
telemetry_policy.reset_cache()
|
telemetry_policy.reset_cache()
|
||||||
|
|
||||||
|
|
||||||
|
def set_config_path(monkeypatch: pytest.MonkeyPatch, name: str, value) -> None:
|
||||||
|
"""Repoint one of `config`'s managed paths for the rest of this test.
|
||||||
|
|
||||||
|
The only way a test assigns `config.ROOT`, `config.KB_DIR` or any other name
|
||||||
|
in `config.MANAGED_PATHS`. `monkeypatch.setattr(config, name, value)` is
|
||||||
|
wrong for these names under every pytest version, in two different ways:
|
||||||
|
|
||||||
|
- up to 9.1 it recorded the old value by *reading* the attribute, which the
|
||||||
|
module `__getattr__` resolves, and its undo wrote that resolved path back
|
||||||
|
as a real module attribute - the name stayed bound to the previous tree
|
||||||
|
and stopped following `resolve_root()`, silently;
|
||||||
|
- from 9.2 it records the module `__dict__` entry instead and undoes an
|
||||||
|
absent one with `delattr` - which raises, because `hermetic_environment`
|
||||||
|
has already dropped the binding with `config.reset()` by the time
|
||||||
|
`monkeypatch` tears down.
|
||||||
|
|
||||||
|
Patching the module dict as a dict avoids both: `setitem` records whether
|
||||||
|
the key was there and its undo deletes a missing key without complaint, so
|
||||||
|
afterwards the name is bound exactly when it was bound before. The guard in
|
||||||
|
`pytest_runtest_teardown` below fails any test that leaves one bound.
|
||||||
|
"""
|
||||||
|
if name not in config.MANAGED_PATHS:
|
||||||
|
raise ValueError(f"{name!r} is not a managed path of chemenu.config")
|
||||||
|
monkeypatch.setitem(vars(config), name, value)
|
||||||
|
|
||||||
|
|
||||||
|
def bound_config_paths() -> list[str]:
|
||||||
|
"""The managed path names currently assigned on `config` rather than resolved."""
|
||||||
|
return [name for name in config.MANAGED_PATHS if name in vars(config)]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.hookimpl(wrapper=True)
|
||||||
|
def pytest_runtest_teardown(item, nextitem):
|
||||||
|
"""Fail a test that leaves a managed `config` path bound behind it.
|
||||||
|
|
||||||
|
A hook wrapper rather than a fixture, because it has to look *after*
|
||||||
|
`monkeypatch` has undone its patches, and `monkeypatch` is torn down after
|
||||||
|
every fixture that uses it. `hermetic_environment` drops every binding when
|
||||||
|
the next test sets up, so a test starts with none - which makes "none
|
||||||
|
after teardown" the same thing as "the same as before". A leak is reset
|
||||||
|
before the failure is raised, so it does not spread to the next test.
|
||||||
|
"""
|
||||||
|
result = yield
|
||||||
|
leaked = bound_config_paths()
|
||||||
|
if leaked:
|
||||||
|
config.reset()
|
||||||
|
raise AssertionError(
|
||||||
|
f"{item.nodeid} left chemenu.config path(s) bound after teardown: "
|
||||||
|
f"{', '.join(leaked)}. Repoint them with "
|
||||||
|
"`conftest.set_config_path(monkeypatch, name, value)`, never with "
|
||||||
|
"`monkeypatch.setattr(config, name, value)`."
|
||||||
|
)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def use_shipped_type_specs(monkeypatch: pytest.MonkeyPatch) -> None:
|
def use_shipped_type_specs(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
"""Keep the shipped `types/` reachable for a test that repoints `ROOT`.
|
"""Keep the shipped `types/` reachable for a test that repoints `ROOT`.
|
||||||
|
|
||||||
@@ -214,7 +271,7 @@ def use_shipped_type_specs(monkeypatch: pytest.MonkeyPatch) -> None:
|
|||||||
import time it held by accident, which is the same shape as the hole
|
import time it held by accident, which is the same shape as the hole
|
||||||
`raw_dir` was written to close, one layer down.
|
`raw_dir` was written to close, one layer down.
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", config._PACKAGE_ROOT / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", config._PACKAGE_ROOT / "types")
|
||||||
monkeypatch.setattr(resolver, "_repo_root", config._PACKAGE_ROOT)
|
monkeypatch.setattr(resolver, "_repo_root", config._PACKAGE_ROOT)
|
||||||
|
|
||||||
|
|
||||||
@@ -259,7 +316,7 @@ def raw_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
directories and the local one survived. Same shape as Gitea #8, closed the
|
directories and the local one survived. Same shape as Gitea #8, closed the
|
||||||
same way - in the fixture, not in the one test that happened to trip.
|
same way - in the fixture, not in the one test that happened to trip.
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
raw = tmp_path / "raw"
|
raw = tmp_path / "raw"
|
||||||
(raw / "notes").mkdir(parents=True)
|
(raw / "notes").mkdir(parents=True)
|
||||||
@@ -286,7 +343,7 @@ def kb_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
"no collection" for every fixture page, which left `unauthorised_labels`
|
"no collection" for every fixture page, which left `unauthorised_labels`
|
||||||
with no working test at all (Gitea #44).
|
with no working test at all (Gitea #44).
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
kb = tmp_path / "kb"
|
kb = tmp_path / "kb"
|
||||||
for sub in ("entities/projects", "entities/systems", "entities/tools",
|
for sub in ("entities/projects", "entities/systems", "entities/tools",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from chemenu import config
|
|||||||
from chemenu.api import Corpus
|
from chemenu.api import Corpus
|
||||||
from chemenu.errors import ChemenuError, ValidationError
|
from chemenu.errors import ChemenuError, ValidationError
|
||||||
from chemenu.types_core import UnknownType
|
from chemenu.types_core import UnknownType
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -129,7 +130,7 @@ def test_derived_paths_follow_the_root_instead_of_lagging_behind(foreign_corpus,
|
|||||||
"""The failure that made the old shape worse than the limitation: `ROOT`
|
"""The failure that made the old shape worse than the limitation: `ROOT`
|
||||||
moved and `KB_DIR` did not, so a caller believed it was working on the
|
moved and `KB_DIR` did not, so a caller believed it was working on the
|
||||||
target tree while reading this one."""
|
target tree while reading this one."""
|
||||||
monkeypatch.setattr(config, "ROOT", foreign_corpus)
|
set_config_path(monkeypatch, "ROOT", foreign_corpus)
|
||||||
assert config.KB_DIR == foreign_corpus / "kb"
|
assert config.KB_DIR == foreign_corpus / "kb"
|
||||||
assert config.RAW_DIR == foreign_corpus / "raw"
|
assert config.RAW_DIR == foreign_corpus / "raw"
|
||||||
assert config.INDEX_FILE == foreign_corpus / "kb" / "index.md"
|
assert config.INDEX_FILE == foreign_corpus / "kb" / "index.md"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from chemenu import backup, config, config_shapes, settings
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.commands import doctor
|
from chemenu.commands import doctor
|
||||||
from chemenu.commands.git_publish import publish_command
|
from chemenu.commands.git_publish import publish_command
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ def instance(tmp_path, monkeypatch):
|
|||||||
_git(root, "commit", "-m", "init")
|
_git(root, "commit", "-m", "init")
|
||||||
synced = tmp_path / "OneDrive - Example"
|
synced = tmp_path / "OneDrive - Example"
|
||||||
synced.mkdir()
|
synced.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@@ -478,7 +479,7 @@ def test_sync_folder_warns_under_cloud_storage(doctor_instance, tmp_path, monkey
|
|||||||
moved = cloud / "OneDrive-Example" / "instance"
|
moved = cloud / "OneDrive-Example" / "instance"
|
||||||
moved.parent.mkdir()
|
moved.parent.mkdir()
|
||||||
doctor_instance.rename(moved)
|
doctor_instance.rename(moved)
|
||||||
monkeypatch.setattr(config, "ROOT", moved)
|
set_config_path(monkeypatch, "ROOT", moved)
|
||||||
assert _check("sync-folder").status == "WARN"
|
assert _check("sync-folder").status == "WARN"
|
||||||
|
|
||||||
|
|
||||||
@@ -488,7 +489,7 @@ def test_sync_folder_sees_through_a_symlink(doctor_instance, tmp_path, monkeypat
|
|||||||
real = synced / "instance"
|
real = synced / "instance"
|
||||||
doctor_instance.rename(real)
|
doctor_instance.rename(real)
|
||||||
(tmp_path / "via-link").symlink_to(real)
|
(tmp_path / "via-link").symlink_to(real)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path / "via-link")
|
set_config_path(monkeypatch, "ROOT", tmp_path / "via-link")
|
||||||
monkeypatch.setenv("OneDrive", str(synced))
|
monkeypatch.setenv("OneDrive", str(synced))
|
||||||
assert _check("sync-folder").status == "WARN"
|
assert _check("sync-folder").status == "WARN"
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from chemenu.commands.cite_cmd import sync_page, upsert_citation
|
|||||||
from chemenu.frontmatter_io import read_page
|
from chemenu.frontmatter_io import read_page
|
||||||
from chemenu.kb_scan import load_kb_pages
|
from chemenu.kb_scan import load_kb_pages
|
||||||
from chemenu.provenance import cite_id
|
from chemenu.provenance import cite_id
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -46,8 +47,8 @@ def test_cite_add_command_writes_definition_and_prints_marker(kb_dir, raw_dir, m
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -63,8 +64,8 @@ def test_cite_add_rejects_unknown_source(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Nope"])
|
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Nope"])
|
||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
@@ -74,7 +75,7 @@ def test_cite_id_command_prints_deterministic_id(raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
|
|
||||||
result = runner.invoke(app, ["cite", "id", "--title", "Source - Almanac Architecture", "--file", "storage-model.md"])
|
result = runner.invoke(app, ["cite", "id", "--title", "Source - Almanac Architecture", "--file", "storage-model.md"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -187,8 +188,8 @@ def test_cite_sync_command_over_kb(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
add_result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
add_result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
||||||
assert add_result.exit_code == 0, add_result.output
|
assert add_result.exit_code == 0, add_result.output
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import typer
|
|||||||
from chemenu import collect, config, upload
|
from chemenu import collect, config, upload
|
||||||
from chemenu.errors import ValidationError
|
from chemenu.errors import ValidationError
|
||||||
from chemenu.commands.upload_cmd import upload_collect_command, upload_list_command
|
from chemenu.commands.upload_cmd import upload_collect_command, upload_list_command
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
OLD = time.time() - 3600
|
OLD = time.time() - 3600
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ def root(tmp_path, monkeypatch):
|
|||||||
instance = tmp_path / "instance"
|
instance = tmp_path / "instance"
|
||||||
instance.mkdir()
|
instance.mkdir()
|
||||||
(instance / "incoming").mkdir()
|
(instance / "incoming").mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", instance)
|
set_config_path(monkeypatch, "ROOT", instance)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from chemenu.errors import ValidationError
|
|||||||
from chemenu.tasks import caldav, superproductivity
|
from chemenu.tasks import caldav, superproductivity
|
||||||
from chemenu.tasks import config as tasks_config
|
from chemenu.tasks import config as tasks_config
|
||||||
from chemenu.telemetry import policy
|
from chemenu.telemetry import policy
|
||||||
from chemenu.tests.conftest import write_settings
|
from chemenu.tests.conftest import set_config_path, write_settings
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ CALDAV_OK = {"url": "https://dav.example/", "username": "u", "app_password": "pw
|
|||||||
def root(tmp_path, monkeypatch):
|
def root(tmp_path, monkeypatch):
|
||||||
tree = tmp_path / "instance"
|
tree = tmp_path / "instance"
|
||||||
tree.mkdir()
|
tree.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tree)
|
set_config_path(monkeypatch, "ROOT", tree)
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ def test_apply_fills_every_region_of_the_page_and_a_second_run_changes_nothing(t
|
|||||||
for name, _ in reference_doc.CONFIG_REGIONS:
|
for name, _ in reference_doc.CONFIG_REGIONS:
|
||||||
emptied = blocks.replace(emptied, name, blocks.open_marker(name) + "\n" + blocks.close_marker(name) + "\n")
|
emptied = blocks.replace(emptied, name, blocks.open_marker(name) + "\n" + blocks.close_marker(name) + "\n")
|
||||||
target.write_text(emptied, encoding="utf-8")
|
target.write_text(emptied, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
_only_config_regions(monkeypatch)
|
_only_config_regions(monkeypatch)
|
||||||
|
|
||||||
result = runner.invoke(app, ["docs", "reference", "--apply"])
|
result = runner.invoke(app, ["docs", "reference", "--apply"])
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from chemenu import blocks, config, conventions, kb_collections
|
from chemenu import blocks, config, conventions, kb_collections
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs
|
||||||
|
|
||||||
GERMAN = (
|
GERMAN = (
|
||||||
"---\n"
|
"---\n"
|
||||||
@@ -39,8 +39,8 @@ FRENCH = (
|
|||||||
def kb_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
def kb_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
||||||
kb = tmp_path / "kb"
|
kb = tmp_path / "kb"
|
||||||
kb.mkdir()
|
kb.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
# Which collections the stack requires are *derived* from where each
|
# Which collections the stack requires are *derived* from where each
|
||||||
# required type (`source`, `project`) writes, so these tests need the
|
# required type (`source`, `project`) writes, so these tests need the
|
||||||
# shipped `types/` reachable - a fixture tree without one derives an empty
|
# shipped `types/` reachable - a fixture tree without one derives an empty
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import pytest
|
|||||||
|
|
||||||
from chemenu import config, corpus_cache
|
from chemenu import config, corpus_cache
|
||||||
from chemenu.corpus_cache import CorpusCache
|
from chemenu.corpus_cache import CorpusCache
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def _git(root: Path, *args: str) -> None:
|
def _git(root: Path, *args: str) -> None:
|
||||||
@@ -28,8 +29,8 @@ def repo(kb_dir: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
_git(tmp_path, "config", "user.email", "fixture@example.com")
|
_git(tmp_path, "config", "user.email", "fixture@example.com")
|
||||||
_git(tmp_path, "add", "-A")
|
_git(tmp_path, "add", "-A")
|
||||||
_git(tmp_path, "commit", "-m", "fixture corpus")
|
_git(tmp_path, "commit", "-m", "fixture corpus")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
"""The dependency locks under tools/ (Gitea #245): what each one has to hold, and how
|
||||||
|
they hold together.
|
||||||
|
|
||||||
|
The locks are written by tools/lock_requirements.py and installed with
|
||||||
|
`pip install --require-hashes`; instructions/dev/dependency-locks.md is the procedure.
|
||||||
|
These tests read the committed files only - nothing here resolves or downloads.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
from datetime import datetime, timedelta, timezone
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from packaging.requirements import Requirement
|
||||||
|
from packaging.utils import canonicalize_name
|
||||||
|
from packaging.version import Version
|
||||||
|
|
||||||
|
from chemenu import config
|
||||||
|
|
||||||
|
TOOLS = config._PACKAGE_ROOT / "tools"
|
||||||
|
WORKFLOWS = config._PACKAGE_ROOT / ".gitea" / "workflows"
|
||||||
|
|
||||||
|
|
||||||
|
def _load_script():
|
||||||
|
spec = importlib.util.spec_from_file_location("lock_requirements", TOOLS / "lock_requirements.py")
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
SCRIPT = _load_script()
|
||||||
|
CHAIN = [(TOOLS / source, TOOLS / lock) for source, lock in SCRIPT.CHAIN]
|
||||||
|
|
||||||
|
PIN_RE = re.compile(r"^([A-Za-z0-9][A-Za-z0-9._-]*)==([^\s;\\]+)")
|
||||||
|
|
||||||
|
|
||||||
|
def entries(lock: Path) -> dict[str, tuple[str, list[str]]]:
|
||||||
|
"""name -> (version, hashes) for every package the lock pins."""
|
||||||
|
found: dict[str, tuple[str, list[str]]] = {}
|
||||||
|
current = None
|
||||||
|
for line in lock.read_text(encoding="utf-8").splitlines():
|
||||||
|
if line.startswith("#") or not line.strip():
|
||||||
|
continue
|
||||||
|
pin = PIN_RE.match(line)
|
||||||
|
if pin:
|
||||||
|
current = canonicalize_name(pin.group(1))
|
||||||
|
assert current not in found, f"{lock.name} pins {current} twice"
|
||||||
|
found[current] = (pin.group(2), [])
|
||||||
|
elif not line.startswith(" "):
|
||||||
|
pytest.fail(f"{lock.name}: a line that pins nothing exactly: {line!r}")
|
||||||
|
if current:
|
||||||
|
found[current][1].extend(re.findall(r"--hash=sha256:([0-9a-f]{64})", line))
|
||||||
|
return found
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("source, lock", CHAIN, ids=[lock.name for _, lock in CHAIN])
|
||||||
|
def test_every_package_is_pinned_exactly_with_a_sha256(source, lock):
|
||||||
|
pinned = entries(lock)
|
||||||
|
assert pinned, f"{lock.name} pins nothing"
|
||||||
|
for name, (version, hashes) in pinned.items():
|
||||||
|
assert hashes, f"{lock.name}: {name}=={version} carries no sha256"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("source, lock", CHAIN, ids=[lock.name for _, lock in CHAIN])
|
||||||
|
def test_every_requirement_of_the_source_is_in_its_lock_at_or_above_its_floor(source, lock):
|
||||||
|
"""The floor in the source file is what keeps a later lift from lowering a package -
|
||||||
|
the invariant of a security lift (#245, point 3): `>=X` stays, so the lock never falls
|
||||||
|
below X again."""
|
||||||
|
pinned = entries(lock)
|
||||||
|
for line in source.read_text(encoding="utf-8").splitlines():
|
||||||
|
line = line.split("#", 1)[0].strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
requirement = Requirement(line)
|
||||||
|
name = canonicalize_name(requirement.name)
|
||||||
|
assert name in pinned, f"{source.name} asks for {name}, {lock.name} does not pin it"
|
||||||
|
assert requirement.specifier.contains(Version(pinned[name][0]), prereleases=True), (
|
||||||
|
f"{lock.name} pins {name}=={pinned[name][0]}, outside {source.name}'s {requirement.specifier}")
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_package_in_two_locks_has_the_same_version_in_both():
|
||||||
|
"""All of them land in one venv; a later `pip install -r` of one lock must not move a
|
||||||
|
package another placed (#245, point 8)."""
|
||||||
|
seen: dict[str, tuple[str, str]] = {}
|
||||||
|
for _, lock in CHAIN:
|
||||||
|
for name, (version, _) in entries(lock).items():
|
||||||
|
if name in seen:
|
||||||
|
assert seen[name][0] == version, (
|
||||||
|
f"{name}: {seen[name][1]} pins {seen[name][0]}, {lock.name} pins {version}")
|
||||||
|
else:
|
||||||
|
seen[name] = (version, lock.name)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("source, lock", CHAIN, ids=[lock.name for _, lock in CHAIN])
|
||||||
|
def test_each_lock_is_constrained_by_every_lock_before_it(source, lock):
|
||||||
|
command = SCRIPT.header(lock)
|
||||||
|
position = [lock for _, lock in CHAIN].index(lock)
|
||||||
|
for _, earlier in CHAIN[:position]:
|
||||||
|
assert f"-c tools/{earlier.name}" in command, f"{lock.name} was not resolved against {earlier.name}"
|
||||||
|
assert "--universal" in command and "--generate-hashes" in command
|
||||||
|
|
||||||
|
|
||||||
|
def _written_at(lock: Path) -> datetime:
|
||||||
|
"""When the lock was written, as far as git can say: its last commit, or now while
|
||||||
|
it differs from HEAD (it has just been regenerated)."""
|
||||||
|
root = config._PACKAGE_ROOT
|
||||||
|
try:
|
||||||
|
dirty = subprocess.run(["git", "status", "--porcelain", "--", str(lock)], cwd=root,
|
||||||
|
capture_output=True, text=True, timeout=10)
|
||||||
|
stamp = subprocess.run(["git", "log", "-1", "--format=%cI", "--", str(lock)], cwd=root,
|
||||||
|
capture_output=True, text=True, timeout=10)
|
||||||
|
except (OSError, subprocess.SubprocessError):
|
||||||
|
return datetime.now(timezone.utc)
|
||||||
|
if dirty.returncode != 0 or dirty.stdout.strip() or not stamp.stdout.strip():
|
||||||
|
return datetime.now(timezone.utc)
|
||||||
|
return datetime.fromisoformat(stamp.stdout.strip()).astimezone(timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("source, lock", CHAIN, ids=[lock.name for _, lock in CHAIN])
|
||||||
|
def test_no_package_was_younger_than_the_cooldown_when_the_lock_was_written(source, lock):
|
||||||
|
"""`--exclude-newer` in the lock's head is the cutoff uv honoured; it has to lie at least
|
||||||
|
COOLDOWN_DAYS before the lock was written. A security lift is the one way past it, and
|
||||||
|
it shows as `--exclude-newer-package` beside the cutoff (#245, points 2 and 3)."""
|
||||||
|
cutoff = SCRIPT.cutoff_of(lock)
|
||||||
|
assert cutoff is not None, f"{lock.name} was written without --exclude-newer"
|
||||||
|
assert cutoff <= _written_at(lock) - timedelta(days=SCRIPT.COOLDOWN_DAYS), (
|
||||||
|
f"{lock.name}: cutoff {cutoff:%Y-%m-%d %H:%M} is less than {SCRIPT.COOLDOWN_DAYS} days "
|
||||||
|
"before the lock was written - regenerate it with tools/lock_requirements.py")
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_locks_resolve_for_the_python_minimum_of_the_manifest():
|
||||||
|
for _, lock in CHAIN:
|
||||||
|
assert f"--python-version {SCRIPT.python_minimum()}" in SCRIPT.header(lock)
|
||||||
|
|
||||||
|
|
||||||
|
def test_an_exception_is_carried_while_young_and_dropped_once_the_cutoff_passes_it(tmp_path, monkeypatch):
|
||||||
|
lock = tmp_path / "requirements.lock"
|
||||||
|
lock.write_text(
|
||||||
|
"# This file was autogenerated by uv via the following command:\n"
|
||||||
|
"# uv pip compile tools/requirements.txt --exclude-newer 2026-11-01T00:00:00Z "
|
||||||
|
"--exclude-newer-package young=2026-11-16T10:00:00Z "
|
||||||
|
"--exclude-newer-package old=2026-10-20T10:00:00Z -o tools/requirements.lock\n"
|
||||||
|
"pyyaml==6.0.3 \\\n --hash=sha256:" + "0" * 64 + "\n",
|
||||||
|
encoding="utf-8")
|
||||||
|
monkeypatch.setattr(SCRIPT, "CHAIN", (("requirements.txt", "requirements.lock"),))
|
||||||
|
monkeypatch.setattr(SCRIPT, "TOOLS", tmp_path)
|
||||||
|
cutoff = datetime(2026, 11, 11, tzinfo=timezone.utc)
|
||||||
|
assert SCRIPT.carried_exceptions(cutoff) == {"young": datetime(2026, 11, 16, 10, tzinfo=timezone.utc)}
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_workflow_installs_a_package_or_requirements_file_without_a_lock():
|
||||||
|
"""#245: every `pip install` in CI goes through a lock with --require-hashes."""
|
||||||
|
offenders = []
|
||||||
|
for workflow in sorted(WORKFLOWS.glob("*.yml")):
|
||||||
|
for number, line in enumerate(workflow.read_text(encoding="utf-8").splitlines(), 1):
|
||||||
|
if "pip install" not in line or line.lstrip().startswith("#"):
|
||||||
|
continue
|
||||||
|
if "--require-hashes" not in line or not re.search(r"-r \S+\.lock\b", line):
|
||||||
|
offenders.append(f"{workflow.name}:{number}: {line.strip()}")
|
||||||
|
assert offenders == []
|
||||||
@@ -14,6 +14,7 @@ import typer
|
|||||||
|
|
||||||
from chemenu import config, toc, version as version_mod
|
from chemenu import config, toc, version as version_mod
|
||||||
from chemenu.commands import dist_cmd
|
from chemenu.commands import dist_cmd
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -162,10 +163,10 @@ def repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
(root / "raw" / "notes").mkdir(parents=True, exist_ok=True)
|
(root / "raw" / "notes").mkdir(parents=True, exist_ok=True)
|
||||||
(root / "raw" / "notes" / "personal-note.md").write_text("private\n", encoding="utf-8")
|
(root / "raw" / "notes" / "personal-note.md").write_text("private\n", encoding="utf-8")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
@@ -348,6 +349,26 @@ def test_plan_excludes_the_test_suite_and_its_configuration_by_exact_path(repo):
|
|||||||
assert "tools/chemenu/tests.py" in plan
|
assert "tools/chemenu/tests.py" in plan
|
||||||
|
|
||||||
|
|
||||||
|
def test_plan_ships_the_runtime_locks_but_not_the_dev_ones_nor_the_script_that_writes_them(repo):
|
||||||
|
"""#245: an instance installs from requirements.lock (and the MCP and browser locks,
|
||||||
|
when it wants those parts) - so they ship. The test tools' source and lock and
|
||||||
|
lock_requirements.py serve only the origin repository and stay behind."""
|
||||||
|
tools_dir = repo / "tools"
|
||||||
|
names = ("requirements", "requirements-mcp", "requirements-browser", "requirements-dev")
|
||||||
|
for name in names:
|
||||||
|
(tools_dir / f"{name}.txt").write_text("x>=1\n", encoding="utf-8")
|
||||||
|
(tools_dir / f"{name}.lock").write_text("x==1 --hash=sha256:00\n", encoding="utf-8")
|
||||||
|
(tools_dir / "lock_requirements.py").write_text("", encoding="utf-8")
|
||||||
|
|
||||||
|
plan = dist_cmd.build_plan()
|
||||||
|
|
||||||
|
for name in names[:3]:
|
||||||
|
assert f"tools/{name}.txt" in plan and f"tools/{name}.lock" in plan
|
||||||
|
assert "tools/requirements-dev.txt" not in plan
|
||||||
|
assert "tools/requirements-dev.lock" not in plan
|
||||||
|
assert "tools/lock_requirements.py" not in plan
|
||||||
|
|
||||||
|
|
||||||
def test_plan_ships_the_environment_template_but_not_the_filled_file(repo):
|
def test_plan_ships_the_environment_template_but_not_the_filled_file(repo):
|
||||||
"""Same split as the personalization pair, for the same reason: a
|
"""Same split as the personalization pair, for the same reason: a
|
||||||
distribution can say what the file is for, never what one checkout's
|
distribution can say what the file is for, never what one checkout's
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import typer
|
|||||||
|
|
||||||
from chemenu import config, kb_state, version as version_mod
|
from chemenu import config, kb_state, version as version_mod
|
||||||
from chemenu.commands import dist_cmd
|
from chemenu.commands import dist_cmd
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def _digest(text: str) -> str:
|
def _digest(text: str) -> str:
|
||||||
@@ -73,7 +74,7 @@ def instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
for the dirty-tree check)."""
|
for the dirty-tree check)."""
|
||||||
root = tmp_path / "instance"
|
root = tmp_path / "instance"
|
||||||
root.mkdir()
|
root.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
|
|
||||||
(root / "VERSION").write_text("1.0.0\n", encoding="utf-8")
|
(root / "VERSION").write_text("1.0.0\n", encoding="utf-8")
|
||||||
(root / "AGENTS.md").write_text("core\n", encoding="utf-8")
|
(root / "AGENTS.md").write_text("core\n", encoding="utf-8")
|
||||||
@@ -900,7 +901,7 @@ def test_latest_yields_the_same_tree_as_the_archive_it_downloaded(instance, tmp_
|
|||||||
dist_cmd.run_upgrade(latest=True)
|
dist_cmd.run_upgrade(latest=True)
|
||||||
via_feed = {p.relative_to(instance): p.read_bytes() for p in instance.rglob("*") if p.is_file()}
|
via_feed = {p.relative_to(instance): p.read_bytes() for p in instance.rglob("*") if p.is_file()}
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", snapshot)
|
set_config_path(monkeypatch, "ROOT", snapshot)
|
||||||
dist_cmd.run_upgrade(served)
|
dist_cmd.run_upgrade(served)
|
||||||
via_archive = {p.relative_to(snapshot): p.read_bytes() for p in snapshot.rglob("*") if p.is_file()}
|
via_archive = {p.relative_to(snapshot): p.read_bytes() for p in snapshot.rglob("*") if p.is_file()}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import typer
|
|||||||
from chemenu import cli_contract, config, type_resolver
|
from chemenu import cli_contract, config, type_resolver
|
||||||
from chemenu.commands import dist_cmd, docs_verify
|
from chemenu.commands import dist_cmd, docs_verify
|
||||||
from chemenu.type_resolver import TypeResolver
|
from chemenu.type_resolver import TypeResolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def test_every_registered_command_has_a_contract_record():
|
def test_every_registered_command_has_a_contract_record():
|
||||||
@@ -57,6 +58,20 @@ def _fixture_record(path: str) -> cli_contract.CommandRecord:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _built_command(callback):
|
||||||
|
"""`callback` as the command object the real check walks.
|
||||||
|
|
||||||
|
Built the way `docs_verify._leaf_click_commands()` builds the real tree -
|
||||||
|
a Typer app through `typer.main.get_command` - rather than from `click`
|
||||||
|
classes directly: typer no longer depends on the `click` package (it ships
|
||||||
|
its own fork as `typer._click`), and its option classes change their
|
||||||
|
constructor between minor versions, so only this public path stays put.
|
||||||
|
"""
|
||||||
|
app = typer.Typer(add_completion=False)
|
||||||
|
app.command(name="frobnicate")(callback)
|
||||||
|
return typer.main.get_command(app)
|
||||||
|
|
||||||
|
|
||||||
def test_commands_region_matches_the_generated_form(tmp_path, monkeypatch):
|
def test_commands_region_matches_the_generated_form(tmp_path, monkeypatch):
|
||||||
"""Regression guard for the drift this check exists to catch: a region
|
"""Regression guard for the drift this check exists to catch: a region
|
||||||
hand-edited (or simply left stale after a record changed) must fail, the
|
hand-edited (or simply left stale after a record changed) must fail, the
|
||||||
@@ -127,14 +142,16 @@ def test_every_registered_commands_flags_are_documented():
|
|||||||
|
|
||||||
|
|
||||||
def test_a_flag_the_synopsis_forgot_is_reported(monkeypatch):
|
def test_a_flag_the_synopsis_forgot_is_reported(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
rec = _fixture_record("frobnicate")
|
rec = _fixture_record("frobnicate")
|
||||||
monkeypatch.setattr(cli_contract, "get", lambda path: rec if path == "frobnicate" else None)
|
monkeypatch.setattr(cli_contract, "get", lambda path: rec if path == "frobnicate" else None)
|
||||||
|
|
||||||
param = click.Option(["--flag"])
|
def frobnicate(
|
||||||
param2 = click.Option(["--forgotten"])
|
flag: str = typer.Option(None, "--flag"),
|
||||||
command = click.Command("frobnicate", params=[param, param2])
|
forgotten: str = typer.Option(None, "--forgotten"),
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -143,8 +160,6 @@ def test_a_flag_the_synopsis_forgot_is_reported(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
rec = cli_contract.CommandRecord(
|
rec = cli_contract.CommandRecord(
|
||||||
path="frobnicate",
|
path="frobnicate",
|
||||||
summary="Does a thing.",
|
summary="Does a thing.",
|
||||||
@@ -153,8 +168,10 @@ def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
|||||||
notes=("Does a thing.",),
|
notes=("Does a thing.",),
|
||||||
failures=(),
|
failures=(),
|
||||||
)
|
)
|
||||||
param = click.Option(["--flag"])
|
def frobnicate(flag: str = typer.Option(None, "--flag")):
|
||||||
command = click.Command("frobnicate", params=[param])
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -164,12 +181,15 @@ def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_hidden_flag_need_not_be_documented(monkeypatch):
|
def test_a_hidden_flag_need_not_be_documented(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
rec = _fixture_record("frobnicate")
|
rec = _fixture_record("frobnicate")
|
||||||
param = click.Option(["--flag"])
|
|
||||||
hidden = click.Option(["--secret"], hidden=True)
|
def frobnicate(
|
||||||
command = click.Command("frobnicate", params=[param, hidden])
|
flag: str = typer.Option(None, "--flag"),
|
||||||
|
secret: str = typer.Option(None, "--secret", hidden=True),
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -181,8 +201,6 @@ def test_a_boolean_flag_pair_is_satisfied_by_either_spelling(monkeypatch):
|
|||||||
"""`--push`/`--no-push`: documenting only the negative spelling (the
|
"""`--push`/`--no-push`: documenting only the negative spelling (the
|
||||||
existing SYNOPSIS convention `publish` used before this check existed)
|
existing SYNOPSIS convention `publish` used before this check existed)
|
||||||
must not be reported as an undocumented `--push`."""
|
must not be reported as an undocumented `--push`."""
|
||||||
import click
|
|
||||||
|
|
||||||
rec = cli_contract.CommandRecord(
|
rec = cli_contract.CommandRecord(
|
||||||
path="frobnicate",
|
path="frobnicate",
|
||||||
summary="Does a thing.",
|
summary="Does a thing.",
|
||||||
@@ -191,8 +209,10 @@ def test_a_boolean_flag_pair_is_satisfied_by_either_spelling(monkeypatch):
|
|||||||
notes=("Does a thing.",),
|
notes=("Does a thing.",),
|
||||||
failures=(),
|
failures=(),
|
||||||
)
|
)
|
||||||
param = click.Option(["--push/--no-push"], default=True)
|
def frobnicate(push: bool = typer.Option(True, "--push/--no-push")):
|
||||||
command = click.Command("frobnicate", params=[param])
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -208,31 +228,31 @@ def test_no_registered_commands_help_cites_an_issue_number():
|
|||||||
|
|
||||||
|
|
||||||
def test_an_issue_number_above_the_form_feed_is_reported(monkeypatch):
|
def test_an_issue_number_above_the_form_feed_is_reported(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
def frobnicate():
|
def frobnicate():
|
||||||
"""One sentence (Gitea #66)."""
|
"""One sentence (Gitea #66)."""
|
||||||
|
|
||||||
command = click.Command("frobnicate", callback=frobnicate, help=frobnicate.__doc__)
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
||||||
issues = docs_verify.check_no_issue_references_in_help()
|
issues = docs_verify.check_no_issue_references_in_help()
|
||||||
assert any("#66" in issue and "frobnicate" in issue for issue in issues)
|
assert any("#66" in issue and "frobnicate" in issue for issue in issues)
|
||||||
|
|
||||||
|
|
||||||
def test_an_issue_number_below_the_form_feed_is_not_reported(monkeypatch):
|
def test_an_issue_number_below_the_form_feed_is_not_reported(monkeypatch):
|
||||||
import click
|
def frobnicate():
|
||||||
|
"""One sentence.
|
||||||
|
\f
|
||||||
|
Maintenance text citing Gitea #66, never rendered."""
|
||||||
|
|
||||||
help_text = "One sentence.\n\f\nMaintenance text citing Gitea #66, never rendered."
|
command = _built_command(frobnicate)
|
||||||
command = click.Command("frobnicate", help=help_text)
|
|
||||||
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
||||||
assert docs_verify.check_no_issue_references_in_help() == []
|
assert docs_verify.check_no_issue_references_in_help() == []
|
||||||
|
|
||||||
|
|
||||||
def test_an_issue_number_in_an_options_help_text_is_reported(monkeypatch):
|
def test_an_issue_number_in_an_options_help_text_is_reported(monkeypatch):
|
||||||
import click
|
def frobnicate(flag: str = typer.Option(None, "--flag", help="Do the thing (Gitea #66).")):
|
||||||
|
pass
|
||||||
|
|
||||||
param = click.Option(["--flag"], help="Do the thing (Gitea #66).")
|
command = _built_command(frobnicate)
|
||||||
command = click.Command("frobnicate", params=[param])
|
|
||||||
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
||||||
issues = docs_verify.check_no_issue_references_in_help()
|
issues = docs_verify.check_no_issue_references_in_help()
|
||||||
assert any("#66" in issue and "--flag" in issue for issue in issues)
|
assert any("#66" in issue and "--flag" in issue for issue in issues)
|
||||||
@@ -271,7 +291,7 @@ def test_stage_readmes_are_checked_too(tmp_path, monkeypatch):
|
|||||||
(root / "tools" / "README.md").write_text(
|
(root / "tools" / "README.md").write_text(
|
||||||
"| Command | Purpose |\n| `publish` | pushes |\n", encoding="utf-8"
|
"| Command | Purpose |\n| `publish` | pushes |\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
||||||
issues = docs_verify.check_readmes_have_no_command_table()
|
issues = docs_verify.check_readmes_have_no_command_table()
|
||||||
assert any("`publish`" in issue for issue in issues)
|
assert any("`publish`" in issue for issue in issues)
|
||||||
@@ -284,7 +304,7 @@ def test_install_md_is_checked_too(tmp_path, monkeypatch):
|
|||||||
(root / "INSTALL.md").write_text(
|
(root / "INSTALL.md").write_text(
|
||||||
"| Command | Purpose |\n| `doctor` | checks things |\n", encoding="utf-8"
|
"| Command | Purpose |\n| `doctor` | checks things |\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
||||||
issues = docs_verify.check_readmes_have_no_command_table()
|
issues = docs_verify.check_readmes_have_no_command_table()
|
||||||
assert any("`doctor`" in issue for issue in issues)
|
assert any("`doctor`" in issue for issue in issues)
|
||||||
@@ -299,7 +319,7 @@ def test_the_developer_guide_is_checked_too(tmp_path, monkeypatch):
|
|||||||
(root / "docs" / "dev" / "development.md").write_text(
|
(root / "docs" / "dev" / "development.md").write_text(
|
||||||
"| Command | Purpose |\n| `docs verify` | checks docs |\n", encoding="utf-8"
|
"| Command | Purpose |\n| `docs verify` | checks docs |\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
||||||
issues = docs_verify.check_readmes_have_no_command_table()
|
issues = docs_verify.check_readmes_have_no_command_table()
|
||||||
assert any("`docs verify`" in issue for issue in issues)
|
assert any("`docs verify`" in issue for issue in issues)
|
||||||
@@ -310,7 +330,7 @@ def test_an_absent_listed_doc_is_skipped_not_reported(tmp_path, monkeypatch):
|
|||||||
it must stay inert where the file does not exist rather than failing a tree
|
it must stay inert where the file does not exist rather than failing a tree
|
||||||
that is correct."""
|
that is correct."""
|
||||||
root = tmp_path
|
root = tmp_path
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
||||||
assert docs_verify.check_readmes_have_no_command_table() == []
|
assert docs_verify.check_readmes_have_no_command_table() == []
|
||||||
|
|
||||||
@@ -352,8 +372,8 @@ def test_an_unknown_type_spec_field_is_reported(tmp_path, monkeypatch):
|
|||||||
"---\n",
|
"---\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
||||||
|
|
||||||
issues = docs_verify.check_type_spec_frontmatter()
|
issues = docs_verify.check_type_spec_frontmatter()
|
||||||
@@ -378,8 +398,8 @@ def _stack_required_type_tree(tmp_path, monkeypatch, project_md: str = "", proje
|
|||||||
(types_dir / "project.md").write_text(project_md, encoding="utf-8")
|
(types_dir / "project.md").write_text(project_md, encoding="utf-8")
|
||||||
if project_schema:
|
if project_schema:
|
||||||
(types_dir / "project.schema.yaml").write_text(project_schema, encoding="utf-8")
|
(types_dir / "project.schema.yaml").write_text(project_schema, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
||||||
|
|
||||||
|
|
||||||
@@ -495,7 +515,7 @@ def test_this_repos_version_and_changelog_agree():
|
|||||||
def _versioned_tree(tmp_path, monkeypatch, version: str, changes: str):
|
def _versioned_tree(tmp_path, monkeypatch, version: str, changes: str):
|
||||||
(tmp_path / "VERSION").write_text(version, encoding="utf-8")
|
(tmp_path / "VERSION").write_text(version, encoding="utf-8")
|
||||||
(tmp_path / "CHANGES.md").write_text(changes, encoding="utf-8")
|
(tmp_path / "CHANGES.md").write_text(changes, encoding="utf-8")
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
|
|
||||||
|
|
||||||
def test_a_bump_with_no_changelog_entry_is_reported(tmp_path, monkeypatch):
|
def test_a_bump_with_no_changelog_entry_is_reported(tmp_path, monkeypatch):
|
||||||
@@ -518,7 +538,7 @@ def test_a_changelog_with_no_versioned_entry_is_accepted(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_missing_or_malformed_version_is_reported(tmp_path, monkeypatch):
|
def test_a_missing_or_malformed_version_is_reported(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert any("VERSION" in issue for issue in docs_verify.check_version_changelog())
|
assert any("VERSION" in issue for issue in docs_verify.check_version_changelog())
|
||||||
_versioned_tree(tmp_path, monkeypatch, "not-a-version\n", "# Changelog\n")
|
_versioned_tree(tmp_path, monkeypatch, "not-a-version\n", "# Changelog\n")
|
||||||
assert any("semantic version" in issue for issue in docs_verify.check_version_changelog())
|
assert any("semantic version" in issue for issue in docs_verify.check_version_changelog())
|
||||||
@@ -544,8 +564,8 @@ def _boundary_tree(tmp_path, monkeypatch, current: str, previous: str, marker: s
|
|||||||
)
|
)
|
||||||
instructions = tmp_path / "instructions"
|
instructions = tmp_path / "instructions"
|
||||||
(instructions / "migrations").mkdir(parents=True, exist_ok=True)
|
(instructions / "migrations").mkdir(parents=True, exist_ok=True)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(docs_verify.config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
@@ -801,7 +821,7 @@ def test_a_shipped_template_over_the_threshold_without_a_region_is_reported(tmp_
|
|||||||
returned nothing here."""
|
returned nothing here."""
|
||||||
from chemenu import config, toc as toc_mod
|
from chemenu import config, toc as toc_mod
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "kb").mkdir()
|
(tmp_path / "kb").mkdir()
|
||||||
long_body = "# Conventions\n\nIntro.\n" + "".join(
|
long_body = "# Conventions\n\nIntro.\n" + "".join(
|
||||||
f"\n## Section {i}\n\n" + "Body line.\n" * 12 for i in range(8)
|
f"\n## Section {i}\n\n" + "Body line.\n" * 12 for i in range(8)
|
||||||
@@ -917,7 +937,7 @@ def test_this_repos_docs_are_laid_out_in_areas():
|
|||||||
def _docs_tree(tmp_path, monkeypatch, files: tuple[str, ...]):
|
def _docs_tree(tmp_path, monkeypatch, files: tuple[str, ...]):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
for relative in files:
|
for relative in files:
|
||||||
path = tmp_path / relative
|
path = tmp_path / relative
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -962,7 +982,7 @@ def test_verify_raises_when_a_docs_file_is_outside_every_area(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def _agents_with_gates(tmp_path, monkeypatch, names: list[str], section: str = "## Gates") -> None:
|
def _agents_with_gates(tmp_path, monkeypatch, names: list[str], section: str = "## Gates") -> None:
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
entries = "".join(f"- **{name}.** Does something.\n" for name in names)
|
entries = "".join(f"- **{name}.** Does something.\n" for name in names)
|
||||||
(tmp_path / "AGENTS.md").write_text(
|
(tmp_path / "AGENTS.md").write_text(
|
||||||
f"# AGENTS\n\n{section}\n\nThese are enforced in code.\n\n{entries}\n"
|
f"# AGENTS\n\n{section}\n\nThese are enforced in code.\n\n{entries}\n"
|
||||||
@@ -1011,7 +1031,7 @@ def test_a_tree_with_no_gates_section_is_reported(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_tree_with_no_agents_md_is_reported(tmp_path, monkeypatch):
|
def test_a_tree_with_no_agents_md_is_reported(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
issues = docs_verify.check_gates_list()
|
issues = docs_verify.check_gates_list()
|
||||||
assert len(issues) == 1 and "AGENTS.md is missing" in issues[0]
|
assert len(issues) == 1 and "AGENTS.md is missing" in issues[0]
|
||||||
|
|
||||||
@@ -1074,7 +1094,7 @@ def test_the_9_0_0_upgrade_breaks_an_old_conventions_link_until_the_migration_ra
|
|||||||
document = (
|
document = (
|
||||||
config.ROOT / "instructions" / "migrations" / "9.0.0-docs-diataxis.md"
|
config.ROOT / "instructions" / "migrations" / "9.0.0-docs-diataxis.md"
|
||||||
).read_text(encoding="utf-8")
|
).read_text(encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "kb").mkdir()
|
(tmp_path / "kb").mkdir()
|
||||||
conventions = tmp_path / "kb" / "CONVENTIONS.md"
|
conventions = tmp_path / "kb" / "CONVENTIONS.md"
|
||||||
conventions.write_text(
|
conventions.write_text(
|
||||||
@@ -1250,8 +1270,8 @@ def _subtype_tree(tmp_path, monkeypatch, files: dict):
|
|||||||
shutil.copytree(config.ROOT / "types", types_dir)
|
shutil.copytree(config.ROOT / "types", types_dir)
|
||||||
for name, text in files.items():
|
for name, text in files.items():
|
||||||
(types_dir / name).write_text(text, encoding="utf-8")
|
(types_dir / name).write_text(text, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
||||||
return docs_verify.check_subtype_templates()
|
return docs_verify.check_subtype_templates()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import pytest
|
|||||||
|
|
||||||
from chemenu import config, conventions, prerequisites, toolpaths
|
from chemenu import config, conventions, prerequisites, toolpaths
|
||||||
from chemenu.commands import doctor, instructions_cmd
|
from chemenu.commands import doctor, instructions_cmd
|
||||||
from chemenu.tests.conftest import write_settings
|
from chemenu.tests.conftest import set_config_path, write_settings
|
||||||
|
|
||||||
|
|
||||||
def _git(root: Path, *args: str) -> None:
|
def _git(root: Path, *args: str) -> None:
|
||||||
@@ -72,14 +72,14 @@ def instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
"---\nname: wiki-demo\ndescription: Demo skill.\n---\n", encoding="utf-8"
|
"---\nname: wiki-demo\ndescription: Demo skill.\n---\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
monkeypatch.setattr(config, "INDEX_FILE", kb / "index.md")
|
set_config_path(monkeypatch, "INDEX_FILE", kb / "index.md")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", kb / "log.md")
|
set_config_path(monkeypatch, "LOG_FILE", kb / "log.md")
|
||||||
monkeypatch.setattr(config, "PROVENANCE_FILE", kb / "provenance.md")
|
set_config_path(monkeypatch, "PROVENANCE_FILE", kb / "provenance.md")
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setattr(config, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
set_config_path(monkeypatch, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
||||||
monkeypatch.setattr(config, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
set_config_path(monkeypatch, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
||||||
monkeypatch.delenv("WIKITOOL_SESSION_ID", raising=False)
|
monkeypatch.delenv("WIKITOOL_SESSION_ID", raising=False)
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ def test_no_author_fails(instance, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_not_a_git_repo_fails(tmp_path, monkeypatch):
|
def test_not_a_git_repo_fails(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
checks = doctor.run_doctor()
|
checks = doctor.run_doctor()
|
||||||
assert _status(checks, "git-repo") == "FAIL"
|
assert _status(checks, "git-repo") == "FAIL"
|
||||||
|
|
||||||
@@ -813,3 +813,40 @@ def test_an_installed_browser_component_is_ok(instance, monkeypatch):
|
|||||||
|
|
||||||
monkeypatch.setattr(browser, "missing", lambda: None)
|
monkeypatch.setattr(browser, "missing", lambda: None)
|
||||||
assert _status(doctor.run_doctor(), "browser") == "OK"
|
assert _status(doctor.run_doctor(), "browser") == "OK"
|
||||||
|
|
||||||
|
|
||||||
|
# --- the Python span (Gitea #245) -------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def _python_check(monkeypatch, major: int, minor: int) -> doctor.Check:
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
fake = SimpleNamespace(version_info=SimpleNamespace(major=major, minor=minor, micro=4))
|
||||||
|
monkeypatch.setattr(doctor, "sys", fake)
|
||||||
|
return doctor.check_python()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("minor, status", [(12, "FAIL"), (13, "OK"), (14, "OK"), (15, "FAIL")])
|
||||||
|
def test_python_is_judged_against_the_span_of_the_manifest(monkeypatch, minor, status):
|
||||||
|
check = _python_check(monkeypatch, 3, minor)
|
||||||
|
assert check.status == status
|
||||||
|
if status == "FAIL":
|
||||||
|
assert f"Python 3.{minor}" in check.detail and "3.13 to 3.14" in check.detail
|
||||||
|
assert "Install Python 3.13 to 3.14" in check.fix and "preflight" in check.fix
|
||||||
|
|
||||||
|
|
||||||
|
def test_python_follows_the_manifest_rather_than_a_literal(monkeypatch, tmp_path):
|
||||||
|
manifest = tmp_path / "prerequisites.txt"
|
||||||
|
manifest.write_text("tool|python|3.10|3.11|all|Python|why|-|-|-|-|-\n", encoding="utf-8")
|
||||||
|
monkeypatch.setattr(prerequisites, "manifest_path", lambda: manifest)
|
||||||
|
assert _python_check(monkeypatch, 3, 11).status == "OK"
|
||||||
|
assert _python_check(monkeypatch, 3, 13).status == "FAIL"
|
||||||
|
|
||||||
|
|
||||||
|
def test_doctor_carries_no_python_version_literal():
|
||||||
|
"""The span lives in tools/prerequisites.txt alone; doctor once had 3.11 typed in."""
|
||||||
|
import re
|
||||||
|
|
||||||
|
source = Path(doctor.__file__).read_text(encoding="utf-8")
|
||||||
|
body = source.split("def check_python", 1)[1].split("\ndef ", 1)[0]
|
||||||
|
assert not re.search(r"\b3\.\d+\b|\(3,\s*\d+\)", body)
|
||||||
@@ -30,6 +30,7 @@ from chemenu.search.registry import resolve
|
|||||||
from chemenu.search.service import load_pages_by_path, run_search
|
from chemenu.search.service import load_pages_by_path, run_search
|
||||||
from chemenu.search.types import SearchQuery
|
from chemenu.search.types import SearchQuery
|
||||||
from chemenu.type_resolver import resolver
|
from chemenu.type_resolver import resolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ def _commit_instance(root: Path, message: str = "instance change") -> None:
|
|||||||
def instance(kb_dir, monkeypatch):
|
def instance(kb_dir, monkeypatch):
|
||||||
root = kb_dir.parent
|
root = kb_dir.parent
|
||||||
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", root / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", root / "types")
|
||||||
monkeypatch.setattr(resolver, "_repo_root", root)
|
monkeypatch.setattr(resolver, "_repo_root", root)
|
||||||
monkeypatch.setattr(repo_capture, "ALLOWED_SCHEMES", ("ssh", "https", "file"))
|
monkeypatch.setattr(repo_capture, "ALLOWED_SCHEMES", ("ssh", "https", "file"))
|
||||||
(root / "raw").mkdir(exist_ok=True)
|
(root / "raw").mkdir(exist_ok=True)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ from chemenu.commands.git_publish import publish_command
|
|||||||
from chemenu.frontmatter_io import write_page
|
from chemenu.frontmatter_io import write_page
|
||||||
from chemenu.search.service import load_pages_by_path
|
from chemenu.search.service import load_pages_by_path
|
||||||
from chemenu.type_resolver import resolver
|
from chemenu.type_resolver import resolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -92,14 +93,14 @@ def instance(tmp_path, monkeypatch):
|
|||||||
"/incoming/*\n!/incoming/.gitkeep\n/.wikitool-local.json\n/quarantine/\n/reports/\n",
|
"/incoming/*\n!/incoming/.gitkeep\n/.wikitool-local.json\n/quarantine/\n/reports/\n",
|
||||||
encoding="utf-8")
|
encoding="utf-8")
|
||||||
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", root / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", root / "types")
|
||||||
monkeypatch.setattr(resolver, "_repo_root", root)
|
monkeypatch.setattr(resolver, "_repo_root", root)
|
||||||
_page(root, "concepts/Alpha.md", ALPHA)
|
_page(root, "concepts/Alpha.md", ALPHA)
|
||||||
_page(root, "concepts/protocols/Beta.md", BETA)
|
_page(root, "concepts/protocols/Beta.md", BETA)
|
||||||
_page(root, "concepts/Gamma.md", "\n# Gamma\n\nPrivate.\n", tags=["private"])
|
_page(root, "concepts/Gamma.md", "\n# Gamma\n\nPrivate.\n", tags=["private"])
|
||||||
_commit(root, "init")
|
_commit(root, "init")
|
||||||
(tmp_path / "OneDrive - Example").mkdir()
|
(tmp_path / "OneDrive - Example").mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ def repo(tmp_path, monkeypatch):
|
|||||||
_git(root, "commit", "-m", "init")
|
_git(root, "commit", "-m", "init")
|
||||||
_git(root, "push", "-u", "origin", "main")
|
_git(root, "push", "-u", "origin", "main")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ def fresh_instance(tmp_path, monkeypatch):
|
|||||||
(root / "kb").mkdir()
|
(root / "kb").mkdir()
|
||||||
(root / "README.md").write_text("fresh instance\n", encoding="utf-8")
|
(root / "README.md").write_text("fresh instance\n", encoding="utf-8")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@@ -1519,7 +1519,7 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
from chemenu.commands.log_append import format_log_entry, parse_log_entries
|
from chemenu.commands.log_append import format_log_entry, parse_log_entries
|
||||||
from chemenu.frontmatter_io import write_page
|
from chemenu.frontmatter_io import write_page
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs
|
||||||
|
|
||||||
GENERATED_FILES = ("kb/index.md", "kb/log.md", "kb/provenance.md", "kb/concepts/INDEX.md")
|
GENERATED_FILES = ("kb/index.md", "kb/log.md", "kb/provenance.md", "kb/concepts/INDEX.md")
|
||||||
|
|
||||||
@@ -1662,6 +1662,69 @@ def test_case_1_on_sync_leaves_the_regenerated_catalog_uncommitted(wiki_repo):
|
|||||||
cwd=wiki_repo).returncode != 0 # dropped on success
|
cwd=wiki_repo).returncode != 0 # dropped on success
|
||||||
|
|
||||||
|
|
||||||
|
def _log_only_entry(root, title="a question"):
|
||||||
|
"""What a read-only query used to leave behind: one appended log entry, nothing else."""
|
||||||
|
with (root / "kb/log.md").open("a", encoding="utf-8", newline="\n") as log:
|
||||||
|
log.write("\n" + format_log_entry("query", title, today="2026-10-06"))
|
||||||
|
|
||||||
|
|
||||||
|
def _backup_ref_exists(root):
|
||||||
|
return subprocess.run(["git", "show-ref", "--verify", "-q", git_publish.BACKUP_REF],
|
||||||
|
cwd=root).returncode == 0
|
||||||
|
|
||||||
|
|
||||||
|
def _assert_catalog_is_the_incoming_one(root):
|
||||||
|
"""kb/index.md and kb/provenance.md are byte for byte what origin/main holds."""
|
||||||
|
check = _check_tree(root)
|
||||||
|
for path in ("kb/index.md", "kb/provenance.md"):
|
||||||
|
assert (root / path).read_bytes() == (check / path).read_bytes(), path
|
||||||
|
|
||||||
|
|
||||||
|
def test_an_open_log_entry_alone_does_not_regenerate_the_catalog_on_a_fast_forward(wiki_repo):
|
||||||
|
writer = _clone_writer(wiki_repo)
|
||||||
|
_writer_ingest(writer, "Writer")
|
||||||
|
_log_only_entry(wiki_repo)
|
||||||
|
|
||||||
|
outcome = reconcile("origin", "main", None)
|
||||||
|
|
||||||
|
assert (outcome.status, outcome.regenerated) == ("fast-forwarded", False)
|
||||||
|
assert _status(wiki_repo).split() == ["M", "kb/log.md"]
|
||||||
|
_assert_catalog_is_the_incoming_one(wiki_repo)
|
||||||
|
assert _logged_titles(wiki_repo) == ["Base", "Writer", "a question"]
|
||||||
|
assert not _backup_ref_exists(wiki_repo)
|
||||||
|
|
||||||
|
|
||||||
|
def test_an_open_log_entry_alone_does_not_regenerate_the_catalog_on_a_rebase(wiki_repo):
|
||||||
|
"""A stranded commit that touches no generated file, an open log entry, and an ingest that
|
||||||
|
landed meanwhile: rebased, the catalog stays the incoming one, the log keeps both."""
|
||||||
|
writer = _clone_writer(wiki_repo)
|
||||||
|
_writer_ingest(writer, "Writer")
|
||||||
|
(wiki_repo / "local.md").write_text("local\n", encoding="utf-8")
|
||||||
|
_commit_all(wiki_repo, "stranded, touches no generated file")
|
||||||
|
_log_only_entry(wiki_repo)
|
||||||
|
|
||||||
|
outcome = reconcile("origin", "main", None)
|
||||||
|
|
||||||
|
assert (outcome.status, outcome.regenerated) == ("rebased", False)
|
||||||
|
assert _status(wiki_repo).split() == ["M", "kb/log.md"]
|
||||||
|
_assert_catalog_is_the_incoming_one(wiki_repo)
|
||||||
|
assert _logged_titles(wiki_repo) == ["Base", "Writer", "a question"]
|
||||||
|
assert (wiki_repo / "local.md").is_file()
|
||||||
|
assert not _backup_ref_exists(wiki_repo)
|
||||||
|
|
||||||
|
|
||||||
|
def test_an_open_log_entry_plus_an_uncommitted_page_still_regenerates(wiki_repo):
|
||||||
|
"""The catalog was locally changed too, so it is set aside and has to be rebuilt."""
|
||||||
|
writer = _clone_writer(wiki_repo)
|
||||||
|
_writer_ingest(writer, "Writer")
|
||||||
|
_ingest(wiki_repo, "Local")
|
||||||
|
|
||||||
|
outcome = reconcile("origin", "main", None)
|
||||||
|
|
||||||
|
assert (outcome.status, outcome.regenerated) == ("fast-forwarded", True)
|
||||||
|
_assert_generated_current(wiki_repo)
|
||||||
|
|
||||||
|
|
||||||
def test_case_2_two_committed_ingests_rebase_without_the_review_gate(wiki_repo):
|
def test_case_2_two_committed_ingests_rebase_without_the_review_gate(wiki_repo):
|
||||||
writer = _clone_writer(wiki_repo)
|
writer = _clone_writer(wiki_repo)
|
||||||
_writer_ingest(writer, "Writer")
|
_writer_ingest(writer, "Writer")
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.tests.conftest import _GIT_ENV, _WIKITOOL_ENV
|
from chemenu.tests import conftest
|
||||||
|
from chemenu.tests.conftest import (
|
||||||
|
_GIT_ENV,
|
||||||
|
_WIKITOOL_ENV,
|
||||||
|
bound_config_paths,
|
||||||
|
set_config_path,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_home_points_into_the_test_s_own_tmp_path(tmp_path: Path, hermetic_environment: Path):
|
def test_home_points_into_the_test_s_own_tmp_path(tmp_path: Path, hermetic_environment: Path):
|
||||||
@@ -55,7 +61,7 @@ def test_default_author_is_none_without_an_identity(tmp_path: Path,
|
|||||||
monkeypatch: pytest.MonkeyPatch):
|
monkeypatch: pytest.MonkeyPatch):
|
||||||
"""The branch that used to be untestable: no WIKI_AUTHOR, no git identity
|
"""The branch that used to be untestable: no WIKI_AUTHOR, no git identity
|
||||||
anywhere, so `new source` has nothing to stamp and must say so."""
|
anywhere, so `new source` has nothing to stamp and must say so."""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert config.default_author() is None
|
assert config.default_author() is None
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +69,7 @@ def test_default_author_reads_a_local_git_identity(tmp_path: Path,
|
|||||||
monkeypatch: pytest.MonkeyPatch):
|
monkeypatch: pytest.MonkeyPatch):
|
||||||
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
||||||
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert config.default_author() == "Local Identity"
|
assert config.default_author() == "Local Identity"
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +77,7 @@ def test_wiki_author_overrides_the_git_identity(tmp_path: Path,
|
|||||||
monkeypatch: pytest.MonkeyPatch):
|
monkeypatch: pytest.MonkeyPatch):
|
||||||
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
||||||
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Env Override")
|
monkeypatch.setenv("WIKI_AUTHOR", "Env Override")
|
||||||
assert config.default_author() == "Env Override"
|
assert config.default_author() == "Env Override"
|
||||||
|
|
||||||
@@ -94,3 +100,81 @@ def test_both_corpus_fixtures_keep_the_shipped_type_specs_reachable(kb_dir: Path
|
|||||||
"""Repointing `ROOT` moves `TYPES_DIR` with it, so the repoint has to be
|
"""Repointing `ROOT` moves `TYPES_DIR` with it, so the repoint has to be
|
||||||
paired with `use_shipped_type_specs()` or no page type resolves at all."""
|
paired with `use_shipped_type_specs()` or no page type resolves at all."""
|
||||||
assert (config.TYPES_DIR / "entity.md").is_file()
|
assert (config.TYPES_DIR / "entity.md").is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_repointed_root_is_taken_back_to_resolution(tmp_path: Path):
|
||||||
|
"""After the undo `ROOT` is bound exactly when it was before - here: not at
|
||||||
|
all - and resolves through `resolve_root()` again, carrying the derived
|
||||||
|
paths with it. Up to pytest 9.1, `monkeypatch.setattr` left the resolved
|
||||||
|
path behind as a real attribute instead."""
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
with pytest.MonkeyPatch.context() as mp:
|
||||||
|
set_config_path(mp, "ROOT", tmp_path)
|
||||||
|
assert config.ROOT == tmp_path
|
||||||
|
assert config.KB_DIR == tmp_path / "kb"
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
assert config.ROOT == config.resolve_root()
|
||||||
|
assert config.KB_DIR == config.resolve_root() / "kb"
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_undo_survives_hermetic_environment_resetting_first(tmp_path: Path):
|
||||||
|
"""The teardown order every test has: `hermetic_environment` calls
|
||||||
|
`config.reset()`, and only then does `monkeypatch` undo. From pytest 9.2
|
||||||
|
on, `monkeypatch.setattr`'s undo raises at exactly this point."""
|
||||||
|
mp = pytest.MonkeyPatch()
|
||||||
|
set_config_path(mp, "ROOT", tmp_path)
|
||||||
|
config.reset()
|
||||||
|
mp.undo()
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_binding_that_was_there_before_is_restored(tmp_path: Path):
|
||||||
|
before = tmp_path / "before"
|
||||||
|
vars(config)["KB_DIR"] = before
|
||||||
|
try:
|
||||||
|
with pytest.MonkeyPatch.context() as mp:
|
||||||
|
set_config_path(mp, "KB_DIR", tmp_path / "during")
|
||||||
|
assert config.KB_DIR == tmp_path / "during"
|
||||||
|
assert vars(config)["KB_DIR"] == before
|
||||||
|
finally:
|
||||||
|
config.reset()
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_name_config_does_not_manage_is_refused(monkeypatch):
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
set_config_path(monkeypatch, "ENV_ROOT", "elsewhere")
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_teardown_guard_fails_a_test_that_leaves_a_path_bound(request, tmp_path: Path):
|
||||||
|
"""What makes a fallback to `monkeypatch.setattr(config, "ROOT", ...)`
|
||||||
|
visible under every pytest version: up to 9.1 its undo leaves `ROOT` bound,
|
||||||
|
and this guard fails the test; from 9.2 the undo itself raises."""
|
||||||
|
guard = conftest.pytest_runtest_teardown(request.node, None)
|
||||||
|
next(guard)
|
||||||
|
vars(config)["ROOT"] = tmp_path
|
||||||
|
with pytest.raises(AssertionError, match="left chemenu.config path"):
|
||||||
|
guard.send(None)
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_teardown_guard_passes_a_test_that_left_nothing_bound(request):
|
||||||
|
guard = conftest.pytest_runtest_teardown(request.node, None)
|
||||||
|
next(guard)
|
||||||
|
with pytest.raises(StopIteration):
|
||||||
|
guard.send(None)
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_fallback_to_monkeypatch_setattr_does_not_go_unnoticed(tmp_path: Path):
|
||||||
|
"""The invariant's other side: the call this suite no longer makes either
|
||||||
|
raises on undo or leaves the binding for the guard - never neither."""
|
||||||
|
mp = pytest.MonkeyPatch()
|
||||||
|
mp.setattr(config, "ROOT", tmp_path)
|
||||||
|
config.reset()
|
||||||
|
try:
|
||||||
|
mp.undo()
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
assert bound_config_paths() == ["ROOT"]
|
||||||
|
finally:
|
||||||
|
config.reset()
|
||||||
@@ -2,13 +2,14 @@ from typer.testing import CliRunner
|
|||||||
|
|
||||||
from chemenu import config, install_doc, prerequisites
|
from chemenu import config, install_doc, prerequisites
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
MANIFEST = prerequisites.Manifest(
|
MANIFEST = prerequisites.Manifest(
|
||||||
limits={},
|
limits={},
|
||||||
tools=(
|
tools=(
|
||||||
prerequisites.Tool("python", "3.11", "all", "Python", "why"),
|
prerequisites.Tool("python", "3.13", "all", "Python", "why", "3.14"),
|
||||||
prerequisites.Tool("git", None, "all", "Git", "why"),
|
prerequisites.Tool("git", None, "all", "Git", "why"),
|
||||||
prerequisites.Tool("pwsh", "7", "windows", "PowerShell 7 (pwsh)", "why"),
|
prerequisites.Tool("pwsh", "7", "windows", "PowerShell 7 (pwsh)", "why"),
|
||||||
),
|
),
|
||||||
@@ -19,7 +20,7 @@ CURRENT = """# Installation
|
|||||||
You need:
|
You need:
|
||||||
|
|
||||||
<!-- wikitool:prerequisites -->
|
<!-- wikitool:prerequisites -->
|
||||||
- **Python** ≥ 3.11
|
- **Python** 3.13 – 3.14
|
||||||
- **Git**
|
- **Git**
|
||||||
<!-- /wikitool:prerequisites -->
|
<!-- /wikitool:prerequisites -->
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ SETUP = """# Set up
|
|||||||
|
|
||||||
|
|
||||||
def _tree(tmp_path, monkeypatch, install=CURRENT, setup=SETUP, manifest=MANIFEST):
|
def _tree(tmp_path, monkeypatch, install=CURRENT, setup=SETUP, manifest=MANIFEST):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(prerequisites, "load_manifest", lambda path=None: manifest)
|
monkeypatch.setattr(prerequisites, "load_manifest", lambda path=None: manifest)
|
||||||
(tmp_path / "instructions").mkdir()
|
(tmp_path / "instructions").mkdir()
|
||||||
(tmp_path / "INSTALL.md").write_text(install, encoding="utf-8")
|
(tmp_path / "INSTALL.md").write_text(install, encoding="utf-8")
|
||||||
@@ -75,14 +76,25 @@ def test_this_repos_setup_instruction_marks_its_questions():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_render_lines_are_label_and_minimum_only():
|
def test_render_lines_are_label_and_version_bounds_only():
|
||||||
assert install_doc.render_lines(MANIFEST.tools) == [
|
assert install_doc.render_lines(MANIFEST.tools) == [
|
||||||
"- **Python** ≥ 3.11",
|
"- **Python** 3.13 – 3.14",
|
||||||
"- **Git**",
|
"- **Git**",
|
||||||
"- **PowerShell 7 (pwsh)** ≥ 7",
|
"- **PowerShell 7 (pwsh)** ≥ 7",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_maximum_alone_renders_as_an_upper_bound():
|
||||||
|
tool = prerequisites.Tool("x", None, "all", "X", "why", "2")
|
||||||
|
assert install_doc.render_lines((tool,)) == ["- **X** ≤ 2"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_real_install_doc_names_the_python_span():
|
||||||
|
"""#245: INSTALL.md carries the admitted span, not a floor alone."""
|
||||||
|
text = (config._PACKAGE_ROOT / install_doc.INSTALL_DOC).read_text(encoding="utf-8")
|
||||||
|
assert "- **Python** 3.13 – 3.14" in text
|
||||||
|
|
||||||
|
|
||||||
def test_a_current_install_doc_passes(tmp_path, monkeypatch):
|
def test_a_current_install_doc_passes(tmp_path, monkeypatch):
|
||||||
_tree(tmp_path, monkeypatch)
|
_tree(tmp_path, monkeypatch)
|
||||||
assert install_doc.check_prerequisite_regions() == []
|
assert install_doc.check_prerequisite_regions() == []
|
||||||
@@ -121,7 +133,7 @@ def test_a_missing_install_doc_is_reported(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_refresh_touches_nothing_outside_the_regions(tmp_path):
|
def test_refresh_touches_nothing_outside_the_regions(tmp_path):
|
||||||
stale = CURRENT.replace("≥ 3.11", "≥ 3.9")
|
stale = CURRENT.replace("3.13 – 3.14", "≥ 3.9")
|
||||||
refreshed, missing = install_doc.refresh(stale, MANIFEST)
|
refreshed, missing = install_doc.refresh(stale, MANIFEST)
|
||||||
assert missing == []
|
assert missing == []
|
||||||
assert refreshed == CURRENT
|
assert refreshed == CURRENT
|
||||||
@@ -153,7 +165,7 @@ def test_a_question_no_longer_asked_fails(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_docs_prerequisites_is_a_dry_run_by_default(tmp_path, monkeypatch):
|
def test_docs_prerequisites_is_a_dry_run_by_default(tmp_path, monkeypatch):
|
||||||
stale = CURRENT.replace("≥ 3.11", "≥ 3.9")
|
stale = CURRENT.replace("3.13 – 3.14", "≥ 3.9")
|
||||||
root = _tree(tmp_path, monkeypatch, install=stale)
|
root = _tree(tmp_path, monkeypatch, install=stale)
|
||||||
result = runner.invoke(app, ["docs", "prerequisites"])
|
result = runner.invoke(app, ["docs", "prerequisites"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -162,7 +174,7 @@ def test_docs_prerequisites_is_a_dry_run_by_default(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_docs_prerequisites_apply_rewrites_the_regions(tmp_path, monkeypatch):
|
def test_docs_prerequisites_apply_rewrites_the_regions(tmp_path, monkeypatch):
|
||||||
root = _tree(tmp_path, monkeypatch, install=CURRENT.replace("≥ 3.11", "≥ 3.9"))
|
root = _tree(tmp_path, monkeypatch, install=CURRENT.replace("3.13 – 3.14", "≥ 3.9"))
|
||||||
result = runner.invoke(app, ["docs", "prerequisites", "--apply"])
|
result = runner.invoke(app, ["docs", "prerequisites", "--apply"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
assert (root / "INSTALL.md").read_text(encoding="utf-8") == CURRENT
|
assert (root / "INSTALL.md").read_text(encoding="utf-8") == CURRENT
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import pytest
|
|||||||
import typer
|
import typer
|
||||||
|
|
||||||
from chemenu import config, conventions
|
from chemenu import config, conventions
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs
|
||||||
from chemenu.commands import instructions_cmd
|
from chemenu.commands import instructions_cmd
|
||||||
|
|
||||||
|
|
||||||
@@ -33,11 +33,11 @@ def layer(tmp_path: Path, monkeypatch):
|
|||||||
(root / "AGENTS.md").write_text("# AGENTS\n", encoding="utf-8")
|
(root / "AGENTS.md").write_text("# AGENTS\n", encoding="utf-8")
|
||||||
(root / "kb").mkdir()
|
(root / "kb").mkdir()
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "KB_DIR", root / "kb")
|
set_config_path(monkeypatch, "KB_DIR", root / "kb")
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setattr(config, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
set_config_path(monkeypatch, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
||||||
monkeypatch.setattr(config, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
set_config_path(monkeypatch, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
||||||
# `verify` resolves each instruction's `type: types/instruction.md`, and the
|
# `verify` resolves each instruction's `type: types/instruction.md`, and the
|
||||||
# resolver's root follows `ROOT` now - so the shipped specs have to be named
|
# resolver's root follows `ROOT` now - so the shipped specs have to be named
|
||||||
# rather than inherited. See `use_shipped_type_specs`.
|
# rather than inherited. See `use_shipped_type_specs`.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import pytest
|
|||||||
|
|
||||||
from chemenu import config, kb_collections, type_resolver
|
from chemenu import config, kb_collections, type_resolver
|
||||||
from chemenu.type_resolver import TypeResolver
|
from chemenu.type_resolver import TypeResolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -17,8 +18,8 @@ def repo(tmp_path: Path, monkeypatch) -> Path:
|
|||||||
(kb / "README.md").write_text("# KB Routing\n", encoding="utf-8")
|
(kb / "README.md").write_text("# KB Routing\n", encoding="utf-8")
|
||||||
(tmp_path / "raw").mkdir()
|
(tmp_path / "raw").mkdir()
|
||||||
(tmp_path / "types").mkdir()
|
(tmp_path / "types").mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ def test_stack_required_collections_includes_gtd_once_project_type_exists(repo,
|
|||||||
"---\n",
|
"---\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
||||||
assert "gtd" in kb_collections.stack_required_collections()
|
assert "gtd" in kb_collections.stack_required_collections()
|
||||||
|
|
||||||
@@ -97,6 +98,6 @@ def test_stack_required_collections_includes_gtd_once_project_type_exists(repo,
|
|||||||
def test_stack_required_collections_omits_a_type_with_no_type_spec(repo, monkeypatch):
|
def test_stack_required_collections_omits_a_type_with_no_type_spec(repo, monkeypatch):
|
||||||
"""No `project.md` at all - the required-types derivation must tolerate a
|
"""No `project.md` at all - the required-types derivation must tolerate a
|
||||||
missing type rather than raising, so a corpus mid-adoption still lints."""
|
missing type rather than raising, so a corpus mid-adoption still lints."""
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", repo / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", repo / "types")
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
||||||
assert "gtd" not in kb_collections.stack_required_collections()
|
assert "gtd" not in kb_collections.stack_required_collections()
|
||||||
@@ -21,6 +21,7 @@ from chemenu import config, config_shapes, legacy_settings, settings, upload
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.tasks import caldav, config as tasks_config, superproductivity
|
from chemenu.tasks import caldav, config as tasks_config, superproductivity
|
||||||
from chemenu.telemetry import policy
|
from chemenu.telemetry import policy
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ def checkout(tmp_path, monkeypatch):
|
|||||||
"""A git checkout under `tmp_path/work`, with the secrets file kept outside it."""
|
"""A git checkout under `tmp_path/work`, with the secrets file kept outside it."""
|
||||||
root = tmp_path / "work"
|
root = tmp_path / "work"
|
||||||
root.mkdir()
|
root.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "xdg"))
|
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "xdg"))
|
||||||
subprocess.run(["git", "init", "-b", "main"], cwd=root, check=True, capture_output=True)
|
subprocess.run(["git", "init", "-b", "main"], cwd=root, check=True, capture_output=True)
|
||||||
subprocess.run(["git", "config", "user.email", "a@example.net"], cwd=root, check=True)
|
subprocess.run(["git", "config", "user.email", "a@example.net"], cwd=root, check=True)
|
||||||
@@ -345,7 +346,7 @@ def test_a_migrated_setting_that_is_already_there_with_the_same_value_is_not_a_c
|
|||||||
])
|
])
|
||||||
def test_a_leftover_makes_the_command_that_needs_the_setting_exit_42(checkout, monkeypatch, args, name):
|
def test_a_leftover_makes_the_command_that_needs_the_setting_exit_42(checkout, monkeypatch, args, name):
|
||||||
(checkout / "kb").mkdir()
|
(checkout / "kb").mkdir()
|
||||||
monkeypatch.setattr(config, "KB_DIR", checkout / "kb")
|
set_config_path(monkeypatch, "KB_DIR", checkout / "kb")
|
||||||
(checkout / name).write_text("{}", encoding="utf-8")
|
(checkout / name).write_text("{}", encoding="utf-8")
|
||||||
result = runner.invoke(app, args)
|
result = runner.invoke(app, args)
|
||||||
assert result.exit_code == 42, result.output
|
assert result.exit_code == 42, result.output
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from chemenu.frontmatter_io import write_page
|
|||||||
from chemenu.lint_core import unfilled_sections
|
from chemenu.lint_core import unfilled_sections
|
||||||
from chemenu.provenance import cite_id, render_cite_block
|
from chemenu.provenance import cite_id, render_cite_block
|
||||||
from chemenu.version import Version
|
from chemenu.version import Version
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def test_lint_detects_unparsable_frontmatter(kb_dir):
|
def test_lint_detects_unparsable_frontmatter(kb_dir):
|
||||||
@@ -454,7 +455,7 @@ def test_the_area_recommendation_says_the_layout_is_missing_when_it_is(kb_dir, t
|
|||||||
"additionalProperties: false\n",
|
"additionalProperties: false\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(resolver, "_repo_root", tmp_path)
|
monkeypatch.setattr(resolver, "_repo_root", tmp_path)
|
||||||
|
|
||||||
_fill_collection(
|
_fill_collection(
|
||||||
@@ -672,9 +673,9 @@ def test_render_summary_says_so_when_there_is_nothing(kb_dir):
|
|||||||
def test_lint_writes_a_report_and_names_its_path(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
def test_lint_writes_a_report_and_names_its_path(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
||||||
"""Without a printed path the only way back to the full report is a second
|
"""Without a printed path the only way back to the full report is a second
|
||||||
lint call - the double-charge this default exists to remove."""
|
lint call - the double-charge this default exists to remove."""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
lint_command(json_out=False, markdown_out=None, full=False, fail_on_error=False)
|
lint_command(json_out=False, markdown_out=None, full=False, fail_on_error=False)
|
||||||
|
|
||||||
written = tmp_path / "reports" / f"Lint Report {date.today().isoformat()}.md"
|
written = tmp_path / "reports" / f"Lint Report {date.today().isoformat()}.md"
|
||||||
@@ -686,9 +687,9 @@ def test_lint_writes_a_report_and_names_its_path(kb_dir, raw_dir, tmp_path, monk
|
|||||||
|
|
||||||
|
|
||||||
def test_lint_full_prints_the_whole_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
def test_lint_full_prints_the_whole_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
lint_command(json_out=False, markdown_out=None, full=True, fail_on_error=False)
|
lint_command(json_out=False, markdown_out=None, full=True, fail_on_error=False)
|
||||||
assert "None found." in capsys.readouterr().out
|
assert "None found." in capsys.readouterr().out
|
||||||
|
|
||||||
@@ -696,18 +697,18 @@ def test_lint_full_prints_the_whole_report(kb_dir, raw_dir, tmp_path, monkeypatc
|
|||||||
def test_lint_json_writes_no_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
def test_lint_json_writes_no_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
||||||
"""`--json` is a machine-readable dump of the same findings; writing a
|
"""`--json` is a machine-readable dump of the same findings; writing a
|
||||||
second copy to reports/ would be noise the caller never asked for."""
|
second copy to reports/ would be noise the caller never asked for."""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
lint_command(json_out=True, markdown_out=None, full=False, fail_on_error=False)
|
lint_command(json_out=True, markdown_out=None, full=False, fail_on_error=False)
|
||||||
assert not (tmp_path / "reports").exists()
|
assert not (tmp_path / "reports").exists()
|
||||||
assert json.loads(capsys.readouterr().out)["page_count"] > 0
|
assert json.loads(capsys.readouterr().out)["page_count"] > 0
|
||||||
|
|
||||||
|
|
||||||
def test_lint_markdown_option_overrides_the_default_path(kb_dir, raw_dir, tmp_path, monkeypatch):
|
def test_lint_markdown_option_overrides_the_default_path(kb_dir, raw_dir, tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
target = tmp_path / "elsewhere" / "report.md"
|
target = tmp_path / "elsewhere" / "report.md"
|
||||||
lint_command(json_out=False, markdown_out=target, full=False, fail_on_error=False)
|
lint_command(json_out=False, markdown_out=target, full=False, fail_on_error=False)
|
||||||
assert target.exists()
|
assert target.exists()
|
||||||
@@ -895,7 +896,7 @@ def test_unauthorised_label_is_judged_in_a_tree_that_is_not_the_configured_kb(
|
|||||||
)
|
)
|
||||||
elsewhere = tmp_path / "elsewhere"
|
elsewhere = tmp_path / "elsewhere"
|
||||||
elsewhere.mkdir()
|
elsewhere.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", elsewhere)
|
set_config_path(monkeypatch, "ROOT", elsewhere)
|
||||||
assert config.KB_DIR != kb_dir
|
assert config.KB_DIR != kb_dir
|
||||||
|
|
||||||
report = run_lint(kb_dir)
|
report = run_lint(kb_dir)
|
||||||
@@ -1095,9 +1096,9 @@ def test_lint_reports_a_raw_path_over_the_budget(kb_dir, raw_dir):
|
|||||||
def test_lint_fail_on_error_ignores_long_paths(kb_dir, raw_dir, tmp_path, monkeypatch):
|
def test_lint_fail_on_error_ignores_long_paths(kb_dir, raw_dir, tmp_path, monkeypatch):
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
baseline = has_hard_errors(run_lint(kb_dir))
|
baseline = has_hard_errors(run_lint(kb_dir))
|
||||||
_long_page(kb_dir, 170)
|
_long_page(kb_dir, 170)
|
||||||
report = run_lint(kb_dir)
|
report = run_lint(kb_dir)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from chemenu.commands.log_append import (
|
|||||||
log_status,
|
log_status,
|
||||||
parse_log_entries,
|
parse_log_entries,
|
||||||
)
|
)
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def test_log_entry_format_matches_convention():
|
def test_log_entry_format_matches_convention():
|
||||||
@@ -60,7 +61,7 @@ def test_ingests_since_last_lint_counts_from_the_start_when_never_linted():
|
|||||||
def test_log_status_reports_zero_with_no_log_file(tmp_path, monkeypatch, capsys):
|
def test_log_status_reports_zero_with_no_log_file(tmp_path, monkeypatch, capsys):
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "LOG_FILE", tmp_path / "log.md")
|
set_config_path(monkeypatch, "LOG_FILE", tmp_path / "log.md")
|
||||||
log_status()
|
log_status()
|
||||||
assert "No kb/log.md yet" in capsys.readouterr().out
|
assert "No kb/log.md yet" in capsys.readouterr().out
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ def test_log_status_warns_at_the_ten_ingest_threshold(tmp_path, monkeypatch, cap
|
|||||||
format_log_entry("ingest", f"raw/notes/{i}.md", today="2026-08-01") for i in range(10)
|
format_log_entry("ingest", f"raw/notes/{i}.md", today="2026-08-01") for i in range(10)
|
||||||
)
|
)
|
||||||
log_file.write_text(body, encoding="utf-8")
|
log_file.write_text(body, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", log_file)
|
set_config_path(monkeypatch, "LOG_FILE", log_file)
|
||||||
|
|
||||||
log_status()
|
log_status()
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
@@ -111,7 +112,7 @@ def test_log_append_reports_an_unreadable_body_file_as_an_error(make_bad_file, t
|
|||||||
log_file = tmp_path / "log.md"
|
log_file = tmp_path / "log.md"
|
||||||
before = "# Wiki Log\n"
|
before = "# Wiki Log\n"
|
||||||
log_file.write_text(before, encoding="utf-8")
|
log_file.write_text(before, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", log_file)
|
set_config_path(monkeypatch, "LOG_FILE", log_file)
|
||||||
bad_file = make_bad_file(tmp_path)
|
bad_file = make_bad_file(tmp_path)
|
||||||
|
|
||||||
with pytest.raises(typer.Exit) as exc:
|
with pytest.raises(typer.Exit) as exc:
|
||||||
@@ -129,7 +130,7 @@ def test_log_append_reads_the_body_from_body_file(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
log_file = tmp_path / "log.md"
|
log_file = tmp_path / "log.md"
|
||||||
log_file.write_text("# Wiki Log\n", encoding="utf-8")
|
log_file.write_text("# Wiki Log\n", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", log_file)
|
set_config_path(monkeypatch, "LOG_FILE", log_file)
|
||||||
body_file = tmp_path / "body.md"
|
body_file = tmp_path / "body.md"
|
||||||
body_file.write_text("Created [[Docker]].", encoding="utf-8")
|
body_file.write_text("Created [[Docker]].", encoding="utf-8")
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import typer
|
|||||||
from chemenu import config, kb_state
|
from chemenu import config, kb_state
|
||||||
from chemenu.commands import migrate_cmd
|
from chemenu.commands import migrate_cmd
|
||||||
from chemenu.version import Version, VersionError
|
from chemenu.version import Version, VersionError
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
CHANGES = "# Changelog\n\n---\n\n## 1.0.0 - 2026-08-30 - First\n\nBody.\n"
|
CHANGES = "# Changelog\n\n---\n\n## 1.0.0 - 2026-08-30 - First\n\nBody.\n"
|
||||||
|
|
||||||
@@ -54,8 +55,8 @@ def instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
write_migration(migrations, "1.2.0", "ancient")
|
write_migration(migrations, "1.2.0", "ancient")
|
||||||
write_migration(migrations, "2.1.0", "not-installed-yet")
|
write_migration(migrations, "2.1.0", "not-installed-yet")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
@@ -226,8 +227,8 @@ def git_instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
||||||
)
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", tmp_path / "kb")
|
set_config_path(monkeypatch, "KB_DIR", tmp_path / "kb")
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
@@ -319,8 +320,8 @@ def test_verify_confirms_three_moved_pages_compare_as_themselves(tmp_path, monke
|
|||||||
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
||||||
)
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", tmp_path / "kb")
|
set_config_path(monkeypatch, "KB_DIR", tmp_path / "kb")
|
||||||
|
|
||||||
moved_dir = kb / "moved"
|
moved_dir = kb / "moved"
|
||||||
moved_dir.mkdir()
|
moved_dir.mkdir()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from chemenu.commands._util import coerce_set_value, parse_set_fields
|
|||||||
from chemenu.commands.new_page import _page_subdir
|
from chemenu.commands.new_page import _page_subdir
|
||||||
from chemenu.frontmatter_io import read_page
|
from chemenu.frontmatter_io import read_page
|
||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
@@ -85,8 +86,10 @@ def _write_sp_backup(root, project_titles: list[str]) -> Path:
|
|||||||
def _make_api_handler(state: dict):
|
def _make_api_handler(state: dict):
|
||||||
class Handler(http.server.BaseHTTPRequestHandler):
|
class Handler(http.server.BaseHTTPRequestHandler):
|
||||||
posted = False
|
posted = False
|
||||||
|
contacted = False
|
||||||
|
|
||||||
def do_GET(self): # noqa: N802 - stdlib method name
|
def do_GET(self): # noqa: N802 - stdlib method name
|
||||||
|
Handler.contacted = True
|
||||||
if self.path == "/health":
|
if self.path == "/health":
|
||||||
self._reply(200, {"server": "up", "rendererReady": True})
|
self._reply(200, {"server": "up", "rendererReady": True})
|
||||||
return
|
return
|
||||||
@@ -104,6 +107,7 @@ def _make_api_handler(state: dict):
|
|||||||
def do_POST(self): # noqa: N802
|
def do_POST(self): # noqa: N802
|
||||||
# `new project` must never attempt this on the API path either -
|
# `new project` must never attempt this on the API path either -
|
||||||
# there is no POST /projects endpoint upstream (Gitea #124/#133).
|
# there is no POST /projects endpoint upstream (Gitea #124/#133).
|
||||||
|
Handler.contacted = True
|
||||||
Handler.posted = True
|
Handler.posted = True
|
||||||
self._reply(404, {"error": "no such endpoint (fixture)"})
|
self._reply(404, {"error": "no such endpoint (fixture)"})
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ def _invoke_new(monkeypatch, kb_dir, args):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return runner.invoke(app, args)
|
return runner.invoke(app, args)
|
||||||
|
|
||||||
|
|
||||||
@@ -304,6 +308,26 @@ def test_new_project_refuses_a_tracker_collision_without_resume(monkeypatch, kb_
|
|||||||
assert not (kb_dir / "gtd/haus/Kueche renovieren.md").exists()
|
assert not (kb_dir / "gtd/haus/Kueche renovieren.md").exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_new_project_refuses_a_kb_title_collision_before_touching_the_tracker(monkeypatch, kb_dir):
|
||||||
|
"""Gitea #244: a project named after the artifact it concerns collides
|
||||||
|
with that artifact's entity page, since titles are unique across kb/.
|
||||||
|
The title check runs before the tracker step, so the refusal leaves
|
||||||
|
nothing behind on either side - no page, and no tracker request at all."""
|
||||||
|
root = kb_dir.parent
|
||||||
|
with _api_server([]) as (server, handler_cls):
|
||||||
|
_write_tasks_config(root, _base_url(server))
|
||||||
|
|
||||||
|
result = _invoke_new(monkeypatch, kb_dir, [
|
||||||
|
"new", "project", "--name", "gdeploy", "--set", "responsibility=haus",
|
||||||
|
])
|
||||||
|
assert result.exit_code == 1
|
||||||
|
assert "already exists" in result.output
|
||||||
|
assert "entities/tools/gdeploy.md" in result.output
|
||||||
|
assert not (kb_dir / "gtd/haus/gdeploy.md").exists()
|
||||||
|
assert handler_cls.contacted is False
|
||||||
|
assert handler_cls.posted is False
|
||||||
|
|
||||||
|
|
||||||
def test_new_project_resume_continues_past_an_existing_tracker_project(monkeypatch, kb_dir):
|
def test_new_project_resume_continues_past_an_existing_tracker_project(monkeypatch, kb_dir):
|
||||||
"""The retry half of the HumanInterventionRequired dance (#126's own
|
"""The retry half of the HumanInterventionRequired dance (#126's own
|
||||||
"Schritt 2"): once a human has created the tracker project by hand, a
|
"Schritt 2"): once a human has created the tracker project by hand, a
|
||||||
@@ -521,7 +545,7 @@ def _fixture_raw_file(monkeypatch, kb_dir, relative: str) -> None:
|
|||||||
|
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import use_shipped_type_specs
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", kb_dir.parent)
|
set_config_path(monkeypatch, "ROOT", kb_dir.parent)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
path = kb_dir.parent / relative
|
path = kb_dir.parent / relative
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -861,7 +885,7 @@ def test_raw_files_error_points_at_the_comma_split(monkeypatch, kb_dir, raw_dir)
|
|||||||
# depend on the caller's git config (see the test-hardening issue).
|
# depend on the caller's git config (see the test-hardening issue).
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", kb_dir.parent)
|
set_config_path(monkeypatch, "ROOT", kb_dir.parent)
|
||||||
result = _invoke_new(monkeypatch, kb_dir, [
|
result = _invoke_new(monkeypatch, kb_dir, [
|
||||||
"new", "source", "--name", "Split Path",
|
"new", "source", "--name", "Split Path",
|
||||||
"--set", "source_type=notes",
|
"--set", "source_type=notes",
|
||||||
@@ -884,7 +908,7 @@ def _invoke_new_instruction(monkeypatch, tmp_path, args):
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import use_shipped_type_specs
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
(tmp_path / "instructions").mkdir(parents=True, exist_ok=True)
|
(tmp_path / "instructions").mkdir(parents=True, exist_ok=True)
|
||||||
return runner.invoke(app, args)
|
return runner.invoke(app, args)
|
||||||
@@ -923,7 +947,7 @@ def test_source_page_accepts_a_raw_file_whose_name_has_a_comma(monkeypatch, kb_d
|
|||||||
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
||||||
|
|
||||||
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", kb_dir.parent)
|
set_config_path(monkeypatch, "ROOT", kb_dir.parent)
|
||||||
result = _invoke_new(monkeypatch, kb_dir, [
|
result = _invoke_new(monkeypatch, kb_dir, [
|
||||||
"new", "source", "--name", "Comma Source",
|
"new", "source", "--name", "Comma Source",
|
||||||
"--set", r"raw_files=raw/notes/Versioning\, CI-CD.md",
|
"--set", r"raw_files=raw/notes/Versioning\, CI-CD.md",
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ import typer
|
|||||||
from chemenu.commands import page_ops
|
from chemenu.commands import page_ops
|
||||||
from chemenu.frontmatter_io import read_page, write_page
|
from chemenu.frontmatter_io import read_page, write_page
|
||||||
from chemenu.provenance import cite_id
|
from chemenu.provenance import cite_id
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def patched_wiki(kb_dir, monkeypatch):
|
def patched_wiki(kb_dir, monkeypatch):
|
||||||
"""Point config.KB_DIR at the fixture wiki so the commands never touch
|
"""Point config.KB_DIR at the fixture wiki so the commands never touch
|
||||||
the real one."""
|
the real one."""
|
||||||
monkeypatch.setattr("chemenu.config.KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return kb_dir
|
return kb_dir
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from typer.testing import CliRunner
|
|||||||
|
|
||||||
from chemenu.commands.index_build import plan_index
|
from chemenu.commands.index_build import plan_index
|
||||||
from chemenu.commands.lint import HARD_ERROR_KEYS, has_hard_errors, run_lint
|
from chemenu.commands.lint import HARD_ERROR_KEYS, has_hard_errors, run_lint
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -51,9 +52,9 @@ def empty_kb(tmp_path, monkeypatch):
|
|||||||
raw = tmp_path / "raw"
|
raw = tmp_path / "raw"
|
||||||
raw.mkdir()
|
raw.mkdir()
|
||||||
|
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
monkeypatch.setattr(config, "INDEX_FILE", kb / "index.md")
|
set_config_path(monkeypatch, "INDEX_FILE", kb / "index.md")
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw)
|
set_config_path(monkeypatch, "RAW_DIR", raw)
|
||||||
return kb
|
return kb
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from chemenu import config, prerequisites, titles, toolpaths
|
from chemenu import config, prerequisites, titles, toolpaths
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
TOOLS = config._PACKAGE_ROOT / "tools"
|
TOOLS = config._PACKAGE_ROOT / "tools"
|
||||||
|
|
||||||
@@ -60,13 +61,14 @@ case "$1" in
|
|||||||
case "$2" in
|
case "$2" in
|
||||||
*hashlib*) exec "{real}" "$@" ;;
|
*hashlib*) exec "{real}" "$@" ;;
|
||||||
esac
|
esac
|
||||||
printf '%s\\n%s\\n' "${{FAKE_PY_VERSION:-3.13}}" "$0"
|
printf '%s\\n%s\\n' "{version}" "$0"
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
-m)
|
-m)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
venv)
|
venv)
|
||||||
shift 2
|
shift 2
|
||||||
[ "$1" = --clear ] && shift
|
# --clear empties the folder first, stamps included, as the real one does.
|
||||||
|
if [ "$1" = --clear ]; then shift; rm -rf "$1"; fi
|
||||||
if [ -n "${{FAKE_VENV_FAIL:-}}" ]; then
|
if [ -n "${{FAKE_VENV_FAIL:-}}" ]; then
|
||||||
echo "Error: ensurepip is not available" >&2
|
echo "Error: ensurepip is not available" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -114,7 +116,7 @@ class Machine:
|
|||||||
for name in ("preflight.sh", "preflight.ps1", "prerequisites.txt", "wikitool", "wikitool.ps1",
|
for name in ("preflight.sh", "preflight.ps1", "prerequisites.txt", "wikitool", "wikitool.ps1",
|
||||||
"run_wikitool.py", "trace-hook", "trace-hook.ps1"):
|
"run_wikitool.py", "trace-hook", "trace-hook.ps1"):
|
||||||
shutil.copy2(TOOLS / name, self.tools / name)
|
shutil.copy2(TOOLS / name, self.tools / name)
|
||||||
(self.tools / "requirements.txt").write_text("PyYAML\n", encoding="utf-8")
|
(self.tools / "requirements.lock").write_text("pyyaml==6.0.3 --hash=sha256:00\n", encoding="utf-8")
|
||||||
self.sysbin = base / "sysbin"
|
self.sysbin = base / "sysbin"
|
||||||
self.sysbin.mkdir(exist_ok=True)
|
self.sysbin.mkdir(exist_ok=True)
|
||||||
for name in UTILITIES:
|
for name in UTILITIES:
|
||||||
@@ -130,8 +132,26 @@ class Machine:
|
|||||||
def stub(self, name: str, text: str, where: Path | None = None) -> Path:
|
def stub(self, name: str, text: str, where: Path | None = None) -> Path:
|
||||||
return _executable((where or self.stubs) / name, text)
|
return _executable((where or self.stubs) / name, text)
|
||||||
|
|
||||||
def python(self, name: str = "python3", where: Path | None = None) -> Path:
|
def python(self, name: str = "python3", where: Path | None = None, version: str | None = None) -> Path:
|
||||||
return self.stub(name, FAKE_PYTHON.format(real=sys.executable), where)
|
"""The fake Python; `version` fixes the one it reports, else FAKE_PY_VERSION decides
|
||||||
|
(3.13 when unset)."""
|
||||||
|
return self.stub(name, FAKE_PYTHON.format(real=sys.executable,
|
||||||
|
version=version or "${FAKE_PY_VERSION:-3.13}"), where)
|
||||||
|
|
||||||
|
def py_launcher(self, default: str, versions: tuple[str, ...]) -> dict[str, Path]:
|
||||||
|
"""Windows' `py`: `-3.X` starts the fake Python of that version, which lies off
|
||||||
|
PATH as the real ones do; anything else is a fake Python of `default`. Returns the
|
||||||
|
version -> interpreter map, whose paths are what the probe reports."""
|
||||||
|
installed = {version: self.python(f"python{version}", self.base / "py-installs" / version, version)
|
||||||
|
for version in versions}
|
||||||
|
cases = "".join(f' -{version}) shift; exec "{path}" "$@" ;;\n' for version, path in installed.items())
|
||||||
|
fallback = self.python("python-default", self.base / "py-installs" / "default", default)
|
||||||
|
self.stub("py", f'#!/bin/sh\ncase "$1" in\n{cases} -3) shift ;;\nesac\nexec "{fallback}" "$@"\n')
|
||||||
|
return installed
|
||||||
|
|
||||||
|
def existing_venv(self, version: str) -> Path:
|
||||||
|
"""A tools/.venv left by an earlier run, whose Python reports `version`."""
|
||||||
|
return self.python("python", self.tools / ".venv" / "bin", version)
|
||||||
|
|
||||||
def standard(self, rg: bool = True, pwsh: bool = False) -> "Machine":
|
def standard(self, rg: bool = True, pwsh: bool = False) -> "Machine":
|
||||||
self.python()
|
self.python()
|
||||||
@@ -269,6 +289,163 @@ def test_python_too_old_stops(machine, shell):
|
|||||||
assert_guidance(result.stdout, "Python 3.9 is too old")
|
assert_guidance(result.stdout, "Python 3.9 is too old")
|
||||||
|
|
||||||
|
|
||||||
|
# --- the Python span (Gitea #245) ----------------------------------------------------
|
||||||
|
|
||||||
|
PY_SPAN = prerequisites.load_manifest().tool("python")
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_manifest_admits_python_3_13_to_3_14():
|
||||||
|
assert (PY_SPAN.minimum, PY_SPAN.maximum) == ("3.13", "3.14")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
@pytest.mark.parametrize("version, status", [("3.12", "TOO_OLD"), ("3.13", "OK"),
|
||||||
|
("3.14", "OK"), ("3.15", "TOO_NEW")])
|
||||||
|
def test_both_ends_of_the_span_are_inclusive_and_only_they(machine, shell, version, status):
|
||||||
|
machine.standard()
|
||||||
|
machine.extra_env["FAKE_PY_VERSION"] = version
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert any(line.split()[:2] == [status, "python"] for line in result.stdout.splitlines()), result.stdout
|
||||||
|
if status == "OK":
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
return
|
||||||
|
assert result.returncode == 42
|
||||||
|
word = "old" if status == "TOO_OLD" else "new"
|
||||||
|
assert_guidance(result.stdout, f"Python {version} is too {word} - this stack needs Python 3.13 to 3.14",
|
||||||
|
"--set python=")
|
||||||
|
assert not (machine.tools / ".venv").exists()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
@pytest.mark.parametrize("default", ["3.12", "3.15"])
|
||||||
|
def test_a_versioned_python_of_the_span_is_taken_when_the_plain_one_lies_outside(machine, shell, default):
|
||||||
|
machine.standard()
|
||||||
|
machine.python("python3", version=default)
|
||||||
|
versioned = machine.python("python3.14", version="3.14", where=machine.base / "elsewhere")
|
||||||
|
machine.path_dirs.append(versioned.parent)
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert machine.recorded()["tools"]["python"] == str(versioned)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_on_windows_the_launcher_is_asked_for_a_version_of_the_span(machine, shell):
|
||||||
|
machine.standard(pwsh=True)
|
||||||
|
machine.extra_env.update(CHEMENU_PREFLIGHT_PLATFORM="windows", CHEMENU_PREFLIGHT_LONGPATHS="1",
|
||||||
|
FAKE_PY_VERSION="3.15")
|
||||||
|
installed = machine.py_launcher("3.15", ("3.13", "3.14"))
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert machine.recorded()["tools"]["python"] == str(installed["3.14"])
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_on_linux_an_out_of_span_python_names_the_distribution_and_set_but_no_other_tool(machine, shell):
|
||||||
|
"""Variant A of #245, point 10: the apt line stays, and the message says that the
|
||||||
|
distribution may have no Python of the span - pointing at --set, not at uv or a PPA."""
|
||||||
|
machine.standard()
|
||||||
|
machine.stub("apt-get", "#!/bin/sh\nexit 0\n")
|
||||||
|
machine.extra_env.update(CHEMENU_PREFLIGHT_PLATFORM="linux", FAKE_PY_VERSION="3.12")
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert result.returncode == 42
|
||||||
|
assert_guidance(result.stdout, "sudo apt install python3 python3-venv",
|
||||||
|
"package source of this Linux distribution may offer no Python 3.13 to 3.14",
|
||||||
|
f"{'tools/preflight.sh'} --set python=<full path to python>")
|
||||||
|
fix = result.stdout.split("Fix:", 1)[1]
|
||||||
|
for other in ("uv ", "pyenv", "deadsnakes", "conda", "ppa:"):
|
||||||
|
assert other not in fix
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
@pytest.mark.parametrize("platform", ["macos", "windows"])
|
||||||
|
def test_off_linux_the_message_carries_no_distribution_note(machine, shell, platform):
|
||||||
|
machine.standard(pwsh=True)
|
||||||
|
machine.extra_env.update(CHEMENU_PREFLIGHT_PLATFORM=platform, CHEMENU_PREFLIGHT_LONGPATHS="1",
|
||||||
|
FAKE_PY_VERSION="3.15")
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert result.returncode == 42
|
||||||
|
assert_guidance(result.stdout, "Python 3.15 is too new")
|
||||||
|
assert "Linux distribution" not in result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_python_install_fields_name_a_version_of_the_span():
|
||||||
|
"""winget, choco and brew can install one given version, so the manifest names that one
|
||||||
|
rather than the newest; apt and pacman stay the distribution's own python (#245, point 10)."""
|
||||||
|
fields = next(line.split("|") for line in (TOOLS / "prerequisites.txt").read_text(encoding="utf-8").splitlines()
|
||||||
|
if line.startswith("tool|python|"))
|
||||||
|
choco, winget, brew, apt, pacman = fields[7:12]
|
||||||
|
assert choco == "choco install python314"
|
||||||
|
assert winget == "winget install --id Python.Python.3.14 -e"
|
||||||
|
assert brew == "brew install python@3.14"
|
||||||
|
assert (apt, pacman) == ("sudo apt install python3 python3-venv", "sudo pacman -S python")
|
||||||
|
|
||||||
|
|
||||||
|
# --- tools/.venv and the lock (Gitea #245) -------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_the_venv_installs_the_lock_with_hashes_required(machine, shell):
|
||||||
|
machine.standard()
|
||||||
|
assert machine.run(shell=shell).returncode == 0
|
||||||
|
(line,) = [line for line in machine.pip_log.read_text(encoding="utf-8").splitlines() if "install" in line]
|
||||||
|
assert "--require-hashes" in line.split()
|
||||||
|
assert line.endswith(str(machine.tools / "requirements.lock"))
|
||||||
|
stamp = (machine.tools / ".venv" / ".chemenu-requirements.sha256").read_text(encoding="utf-8").strip()
|
||||||
|
assert stamp == hashlib.sha256((machine.tools / "requirements.lock").read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_a_changed_lock_is_installed_on_the_next_run_and_only_then(machine, shell):
|
||||||
|
"""An instance whose tools/ was replaced by a newer stack moves its venv to the new lock -
|
||||||
|
pip installs `==` pins whichever way they point - with no step of its own."""
|
||||||
|
machine.standard()
|
||||||
|
assert machine.run(shell=shell).returncode == 0
|
||||||
|
assert machine.run(shell=shell).returncode == 0
|
||||||
|
(machine.tools / "requirements.lock").write_text("pyyaml==6.0.2 --hash=sha256:11\n", encoding="utf-8")
|
||||||
|
assert machine.run(shell=shell).returncode == 0
|
||||||
|
installs = [line for line in machine.pip_log.read_text(encoding="utf-8").splitlines() if "install" in line]
|
||||||
|
assert len(installs) == 2 and all("--require-hashes" in line for line in installs)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_a_stamp_of_the_old_requirements_txt_reinstalls_from_the_lock(machine, shell):
|
||||||
|
"""Before #245 the stamp hashed requirements.txt; an instance carrying one installs the
|
||||||
|
lock on its first run under the new stack."""
|
||||||
|
machine.standard()
|
||||||
|
machine.existing_venv("3.13")
|
||||||
|
(machine.tools / ".venv" / ".chemenu-requirements.sha256").write_text(
|
||||||
|
hashlib.sha256(b"PyYAML\n").hexdigest() + "\n", encoding="utf-8")
|
||||||
|
assert machine.run(shell=shell).returncode == 0
|
||||||
|
assert "requirements.lock" in machine.pip_log.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_a_venv_outside_the_span_is_built_again_on_the_python_found(machine, shell):
|
||||||
|
machine.standard()
|
||||||
|
old = machine.existing_venv("3.12")
|
||||||
|
(old.parent.parent / ".chemenu-requirements.sha256").write_text(
|
||||||
|
hashlib.sha256((machine.tools / "requirements.lock").read_bytes()).hexdigest() + "\n", encoding="utf-8")
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert any(line.split()[:3] == ["REBUILD", "venv", "3.12"] for line in result.stdout.splitlines())
|
||||||
|
probe = subprocess.run([str(old), "-c", "import sys"], capture_output=True, text=True,
|
||||||
|
env={"PATH": os.pathsep.join(str(d) for d in machine.path_dirs)})
|
||||||
|
assert probe.stdout.splitlines()[0] == "3.13"
|
||||||
|
# --clear took the old stamp with it, so the lock went in again.
|
||||||
|
assert "requirements.lock" in machine.pip_log.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
|
def test_a_venv_inside_the_span_stays_when_the_python_found_is_another_version(machine, shell):
|
||||||
|
machine.standard()
|
||||||
|
kept = machine.existing_venv("3.14")
|
||||||
|
before = kept.read_bytes()
|
||||||
|
result = machine.run(shell=shell)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert "REBUILD" not in result.stdout
|
||||||
|
assert kept.read_bytes() == before
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("shell", SHELLS)
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
def test_invalid_set_path_writes_nothing(machine, shell):
|
def test_invalid_set_path_writes_nothing(machine, shell):
|
||||||
machine.standard()
|
machine.standard()
|
||||||
@@ -345,7 +522,7 @@ def _browser_lines(machine) -> list[str]:
|
|||||||
@pytest.mark.parametrize("shell", SHELLS)
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
def test_without_with_browser_nothing_of_the_component_is_installed(machine, shell):
|
def test_without_with_browser_nothing_of_the_component_is_installed(machine, shell):
|
||||||
machine.standard()
|
machine.standard()
|
||||||
(machine.tools / "requirements-browser.txt").write_text("playwright\n", encoding="utf-8")
|
(machine.tools / "requirements-browser.lock").write_text("playwright\n", encoding="utf-8")
|
||||||
result = machine.run(shell=shell)
|
result = machine.run(shell=shell)
|
||||||
assert result.returncode == 0, result.stdout + result.stderr
|
assert result.returncode == 0, result.stdout + result.stderr
|
||||||
assert _browser_lines(machine) == []
|
assert _browser_lines(machine) == []
|
||||||
@@ -355,19 +532,19 @@ def test_without_with_browser_nothing_of_the_component_is_installed(machine, she
|
|||||||
@pytest.mark.parametrize("shell", SHELLS)
|
@pytest.mark.parametrize("shell", SHELLS)
|
||||||
def test_with_browser_installs_the_component_into_the_venv_and_keeps_it(machine, shell):
|
def test_with_browser_installs_the_component_into_the_venv_and_keeps_it(machine, shell):
|
||||||
machine.standard()
|
machine.standard()
|
||||||
(machine.tools / "requirements-browser.txt").write_text("playwright\n", encoding="utf-8")
|
(machine.tools / "requirements-browser.lock").write_text("playwright\n", encoding="utf-8")
|
||||||
result = machine.run("--with", "browser", shell=shell)
|
result = machine.run("--with", "browser", shell=shell)
|
||||||
assert result.returncode == 0, result.stdout + result.stderr
|
assert result.returncode == 0, result.stdout + result.stderr
|
||||||
venv = machine.tools / ".venv"
|
venv = machine.tools / ".venv"
|
||||||
lines = _browser_lines(machine)
|
lines = _browser_lines(machine)
|
||||||
assert any("-r" in line and line.endswith("requirements-browser.txt") for line in lines)
|
assert any("-r" in line and line.endswith("requirements-browser.lock") for line in lines)
|
||||||
assert f"playwright install chromium into {venv / 'ms-playwright'}" in lines
|
assert f"playwright install chromium into {venv / 'ms-playwright'}" in lines
|
||||||
assert any(line.split()[:2] == ["OK", "browser"] for line in result.stdout.splitlines())
|
assert any(line.split()[:2] == ["OK", "browser"] for line in result.stdout.splitlines())
|
||||||
assert (venv / ".chemenu-browser.sha256").is_file()
|
assert (venv / ".chemenu-browser.sha256").is_file()
|
||||||
# A later plain run keeps it, and reinstalls only when its requirements change.
|
# A later plain run keeps it, and reinstalls only when its requirements change.
|
||||||
assert machine.run(shell=shell).returncode == 0
|
assert machine.run(shell=shell).returncode == 0
|
||||||
assert len(_browser_lines(machine)) == 2
|
assert len(_browser_lines(machine)) == 2
|
||||||
(machine.tools / "requirements-browser.txt").write_text("playwright>=2\n", encoding="utf-8")
|
(machine.tools / "requirements-browser.lock").write_text("playwright>=2\n", encoding="utf-8")
|
||||||
result = machine.run(shell=shell)
|
result = machine.run(shell=shell)
|
||||||
assert result.returncode == 0 and len(_browser_lines(machine)) == 4
|
assert result.returncode == 0 and len(_browser_lines(machine)) == 4
|
||||||
assert "OK browser" in result.stdout
|
assert "OK browser" in result.stdout
|
||||||
@@ -377,7 +554,7 @@ def test_with_browser_installs_the_component_into_the_venv_and_keeps_it(machine,
|
|||||||
@pytest.mark.parametrize("failing", ["FAKE_BROWSER_PIP_FAIL", "FAKE_PLAYWRIGHT_FAIL"])
|
@pytest.mark.parametrize("failing", ["FAKE_BROWSER_PIP_FAIL", "FAKE_PLAYWRIGHT_FAIL"])
|
||||||
def test_a_component_that_fails_stops_but_leaves_wikitool_working(machine, shell, failing):
|
def test_a_component_that_fails_stops_but_leaves_wikitool_working(machine, shell, failing):
|
||||||
machine.standard()
|
machine.standard()
|
||||||
(machine.tools / "requirements-browser.txt").write_text("playwright\n", encoding="utf-8")
|
(machine.tools / "requirements-browser.lock").write_text("playwright\n", encoding="utf-8")
|
||||||
machine.extra_env[failing] = "1"
|
machine.extra_env[failing] = "1"
|
||||||
result = machine.run("--with=browser", shell=shell)
|
result = machine.run("--with=browser", shell=shell)
|
||||||
assert result.returncode == 42
|
assert result.returncode == 42
|
||||||
@@ -513,7 +690,7 @@ def build_release(base: Path, *, limit: int | None = None, tops: tuple[str, ...]
|
|||||||
(stage / top / "tools").mkdir(parents=True)
|
(stage / top / "tools").mkdir(parents=True)
|
||||||
for file in STACK_FILES:
|
for file in STACK_FILES:
|
||||||
shutil.copy2(TOOLS / file, stage / top / "tools" / file)
|
shutil.copy2(TOOLS / file, stage / top / "tools" / file)
|
||||||
(stage / top / "tools" / "requirements.txt").write_text("PyYAML\n", encoding="utf-8")
|
(stage / top / "tools" / "requirements.lock").write_text("pyyaml==6.0.3 --hash=sha256:00\n", encoding="utf-8")
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
manifest = stage / top / "tools" / "prerequisites.txt"
|
manifest = stage / top / "tools" / "prerequisites.txt"
|
||||||
manifest.write_text(
|
manifest.write_text(
|
||||||
@@ -724,7 +901,7 @@ def test_set_and_the_exit_code_pass_through_to_the_tree_copy(asset, shell):
|
|||||||
# moment; with :partial each failed attempt has already moved one file of the entry up,
|
# moment; with :partial each failed attempt has already moved one file of the entry up,
|
||||||
# which is what a move that falls back to copying and deleting leaves behind.
|
# which is what a move that falls back to copying and deleting leaves behind.
|
||||||
|
|
||||||
ARCHIVED_TOOLS = sorted((*STACK_FILES, "requirements.txt"))
|
ARCHIVED_TOOLS = sorted((*STACK_FILES, "requirements.lock"))
|
||||||
MOVE_ATTEMPTS = 8
|
MOVE_ATTEMPTS = 8
|
||||||
|
|
||||||
|
|
||||||
@@ -1035,7 +1212,7 @@ def test_git_and_rg_start_from_the_recorded_paths_not_from_path(tmp_path, monkey
|
|||||||
subprocess.run(["git", "config", "user.name", "Recorded Git"], cwd=repo, check=True)
|
subprocess.run(["git", "config", "user.name", "Recorded Git"], cwd=repo, check=True)
|
||||||
(repo / "kb").mkdir()
|
(repo / "kb").mkdir()
|
||||||
(repo / "kb" / "Page.md").write_text("---\ntitle: Page\n---\nkingfisher\n", encoding="utf-8")
|
(repo / "kb" / "Page.md").write_text("---\ntitle: Page\n---\nkingfisher\n", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", repo)
|
set_config_path(monkeypatch, "ROOT", repo)
|
||||||
monkeypatch.setenv("PATH", str(tmp_path / "empty"))
|
monkeypatch.setenv("PATH", str(tmp_path / "empty"))
|
||||||
|
|
||||||
assert config.default_author() == "Recorded Git"
|
assert config.default_author() == "Recorded Git"
|
||||||
|
|||||||
@@ -142,6 +142,86 @@ def test_python_too_old_stops(machine):
|
|||||||
assert_guidance(result.stdout, "Python 3.9 is too old")
|
assert_guidance(result.stdout, "Python 3.9 is too old")
|
||||||
|
|
||||||
|
|
||||||
|
# --- the Python span and the lock (Gitea #245) ---------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("version, status", [("3.12", "TOO_OLD"), ("3.13", "OK"),
|
||||||
|
("3.14", "OK"), ("3.15", "TOO_NEW")])
|
||||||
|
def test_both_ends_of_the_span_are_inclusive_and_only_they(machine, version, status):
|
||||||
|
machine.extra_env["FAKE_PY_VERSION"] = version
|
||||||
|
result = _preflight(machine)
|
||||||
|
assert any(line.split()[:2] == [status, "python"] for line in result.stdout.splitlines()), result.stdout
|
||||||
|
if status == "OK":
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
return
|
||||||
|
assert result.returncode == 42
|
||||||
|
word = "old" if status == "TOO_OLD" else "new"
|
||||||
|
assert_guidance(result.stdout, f"Python {version} is too {word} - this stack needs Python 3.13 to 3.14",
|
||||||
|
"--set python=")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("default", ["3.12", "3.15"])
|
||||||
|
def test_a_versioned_python_of_the_span_is_taken_when_the_plain_one_lies_outside(machine, default):
|
||||||
|
machine.python("python3", version=default)
|
||||||
|
versioned = machine.python("python3.13", version="3.13", where=machine.base / "elsewhere")
|
||||||
|
machine.path_dirs.append(versioned.parent)
|
||||||
|
result = _preflight(machine)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert machine.recorded()["tools"]["python"] == str(versioned)
|
||||||
|
|
||||||
|
|
||||||
|
def test_on_windows_the_launcher_is_asked_for_a_version_of_the_span(tmp_path):
|
||||||
|
machine = Machine(tmp_path.resolve()).standard(pwsh=True)
|
||||||
|
machine.extra_env.update(WINDOWS, FAKE_PY_VERSION="3.15")
|
||||||
|
installed = machine.py_launcher("3.15", ("3.13", "3.14"))
|
||||||
|
result = _preflight(machine)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert machine.recorded()["tools"]["python"] == str(installed["3.14"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_on_linux_an_out_of_span_python_names_the_distribution_and_set_but_no_other_tool(machine):
|
||||||
|
machine.stub("apt-get", "#!/bin/sh\nexit 0\n")
|
||||||
|
machine.extra_env.update(CHEMENU_PREFLIGHT_PLATFORM="linux", FAKE_PY_VERSION="3.15")
|
||||||
|
result = _preflight(machine)
|
||||||
|
assert result.returncode == 42
|
||||||
|
assert_guidance(result.stdout, "sudo apt install python3 python3-venv",
|
||||||
|
"package source of this Linux distribution may offer no Python 3.13 to 3.14",
|
||||||
|
"--set python=<full path to python>")
|
||||||
|
fix = result.stdout.split("Fix:", 1)[1]
|
||||||
|
for other in ("uv ", "pyenv", "deadsnakes", "conda", "ppa:"):
|
||||||
|
assert other not in fix
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_venv_installs_the_lock_with_hashes_required_and_follows_a_changed_one(machine):
|
||||||
|
assert _preflight(machine).returncode == 0
|
||||||
|
assert _preflight(machine).returncode == 0
|
||||||
|
(machine.tools / "requirements.lock").write_text("pyyaml==6.0.2 --hash=sha256:11\n", encoding="utf-8")
|
||||||
|
assert _preflight(machine).returncode == 0
|
||||||
|
installs = [line for line in machine.pip_log.read_text(encoding="utf-8").splitlines() if "install" in line]
|
||||||
|
assert len(installs) == 2
|
||||||
|
assert all("--require-hashes" in line.split() and line.endswith("requirements.lock") for line in installs)
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_venv_outside_the_span_is_built_again_on_the_python_found(machine):
|
||||||
|
old = machine.existing_venv("3.12")
|
||||||
|
result = _preflight(machine)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert any(line.split()[:3] == ["REBUILD", "venv", "3.12"] for line in result.stdout.splitlines())
|
||||||
|
probe = subprocess.run([str(old), "-c", "import sys"], capture_output=True, text=True,
|
||||||
|
env={"PATH": os.pathsep.join(str(d) for d in machine.path_dirs)})
|
||||||
|
assert probe.stdout.splitlines()[0] == "3.13"
|
||||||
|
assert "requirements.lock" in machine.pip_log.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_venv_inside_the_span_stays_when_the_python_found_is_another_version(machine):
|
||||||
|
kept = machine.existing_venv("3.14")
|
||||||
|
before = kept.read_bytes()
|
||||||
|
result = _preflight(machine)
|
||||||
|
assert result.returncode == 0, result.stdout
|
||||||
|
assert "REBUILD" not in result.stdout
|
||||||
|
assert kept.read_bytes() == before
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_set_path_writes_nothing(machine):
|
def test_invalid_set_path_writes_nothing(machine):
|
||||||
result = _preflight(machine, "--set", f"rg={machine.base / 'nowhere' / 'rg'}")
|
result = _preflight(machine, "--set", f"rg={machine.base / 'nowhere' / 'rg'}")
|
||||||
assert result.returncode == 42
|
assert result.returncode == 42
|
||||||
@@ -191,7 +271,7 @@ def _browser_lines(machine: Machine) -> list[str]:
|
|||||||
|
|
||||||
|
|
||||||
def test_with_browser_installs_the_component_and_a_plain_run_keeps_it(machine):
|
def test_with_browser_installs_the_component_and_a_plain_run_keeps_it(machine):
|
||||||
(machine.tools / "requirements-browser.txt").write_text("playwright\n", encoding="utf-8")
|
(machine.tools / "requirements-browser.lock").write_text("playwright\n", encoding="utf-8")
|
||||||
assert _preflight(machine).returncode == 0
|
assert _preflight(machine).returncode == 0
|
||||||
assert _browser_lines(machine) == []
|
assert _browser_lines(machine) == []
|
||||||
result = _preflight(machine, "--with", "browser")
|
result = _preflight(machine, "--with", "browser")
|
||||||
@@ -205,7 +285,7 @@ def test_with_browser_installs_the_component_and_a_plain_run_keeps_it(machine):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("failing", ["FAKE_BROWSER_PIP_FAIL", "FAKE_PLAYWRIGHT_FAIL"])
|
@pytest.mark.parametrize("failing", ["FAKE_BROWSER_PIP_FAIL", "FAKE_PLAYWRIGHT_FAIL"])
|
||||||
def test_a_component_that_fails_stops_but_leaves_wikitool_working(machine, failing):
|
def test_a_component_that_fails_stops_but_leaves_wikitool_working(machine, failing):
|
||||||
(machine.tools / "requirements-browser.txt").write_text("playwright\n", encoding="utf-8")
|
(machine.tools / "requirements-browser.lock").write_text("playwright\n", encoding="utf-8")
|
||||||
machine.extra_env[failing] = "1"
|
machine.extra_env[failing] = "1"
|
||||||
result = _preflight(machine, "--with=browser")
|
result = _preflight(machine, "--with=browser")
|
||||||
assert result.returncode == 42
|
assert result.returncode == 42
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from chemenu.provenance import (
|
|||||||
uncovered_raw_files,
|
uncovered_raw_files,
|
||||||
)
|
)
|
||||||
from chemenu.kb_scan import load_kb_pages
|
from chemenu.kb_scan import load_kb_pages
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -247,7 +248,7 @@ def test_source_pages_by_raw_file_uses_legacy_source_fallback(kb_dir, raw_dir):
|
|||||||
def test_uncovered_raw_files_detects_ingested_gap(kb_dir, raw_dir, monkeypatch):
|
def test_uncovered_raw_files_detects_ingested_gap(kb_dir, raw_dir, monkeypatch):
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
pages = load_kb_pages(kb_dir)
|
pages = load_kb_pages(kb_dir)
|
||||||
uncovered = uncovered_raw_files(raw_dir, pages)
|
uncovered = uncovered_raw_files(raw_dir, pages)
|
||||||
assert "raw/notes/Uningested.md" in uncovered
|
assert "raw/notes/Uningested.md" in uncovered
|
||||||
@@ -257,7 +258,7 @@ def test_uncovered_raw_files_detects_ingested_gap(kb_dir, raw_dir, monkeypatch):
|
|||||||
def test_broken_raw_refs_detects_dangling_path(kb_dir, raw_dir, monkeypatch):
|
def test_broken_raw_refs_detects_dangling_path(kb_dir, raw_dir, monkeypatch):
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
write_page(
|
write_page(
|
||||||
kb_dir / "sources/Source - Ghost.md",
|
kb_dir / "sources/Source - Ghost.md",
|
||||||
{
|
{
|
||||||
@@ -347,9 +348,9 @@ def test_sources_coverage_command_reports_uncovered_file(kb_dir, raw_dir, monkey
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, ["sources", "coverage", "--json"])
|
result = runner.invoke(app, ["sources", "coverage", "--json"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -360,9 +361,9 @@ def test_sources_trace_by_raw_and_by_page(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
write_page(
|
write_page(
|
||||||
kb_dir / "entities/systems/aurora.md",
|
kb_dir / "entities/systems/aurora.md",
|
||||||
@@ -389,8 +390,8 @@ def test_new_source_with_multiple_raw_files(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
# This test is about raw_files:, not about authorship - but `new source`
|
# This test is about raw_files:, not about authorship - but `new source`
|
||||||
# refuses to stamp a placeholder author, and the fixture root has no git
|
# refuses to stamp a placeholder author, and the fixture root has no git
|
||||||
# identity. Naming one keeps the test off the runner's global git config.
|
# identity. Naming one keeps the test off the runner's global git config.
|
||||||
@@ -413,8 +414,8 @@ def test_new_source_rejects_nonexistent_raw_path(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, [
|
result = runner.invoke(app, [
|
||||||
"new", "source", "--name", "Bad", "--set", "raw_files=raw/notes/Nope.md",
|
"new", "source", "--name", "Bad", "--set", "raw_files=raw/notes/Nope.md",
|
||||||
@@ -426,8 +427,8 @@ def test_lint_flags_citation_not_in_frontmatter_sources(kb_dir, raw_dir, monkeyp
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
refs, block = _footnote_block(("Source - Aurora", None))
|
refs, block = _footnote_block(("Source - Aurora", None))
|
||||||
write_page(
|
write_page(
|
||||||
@@ -448,8 +449,8 @@ def test_lint_no_drift_when_source_declared(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
refs, block = _footnote_block(("Source - Aurora", None))
|
refs, block = _footnote_block(("Source - Aurora", None))
|
||||||
write_page(
|
write_page(
|
||||||
@@ -469,8 +470,8 @@ def test_lint_unmarked_provenance_flags_empty_sources_without_general(kb_dir, ra
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
report = run_lint(kb_dir)
|
report = run_lint(kb_dir)
|
||||||
# gdeploy in the base fixture has sources: [] and no provenance field at all.
|
# gdeploy in the base fixture has sources: [] and no provenance field at all.
|
||||||
assert "gdeploy" in report["unmarked_provenance"]
|
assert "gdeploy" in report["unmarked_provenance"]
|
||||||
@@ -480,8 +481,8 @@ def test_lint_does_not_flag_source_page_self_citation(kb_dir, raw_dir, monkeypat
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
refs, block = _footnote_block(("Source - Aurora", "Aurora.md"))
|
refs, block = _footnote_block(("Source - Aurora", "Aurora.md"))
|
||||||
write_page(
|
write_page(
|
||||||
|
|||||||
@@ -0,0 +1,155 @@
|
|||||||
|
"""`raw clarify` and the companion file's way through `raw pending` and `raw accept` (Gitea #241)."""
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import typer
|
||||||
|
|
||||||
|
from chemenu.commands.raw.accept import raw_accept_command
|
||||||
|
from chemenu.commands.raw.clarify import raw_clarify_command
|
||||||
|
from chemenu.commands.raw.pending import raw_pending_command
|
||||||
|
from chemenu.frontmatter_io import write_page
|
||||||
|
|
||||||
|
|
||||||
|
def _shard() -> str:
|
||||||
|
today = datetime.date.today()
|
||||||
|
return f"raw/{today.year:04d}/{today.month:02d}"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def tree(kb_dir):
|
||||||
|
root = kb_dir.parent
|
||||||
|
(root / "raw").mkdir(parents=True)
|
||||||
|
(root / "incoming").mkdir(parents=True, exist_ok=True)
|
||||||
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
def _clarify(entry=None, items=("Termindatum: 2026-11-12",), page=None):
|
||||||
|
return raw_clarify_command(entry=entry, item=list(items), page=page)
|
||||||
|
|
||||||
|
|
||||||
|
def _accept(*files, page=None, fidelity="verbatim", authority="reporting"):
|
||||||
|
return raw_accept_command(
|
||||||
|
files=list(files), fidelity=fidelity, authority=authority, page=page,
|
||||||
|
replaces=None, dry_run=False, replaces_bundle=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _source(kb_dir, title, raw_files, fidelity="verbatim", authority="reporting"):
|
||||||
|
write_page(kb_dir / "sources" / f"{title}.md", {
|
||||||
|
"type": "types/source.md", "source_type": "document", "author": "T",
|
||||||
|
"raw_files": list(raw_files), "date": "2026-09-01", "fidelity": fidelity,
|
||||||
|
"authority": authority, "tags": [], "entities": [], "concepts": [],
|
||||||
|
"summary": "Test source.",
|
||||||
|
}, f"\n# {title}\n\n## Summary\n\nTest.\n")
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_writes_companion_file_with_fixed_header_and_one_item(tree):
|
||||||
|
(tree / "incoming/meeting.vtt").write_text("WEBVTT\n", encoding="utf-8")
|
||||||
|
_clarify(tree / "incoming/meeting.vtt")
|
||||||
|
text = (tree / "incoming/meeting.clarifications.md").read_text(encoding="utf-8")
|
||||||
|
assert "kind: clarifications" in text
|
||||||
|
assert "meeting.vtt" in text
|
||||||
|
assert f"answered: {datetime.date.today().isoformat()}" in text
|
||||||
|
assert [l for l in text.splitlines() if l.startswith("- ")] == ["- Termindatum: 2026-11-12"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_without_item_exits_1_and_writes_nothing(tree):
|
||||||
|
(tree / "incoming/meeting.vtt").write_text("WEBVTT\n", encoding="utf-8")
|
||||||
|
with pytest.raises(typer.Exit) as exc:
|
||||||
|
_clarify(tree / "incoming/meeting.vtt", items=())
|
||||||
|
assert exc.value.exit_code == 1
|
||||||
|
assert sorted(p.name for p in (tree / "incoming").iterdir()) == ["meeting.vtt"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_rejects_multiline_item_and_both_or_neither_target(tree):
|
||||||
|
(tree / "incoming/m.vtt").write_text("x", encoding="utf-8")
|
||||||
|
with pytest.raises(typer.Exit):
|
||||||
|
_clarify(tree / "incoming/m.vtt", items=("a\nb",))
|
||||||
|
with pytest.raises(typer.Exit):
|
||||||
|
_clarify(None)
|
||||||
|
with pytest.raises(typer.Exit):
|
||||||
|
_clarify(tree / "incoming/m.vtt", page="X")
|
||||||
|
assert [p.name for p in (tree / "incoming").iterdir()] == ["m.vtt"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_folder_and_never_overwrites(tree):
|
||||||
|
folder = tree / "incoming/x"
|
||||||
|
folder.mkdir()
|
||||||
|
(folder / "a.md").write_text("a", encoding="utf-8")
|
||||||
|
_clarify(folder)
|
||||||
|
first = (folder / "clarifications.md").read_text(encoding="utf-8")
|
||||||
|
_clarify(folder, items=("zweite",))
|
||||||
|
assert (folder / "clarifications.md").read_text(encoding="utf-8") == first
|
||||||
|
assert "- zweite" in (folder / "clarifications-2.md").read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_file_name_taken_gets_counter(tree):
|
||||||
|
(tree / "incoming/m.vtt").write_text("x", encoding="utf-8")
|
||||||
|
_clarify(tree / "incoming/m.vtt")
|
||||||
|
_clarify(tree / "incoming/m.vtt", items=("b",))
|
||||||
|
assert (tree / "incoming/m.clarifications-2.md").is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_pending_lists_original_and_companion_as_one_bundle(tree, capsys):
|
||||||
|
(tree / "incoming/meeting.vtt").write_text("WEBVTT\n", encoding="utf-8")
|
||||||
|
_clarify(tree / "incoming/meeting.vtt")
|
||||||
|
capsys.readouterr()
|
||||||
|
raw_pending_command(json_out=True)
|
||||||
|
candidates = json.loads(capsys.readouterr().out)
|
||||||
|
assert len(candidates) == 1
|
||||||
|
assert candidates[0]["kind"] == "bundle" and candidates[0]["files"] == 2
|
||||||
|
assert candidates[0]["acceptable"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_accept_names_bundle_after_the_original_whatever_the_order(tree):
|
||||||
|
(tree / "incoming/meeting.vtt").write_text("WEBVTT\n", encoding="utf-8")
|
||||||
|
_clarify(tree / "incoming/meeting.vtt")
|
||||||
|
_accept(tree / "incoming/meeting.clarifications.md", tree / "incoming/meeting.vtt")
|
||||||
|
bundle = tree / _shard() / "meeting"
|
||||||
|
assert (bundle / "meeting.vtt").is_file()
|
||||||
|
assert (bundle / "meeting.clarifications.md").is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_accept_refuses_companion_without_original_and_moves_nothing(tree):
|
||||||
|
(tree / "incoming/meeting.vtt").write_text("WEBVTT\n", encoding="utf-8")
|
||||||
|
_clarify(tree / "incoming/meeting.vtt")
|
||||||
|
(tree / "incoming/meeting.vtt").unlink()
|
||||||
|
with pytest.raises(typer.Exit) as exc:
|
||||||
|
_accept(tree / "incoming/meeting.clarifications.md")
|
||||||
|
assert exc.value.exit_code == 1
|
||||||
|
assert (tree / "incoming/meeting.clarifications.md").is_file()
|
||||||
|
assert not (tree / _shard()).exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_page_writes_file_and_prints_accept_line_that_builds_bundle(tree, kb_dir, capsys):
|
||||||
|
raw = tree / _shard()
|
||||||
|
raw.mkdir(parents=True)
|
||||||
|
(raw / "meeting.vtt").write_text("WEBVTT\n", encoding="utf-8")
|
||||||
|
_source(kb_dir, "Source - Meeting", [f"{_shard()}/meeting.vtt"])
|
||||||
|
_clarify(page="Source - Meeting", items=("Projekt: Alpha",))
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
assert 'raw accept --page "Source - Meeting" --fidelity verbatim --authority reporting' in out
|
||||||
|
assert "incoming/meeting.clarifications.md" in out
|
||||||
|
_accept(tree / "incoming/meeting.clarifications.md", page="Source - Meeting")
|
||||||
|
assert (raw / "meeting/meeting.vtt").is_file()
|
||||||
|
assert (raw / "meeting/meeting.clarifications.md").is_file()
|
||||||
|
assert not (raw / "meeting.vtt").exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_clarify_page_in_existing_bundle_counts_up(tree, kb_dir):
|
||||||
|
bundle = tree / _shard() / "meeting"
|
||||||
|
bundle.mkdir(parents=True)
|
||||||
|
(bundle / "meeting.vtt").write_text("x", encoding="utf-8")
|
||||||
|
(bundle / "meeting.clarifications.md").write_text("x", encoding="utf-8")
|
||||||
|
_source(kb_dir, "Source - Meeting", [f"{_shard()}/meeting/meeting.vtt", f"{_shard()}/meeting/meeting.clarifications.md"])
|
||||||
|
_clarify(page="Source - Meeting")
|
||||||
|
assert (tree / "incoming/meeting.clarifications-2.md").is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_pdf_with_only_a_companion_still_warns_about_missing_derived_text(tree, capsys):
|
||||||
|
(tree / "incoming/scan.pdf").write_bytes(b"%PDF-1.4\n")
|
||||||
|
_clarify(tree / "incoming/scan.pdf")
|
||||||
|
capsys.readouterr()
|
||||||
|
_accept(tree / "incoming/scan.pdf", tree / "incoming/scan.clarifications.md")
|
||||||
|
assert "has a text filter and no derived .md" in capsys.readouterr().out
|
||||||
@@ -9,6 +9,7 @@ from chemenu import version as version_mod
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.commands import dist_cmd, docs_verify, instructions_cmd
|
from chemenu.commands import dist_cmd, docs_verify, instructions_cmd
|
||||||
from chemenu.type_resolver import resolver
|
from chemenu.type_resolver import resolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ def exported_instance(tmp_path, monkeypatch):
|
|||||||
instance may: a type-spec of its own making, and a skill of its own."""
|
instance may: a type-spec of its own making, and a skill of its own."""
|
||||||
target = tmp_path / "instance"
|
target = tmp_path / "instance"
|
||||||
dist_cmd.run_export(target)
|
dist_cmd.run_export(target)
|
||||||
monkeypatch.setattr(config, "ROOT", target)
|
set_config_path(monkeypatch, "ROOT", target)
|
||||||
monkeypatch.setattr(resolver, "_repo_root", target)
|
monkeypatch.setattr(resolver, "_repo_root", target)
|
||||||
for template in sorted((target / "types").glob("*.template")):
|
for template in sorted((target / "types").glob("*.template")):
|
||||||
template.rename(template.with_suffix(""))
|
template.rename(template.with_suffix(""))
|
||||||
@@ -267,7 +268,7 @@ def _page_type(description: str = "A fixture type.") -> reference_doc.PageType:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def tree(tmp_path, monkeypatch):
|
def tree(tmp_path, monkeypatch):
|
||||||
real_root = config.ROOT
|
real_root = config.ROOT
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
records = {"frobnicate": _record("frobnicate"), "gate keep": _record("gate keep", ("mass-update",))}
|
records = {"frobnicate": _record("frobnicate"), "gate keep": _record("gate keep", ("mass-update",))}
|
||||||
monkeypatch.setattr(cli_contract, "all_records", lambda: dict(records))
|
monkeypatch.setattr(cli_contract, "all_records", lambda: dict(records))
|
||||||
monkeypatch.setattr(cli_contract, "GROUPS", GROUPS)
|
monkeypatch.setattr(cli_contract, "GROUPS", GROUPS)
|
||||||
@@ -408,7 +409,7 @@ def test_a_page_without_a_group_fails(tree):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_tree_without_docs_passes(tmp_path, monkeypatch):
|
def test_a_tree_without_docs_passes(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert docs_verify.check_reference_regions() == []
|
assert docs_verify.check_reference_regions() == []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from chemenu.cli import app
|
|||||||
from chemenu.commands.run_budget import is_exempt
|
from chemenu.commands.run_budget import is_exempt
|
||||||
from chemenu.errors import ValidationError
|
from chemenu.errors import ValidationError
|
||||||
from chemenu.frontmatter_io import write_page
|
from chemenu.frontmatter_io import write_page
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs, write_settings
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs, write_settings
|
||||||
from chemenu.review import (
|
from chemenu.review import (
|
||||||
CHECK_NO_OPEN_LOOP,
|
CHECK_NO_OPEN_LOOP,
|
||||||
CHECK_PROJECT_AGE_UNKNOWN,
|
CHECK_PROJECT_AGE_UNKNOWN,
|
||||||
@@ -322,7 +322,7 @@ def test_d3_caldav_project_with_no_determinable_created_date_is_its_own_finding(
|
|||||||
def test_d3_text_and_json_output_agree(tmp_path, monkeypatch):
|
def test_d3_text_and_json_output_agree(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
projects = {"p1": {"id": "p1", "title": "Kueche renovieren", "created": _ms(2026, 1, 1),
|
projects = {"p1": {"id": "p1", "title": "Kueche renovieren", "created": _ms(2026, 1, 1),
|
||||||
"taskIds": ["t1"], "backlogTaskIds": []}}
|
"taskIds": ["t1"], "backlogTaskIds": []}}
|
||||||
@@ -463,7 +463,7 @@ def test_unreachable_provider_skips_the_project_list_checks_but_not_someday(tmp_
|
|||||||
def test_cli_no_provider_exits_1_with_a_clear_message(tmp_path, monkeypatch):
|
def test_cli_no_provider_exits_1_with_a_clear_message(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
||||||
result = runner.invoke(app, ["review"])
|
result = runner.invoke(app, ["review"])
|
||||||
@@ -474,7 +474,7 @@ def test_cli_no_provider_exits_1_with_a_clear_message(tmp_path, monkeypatch):
|
|||||||
def test_cli_incomplete_report_exits_1_and_still_prints(tmp_path, monkeypatch):
|
def test_cli_incomplete_report_exits_1_and_still_prints(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
_write_tasks_config(tmp_path, tmp_path / "does-not-exist-dir")
|
_write_tasks_config(tmp_path, tmp_path / "does-not-exist-dir")
|
||||||
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
||||||
@@ -491,7 +491,7 @@ def test_cli_json_and_text_agree_on_findings(tmp_path, monkeypatch):
|
|||||||
against the CLI's own `--json`."""
|
against the CLI's own `--json`."""
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
||||||
"taskIds": [], "backlogTaskIds": []}}
|
"taskIds": [], "backlogTaskIds": []}}
|
||||||
@@ -539,7 +539,7 @@ def test_report_names_its_source_and_the_snapshot_age(tmp_path):
|
|||||||
def test_cli_shows_the_source_in_both_render_forms(tmp_path, monkeypatch):
|
def test_cli_shows_the_source_in_both_render_forms(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
||||||
"taskIds": [], "backlogTaskIds": []}}
|
"taskIds": [], "backlogTaskIds": []}}
|
||||||
@@ -579,7 +579,7 @@ def test_a_run_leaves_the_git_tree_untouched(tmp_path, monkeypatch):
|
|||||||
subprocess.run(["git", "add", "-A"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "add", "-A"], cwd=tmp_path, check=True)
|
||||||
subprocess.run(["git", "commit", "-q", "-m", "fixture"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "commit", "-q", "-m", "fixture"], cwd=tmp_path, check=True)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
before = subprocess.run(
|
before = subprocess.run(
|
||||||
["git", "status", "--porcelain"], cwd=tmp_path, capture_output=True, text=True, check=True
|
["git", "status", "--porcelain"], cwd=tmp_path, capture_output=True, text=True, check=True
|
||||||
@@ -594,7 +594,7 @@ def test_a_run_leaves_the_git_tree_untouched(tmp_path, monkeypatch):
|
|||||||
def test_cli_override_naming_a_missing_file_is_an_error_naming_the_path(tmp_path, monkeypatch):
|
def test_cli_override_naming_a_missing_file_is_an_error_naming_the_path(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setenv("WIKITOOL_TASKS_CONFIG", str(tmp_path / "gone.json"))
|
monkeypatch.setenv("WIKITOOL_TASKS_CONFIG", str(tmp_path / "gone.json"))
|
||||||
result = runner.invoke(app, ["review"])
|
result = runner.invoke(app, ["review"])
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ from chemenu.cli import app
|
|||||||
from chemenu.commands import _util, docs_verify, doctor
|
from chemenu.commands import _util, docs_verify, doctor
|
||||||
from chemenu.config_shapes import CHECKOUT, INSTANCE, SECRET, Field, Shape
|
from chemenu.config_shapes import CHECKOUT, INSTANCE, SECRET, Field, Shape
|
||||||
from chemenu.errors import ValidationError
|
from chemenu.errors import ValidationError
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ TRACKER = Shape(
|
|||||||
def root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
def root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
||||||
tree = tmp_path / "instance"
|
tree = tmp_path / "instance"
|
||||||
tree.mkdir()
|
tree.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tree)
|
set_config_path(monkeypatch, "ROOT", tree)
|
||||||
monkeypatch.setattr(config_shapes, "SETTINGS_SECTIONS", (TRACKER,))
|
monkeypatch.setattr(config_shapes, "SETTINGS_SECTIONS", (TRACKER,))
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import pytest
|
|||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
from chemenu.tests.conftest import write_settings
|
from chemenu.tests.conftest import set_config_path, write_settings
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ def _invoke(monkeypatch, kb_dir, args):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return runner.invoke(app, args)
|
return runner.invoke(app, args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from chemenu.telemetry import policy
|
from chemenu.telemetry import policy
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@@ -122,7 +123,7 @@ def test_the_env_override_is_always_live_even_with_a_cached_root(tmp_path, monke
|
|||||||
def test_resolve_defaults_to_config_root(tmp_path, monkeypatch):
|
def test_resolve_defaults_to_config_root(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
_stamp(tmp_path)
|
_stamp(tmp_path)
|
||||||
assert policy.resolve().enabled is False
|
assert policy.resolve().enabled is False
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from chemenu import blocks, toc
|
from chemenu import blocks, toc
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def _body(n_lines: int, sections: int) -> str:
|
def _body(n_lines: int, sections: int) -> str:
|
||||||
@@ -192,7 +193,7 @@ def test_target_files_takes_a_template_only_for_a_file_already_in_scope(tmp_path
|
|||||||
because `USER.md` itself is not reference material this region applies to."""
|
because `USER.md` itself is not reference material this region applies to."""
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "kb").mkdir()
|
(tmp_path / "kb").mkdir()
|
||||||
for name in ("kb/CONVENTIONS.md", "kb/CONVENTIONS.md.template", "USER.md.template"):
|
for name in ("kb/CONVENTIONS.md", "kb/CONVENTIONS.md.template", "USER.md.template"):
|
||||||
(tmp_path / name).write_text("# A file\n", encoding="utf-8")
|
(tmp_path / name).write_text("# A file\n", encoding="utf-8")
|
||||||
@@ -238,7 +239,7 @@ def test_target_files_leaves_out_subtype_templates(tmp_path, monkeypatch):
|
|||||||
shape, stays in."""
|
shape, stays in."""
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
types_dir = tmp_path / "types"
|
types_dir = tmp_path / "types"
|
||||||
types_dir.mkdir()
|
types_dir.mkdir()
|
||||||
long_body = _body(150, 6)
|
long_body = _body(150, 6)
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ from typer.testing import CliRunner
|
|||||||
from chemenu import config
|
from chemenu import config
|
||||||
from chemenu.commands.touch import touch_command
|
from chemenu.commands.touch import touch_command
|
||||||
from chemenu.frontmatter_io import read_page
|
from chemenu.frontmatter_io import read_page
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def touch_wiki(kb_dir, monkeypatch):
|
def touch_wiki(kb_dir, monkeypatch):
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return kb_dir
|
return kb_dir
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +192,7 @@ def test_confidence_base_flag_no_longer_exists(touch_wiki, monkeypatch):
|
|||||||
import chemenu.config as cfg
|
import chemenu.config as cfg
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(cfg, "KB_DIR", touch_wiki)
|
set_config_path(monkeypatch, "KB_DIR", touch_wiki)
|
||||||
result = runner.invoke(app, ["touch", "--page", "aurora", "--confidence-base", "0.9"])
|
result = runner.invoke(app, ["touch", "--page", "aurora", "--confidence-base", "0.9"])
|
||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
assert "confidence-base" in result.output.lower() or "no such option" in result.output.lower()
|
assert "confidence-base" in result.output.lower() or "no such option" in result.output.lower()
|
||||||
@@ -218,7 +219,7 @@ def test_set_validates_against_the_schema_before_writing(touch_wiki):
|
|||||||
def test_set_raw_files_checks_the_path_exists(touch_wiki, raw_dir, monkeypatch):
|
def test_set_raw_files_checks_the_path_exists(touch_wiki, raw_dir, monkeypatch):
|
||||||
"""`touch` writes this field now, so it owes the same filesystem check
|
"""`touch` writes this field now, so it owes the same filesystem check
|
||||||
`new` does - the schema cannot express it."""
|
`new` does - the schema cannot express it."""
|
||||||
monkeypatch.setattr(config, "ROOT", touch_wiki.parent)
|
set_config_path(monkeypatch, "ROOT", touch_wiki.parent)
|
||||||
with pytest.raises(typer.Exit):
|
with pytest.raises(typer.Exit):
|
||||||
_touch(page_title="Source - Aurora", set_fields=["raw_files=raw/notes/absent.md"])
|
_touch(page_title="Source - Aurora", set_fields=["raw_files=raw/notes/absent.md"])
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ def test_set_raw_files_checks_the_path_exists(touch_wiki, raw_dir, monkeypatch):
|
|||||||
def test_set_raw_files_accepts_an_existing_path_with_a_comma(touch_wiki, raw_dir, monkeypatch):
|
def test_set_raw_files_accepts_an_existing_path_with_a_comma(touch_wiki, raw_dir, monkeypatch):
|
||||||
"""The repair the whole issue started from: a raw file moved, and the page
|
"""The repair the whole issue started from: a raw file moved, and the page
|
||||||
pointing at it has to follow without anyone editing frontmatter."""
|
pointing at it has to follow without anyone editing frontmatter."""
|
||||||
monkeypatch.setattr(config, "ROOT", touch_wiki.parent)
|
set_config_path(monkeypatch, "ROOT", touch_wiki.parent)
|
||||||
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
||||||
_touch(
|
_touch(
|
||||||
page_title="Source - Aurora",
|
page_title="Source - Aurora",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from chemenu.commands.upload_cmd import (
|
|||||||
upload_reject_command,
|
upload_reject_command,
|
||||||
upload_show_command,
|
upload_show_command,
|
||||||
)
|
)
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
CONTENT = b"a test submission for the CLI layer\n"
|
CONTENT = b"a test submission for the CLI layer\n"
|
||||||
CONTENT_B64 = base64.b64encode(CONTENT).decode("ascii")
|
CONTENT_B64 = base64.b64encode(CONTENT).decode("ascii")
|
||||||
@@ -33,7 +34,7 @@ _CFG = upload.Channel(
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def root(tmp_path, monkeypatch):
|
def root(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "incoming").mkdir()
|
(tmp_path / "incoming").mkdir()
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import typer
|
|||||||
from chemenu import config, version as version_mod
|
from chemenu import config, version as version_mod
|
||||||
from chemenu.commands import version_cmd
|
from chemenu.commands import version_cmd
|
||||||
from chemenu.version import Version, VersionError
|
from chemenu.version import Version, VersionError
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
CHANGES_HEADER = "# Changelog\n\nPreamble.\n\n---\n\n"
|
CHANGES_HEADER = "# Changelog\n\nPreamble.\n\n---\n\n"
|
||||||
|
|
||||||
@@ -28,8 +29,8 @@ def tree(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
)
|
)
|
||||||
instructions = tmp_path / "instructions"
|
instructions = tmp_path / "instructions"
|
||||||
(instructions / "migrations").mkdir(parents=True)
|
(instructions / "migrations").mkdir(parents=True)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import typer
|
|||||||
|
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
from chemenu.commands import work_cmd
|
from chemenu.commands import work_cmd
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -12,9 +13,9 @@ def patched_work(tmp_path, monkeypatch):
|
|||||||
root = tmp_path
|
root = tmp_path
|
||||||
(root / "raw" / "documents" / "almanac").mkdir(parents=True)
|
(root / "raw" / "documents" / "almanac").mkdir(parents=True)
|
||||||
(root / "raw" / "documents" / "almanac" / "README.md").write_text("x", encoding="utf-8")
|
(root / "raw" / "documents" / "almanac" / "README.md").write_text("x", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", root / "raw")
|
set_config_path(monkeypatch, "RAW_DIR", root / "raw")
|
||||||
monkeypatch.setattr(config, "WORK_DIR", root / "work")
|
set_config_path(monkeypatch, "WORK_DIR", root / "work")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
"""Write the four lock files of tools/ from their source files - dev-only.
|
||||||
|
|
||||||
|
python3 tools/lock_requirements.py regenerate tools/*.lock
|
||||||
|
python3 tools/lock_requirements.py --out <dir> write them into <dir> instead
|
||||||
|
python3 tools/lock_requirements.py --exception <name>=<timestamp>
|
||||||
|
a security lift (see below)
|
||||||
|
|
||||||
|
Each `tools/requirements*.txt` names what the stack needs with lower bounds; its
|
||||||
|
`.lock` beside it names exact versions and SHA-256 hashes for everything that
|
||||||
|
resolves from it, transitive packages included. The preflight and CI install only
|
||||||
|
from the locks, with `pip install --require-hashes`. This script is the one way
|
||||||
|
a lock is written; the procedure around it - when to run it, the security lift,
|
||||||
|
how the result is checked - is instructions/dev/dependency-locks.md.
|
||||||
|
|
||||||
|
What every run does:
|
||||||
|
|
||||||
|
- resolves with `uv pip compile --universal --generate-hashes` (one file for
|
||||||
|
Linux, macOS and Windows), for the Python minimum in tools/prerequisites.txt;
|
||||||
|
- leaves out every file uploaded in the last COOLDOWN_DAYS days
|
||||||
|
(`--exclude-newer`): a compromised release is usually found and pulled within
|
||||||
|
hours to days, and a lock never takes one before that has had time to happen;
|
||||||
|
- resolves the locks in a chain, each constrained by the ones before it, so a
|
||||||
|
package that sits in two locks has the same version in both - all four end up
|
||||||
|
in one venv, and a later lock must not move a package an earlier one placed;
|
||||||
|
- carries every `--exclude-newer-package` exception from the current locks'
|
||||||
|
headers over while its timestamp is still inside the cooldown, and drops it
|
||||||
|
once the global cutoff has passed it. `--exception` adds a new one.
|
||||||
|
|
||||||
|
Needs `uv` on PATH (requirements-dev.lock carries it). An instance never runs
|
||||||
|
this: it ships no source of truth to resolve against, only the locks.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from datetime import datetime, timedelta, timezone
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
TOOLS = Path(__file__).resolve().parent
|
||||||
|
ROOT = TOOLS.parent
|
||||||
|
COOLDOWN_DAYS = 7
|
||||||
|
|
||||||
|
# Source file -> lock file, in the order they are resolved: each one is
|
||||||
|
# constrained by every lock above it.
|
||||||
|
CHAIN = (
|
||||||
|
("requirements.txt", "requirements.lock"),
|
||||||
|
("requirements-mcp.txt", "requirements-mcp.lock"),
|
||||||
|
("requirements-browser.txt", "requirements-browser.lock"),
|
||||||
|
("requirements-dev.txt", "requirements-dev.lock"),
|
||||||
|
)
|
||||||
|
|
||||||
|
EXCEPTION_RE = re.compile(r"--exclude-newer-package[ =]([A-Za-z0-9._-]+)=(\S+)")
|
||||||
|
CUTOFF_RE = re.compile(r"--exclude-newer[ =](\S+)")
|
||||||
|
|
||||||
|
|
||||||
|
def timestamp(moment: datetime) -> str:
|
||||||
|
return moment.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
|
|
||||||
|
def parse_timestamp(text: str) -> datetime:
|
||||||
|
return datetime.fromisoformat(text.replace("Z", "+00:00")).astimezone(timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
|
def header(lock: Path) -> str:
|
||||||
|
"""The command uv wrote into the lock's head, or '' for a missing file."""
|
||||||
|
if not lock.is_file():
|
||||||
|
return ""
|
||||||
|
lines = []
|
||||||
|
for line in lock.read_text(encoding="utf-8").splitlines():
|
||||||
|
if not line.startswith("#"):
|
||||||
|
break
|
||||||
|
lines.append(line)
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def cutoff_of(lock: Path) -> datetime | None:
|
||||||
|
found = CUTOFF_RE.search(header(lock))
|
||||||
|
return parse_timestamp(found.group(1)) if found else None
|
||||||
|
|
||||||
|
|
||||||
|
def exceptions_of(lock: Path) -> dict[str, datetime]:
|
||||||
|
return {name: parse_timestamp(stamp) for name, stamp in EXCEPTION_RE.findall(header(lock))}
|
||||||
|
|
||||||
|
|
||||||
|
def python_minimum() -> str:
|
||||||
|
for line in (TOOLS / "prerequisites.txt").read_text(encoding="utf-8").splitlines():
|
||||||
|
fields = line.split("|")
|
||||||
|
if fields[:2] == ["tool", "python"]:
|
||||||
|
return fields[2]
|
||||||
|
raise SystemExit("lock_requirements: tools/prerequisites.txt has no python line")
|
||||||
|
|
||||||
|
|
||||||
|
def carried_exceptions(cutoff: datetime) -> dict[str, datetime]:
|
||||||
|
"""Exceptions in the current locks still younger than the cutoff - the ones
|
||||||
|
without which the next resolution would fail rather than lower the package."""
|
||||||
|
carried: dict[str, datetime] = {}
|
||||||
|
for _, lock in CHAIN:
|
||||||
|
for name, stamp in exceptions_of(TOOLS / lock).items():
|
||||||
|
if stamp > cutoff:
|
||||||
|
carried[name] = max(stamp, carried.get(name, stamp))
|
||||||
|
return carried
|
||||||
|
|
||||||
|
|
||||||
|
def relative(path: Path) -> str:
|
||||||
|
try:
|
||||||
|
return path.relative_to(ROOT).as_posix()
|
||||||
|
except ValueError:
|
||||||
|
return str(path)
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str] | None = None) -> int:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__.split("\n\n", 1)[0])
|
||||||
|
parser.add_argument("--out", type=Path, help="write the locks here instead of tools/")
|
||||||
|
parser.add_argument("--exception", action="append", default=[], metavar="NAME=TIMESTAMP",
|
||||||
|
help="exempt one package from the cooldown up to TIMESTAMP (a security lift)")
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
uv = shutil.which("uv")
|
||||||
|
if not uv:
|
||||||
|
print("lock_requirements: uv is not on PATH - install tools/requirements-dev.lock, "
|
||||||
|
"or put uv on PATH another way", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
cutoff = datetime.now(timezone.utc).replace(microsecond=0) - timedelta(days=COOLDOWN_DAYS)
|
||||||
|
exceptions = carried_exceptions(cutoff)
|
||||||
|
for entry in args.exception:
|
||||||
|
name, sep, stamp = entry.partition("=")
|
||||||
|
if not sep or not name:
|
||||||
|
parser.error(f"--exception wants NAME=TIMESTAMP, got {entry!r}")
|
||||||
|
exceptions[name.lower()] = parse_timestamp(stamp)
|
||||||
|
|
||||||
|
out = (args.out or TOOLS).resolve()
|
||||||
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
done: list[Path] = []
|
||||||
|
for source, lock in CHAIN:
|
||||||
|
target = out / lock
|
||||||
|
command = [uv, "pip", "compile", relative(TOOLS / source)]
|
||||||
|
for previous in done:
|
||||||
|
command += ["-c", relative(previous)]
|
||||||
|
command += ["--universal", "--generate-hashes", "--python-version", python_minimum(),
|
||||||
|
"--exclude-newer", timestamp(cutoff)]
|
||||||
|
for name in sorted(exceptions):
|
||||||
|
command += ["--exclude-newer-package", f"{name}={timestamp(exceptions[name])}"]
|
||||||
|
command += ["--no-config", "--quiet", "-o", relative(target)]
|
||||||
|
result = subprocess.run(command, cwd=ROOT)
|
||||||
|
if result.returncode != 0:
|
||||||
|
print(f"lock_requirements: resolving {source} failed - see uv's message above", file=sys.stderr)
|
||||||
|
return result.returncode
|
||||||
|
done.append(target)
|
||||||
|
print(f"wrote {relative(target)}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
+104
-28
@@ -6,10 +6,15 @@
|
|||||||
# pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1 --set rg=C:\Tools\rg.exe
|
# pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1 --set rg=C:\Tools\rg.exe
|
||||||
# pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1 --with browser
|
# pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1 --with browser
|
||||||
#
|
#
|
||||||
# --with browser installs tools/requirements-browser.txt into tools/.venv and the
|
# tools/.venv gets exactly the versions tools/requirements.lock names, checked against
|
||||||
|
# the hashes in it (pip --require-hashes); whenever the lock changes, the next run moves
|
||||||
|
# the venv to it, up or down. A venv built on a Python outside the span the manifest
|
||||||
|
# admits is built again on the Python found here.
|
||||||
|
#
|
||||||
|
# --with browser installs tools/requirements-browser.lock into tools/.venv and the
|
||||||
# Chromium that Playwright drives into tools/.venv/ms-playwright - only on request,
|
# Chromium that Playwright drives into tools/.venv/ms-playwright - only on request,
|
||||||
# because it is a large download that only `raw login` and pages a site handler
|
# because it is a large download that only `raw login` and pages a site handler
|
||||||
# declares `render` need. Once installed, every later run keeps it up to date.
|
# declares `render` need. Once installed, every later run keeps it at its lock.
|
||||||
#
|
#
|
||||||
# As the release asset `preflight.ps1` - a copy with no tools/prerequisites.txt next
|
# As the release asset `preflight.ps1` - a copy with no tools/prerequisites.txt next
|
||||||
# to it - the script is the first install step instead: it downloads the stack
|
# to it - the script is the first install step instead: it downloads the stack
|
||||||
@@ -61,9 +66,9 @@ $Root = Split-Path -Parent $Dir
|
|||||||
$Manifest = Join-Path $Dir 'prerequisites.txt'
|
$Manifest = Join-Path $Dir 'prerequisites.txt'
|
||||||
$ToolsFile = Join-Path $Root '.wikitool-tools.json'
|
$ToolsFile = Join-Path $Root '.wikitool-tools.json'
|
||||||
$Venv = Join-Path $Dir '.venv'
|
$Venv = Join-Path $Dir '.venv'
|
||||||
$Requirements = Join-Path $Dir 'requirements.txt'
|
$Requirements = Join-Path $Dir 'requirements.lock'
|
||||||
$Stamp = Join-Path $Venv '.chemenu-requirements.sha256'
|
$Stamp = Join-Path $Venv '.chemenu-requirements.sha256'
|
||||||
$BrowserRequirements = Join-Path $Dir 'requirements-browser.txt'
|
$BrowserRequirements = Join-Path $Dir 'requirements-browser.lock'
|
||||||
$BrowserStamp = Join-Path $Venv '.chemenu-browser.sha256'
|
$BrowserStamp = Join-Path $Venv '.chemenu-browser.sha256'
|
||||||
$Browsers = Join-Path $Venv 'ms-playwright'
|
$Browsers = Join-Path $Venv 'ms-playwright'
|
||||||
$Self = 'pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1'
|
$Self = 'pwsh -NoProfile -ExecutionPolicy Bypass -File tools/preflight.ps1'
|
||||||
@@ -564,7 +569,7 @@ foreach ($line in $ManifestLines) {
|
|||||||
Write-ErrorLine "preflight: bad tool name '$($parts[1])' in $Manifest"
|
Write-ErrorLine "preflight: bad tool name '$($parts[1])' in $Manifest"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
if ($parts[3] -eq 'all' -or $parts[3] -eq $Platform) {
|
if ($parts[4] -eq 'all' -or $parts[4] -eq $Platform) {
|
||||||
$Tools += $parts[1]
|
$Tools += $parts[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,11 +590,11 @@ foreach ($line in $ManifestLines) {
|
|||||||
|
|
||||||
function Get-InstallHint {
|
function Get-InstallHint {
|
||||||
param([string]$Tool)
|
param([string]$Tool)
|
||||||
$choco = Get-ManifestField 'tool' $Tool 7
|
$choco = Get-ManifestField 'tool' $Tool 8
|
||||||
$winget = Get-ManifestField 'tool' $Tool 8
|
$winget = Get-ManifestField 'tool' $Tool 9
|
||||||
$brew = Get-ManifestField 'tool' $Tool 9
|
$brew = Get-ManifestField 'tool' $Tool 10
|
||||||
$apt = Get-ManifestField 'tool' $Tool 10
|
$apt = Get-ManifestField 'tool' $Tool 11
|
||||||
$pacman = Get-ManifestField 'tool' $Tool 11
|
$pacman = Get-ManifestField 'tool' $Tool 12
|
||||||
$hint = ''
|
$hint = ''
|
||||||
switch ($Platform) {
|
switch ($Platform) {
|
||||||
'windows' {
|
'windows' {
|
||||||
@@ -752,10 +757,27 @@ foreach ($name in $Sets.Keys) {
|
|||||||
|
|
||||||
$script:Py = ''
|
$script:Py = ''
|
||||||
$script:PyVersion = ''
|
$script:PyVersion = ''
|
||||||
$script:PyOld = $null
|
$script:PyOut = $null
|
||||||
$PyMin = Get-ManifestField 'tool' 'python' 3
|
$PyMin = Get-ManifestField 'tool' 'python' 3
|
||||||
|
$PyMax = Get-ManifestField 'tool' 'python' 4
|
||||||
|
|
||||||
# Sets Py/PyVersion on success, PyOld when the version is too old.
|
# Whether major.minor lies in the span the manifest admits, both ends inclusive.
|
||||||
|
function Test-PythonAdmitted {
|
||||||
|
param([string]$Version)
|
||||||
|
if (-not (Test-VersionGe $Version $PyMin)) {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
return ($PyMax -eq '-' -or (Test-VersionGe $PyMax $Version))
|
||||||
|
}
|
||||||
|
|
||||||
|
# The span in words, for every message that names it.
|
||||||
|
if ($PyMax -eq '-') {
|
||||||
|
$PySpan = "$PyMin or newer"
|
||||||
|
} else {
|
||||||
|
$PySpan = "$PyMin to $PyMax"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sets Py/PyVersion on success, PyOut when the version lies outside the span.
|
||||||
function Test-PythonCandidate {
|
function Test-PythonCandidate {
|
||||||
param([string]$Path, [string[]]$Extra = @())
|
param([string]$Path, [string[]]$Extra = @())
|
||||||
$out = Invoke-Native -Path $Path -Arguments ($Extra + @('-c', $PyProbe))
|
$out = Invoke-Native -Path $Path -Arguments ($Extra + @('-c', $PyProbe))
|
||||||
@@ -771,12 +793,14 @@ function Test-PythonCandidate {
|
|||||||
if (-not $version -or -not $executable) {
|
if (-not $version -or -not $executable) {
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
if (Test-VersionGe $version $PyMin) {
|
if (Test-PythonAdmitted $version) {
|
||||||
$script:Py = $executable
|
$script:Py = $executable
|
||||||
$script:PyVersion = $version
|
$script:PyVersion = $version
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
$script:PyOld = @{ Version = $version; Path = $Path }
|
if (-not $script:PyOut) {
|
||||||
|
$script:PyOut = @{ Version = $version; Path = $Path }
|
||||||
|
}
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,12 +813,33 @@ function Get-PythonExtra {
|
|||||||
return @()
|
return @()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The versioned interpreters of the span, newest first - python3.14 python3.13 - so a
|
||||||
|
# machine whose plain python lies outside the span, with one inside it beside, is not
|
||||||
|
# turned away. On Windows the launcher's py -3.14 py -3.13 come before each.
|
||||||
|
function Get-VersionedCandidate {
|
||||||
|
if ($PyMax -eq '-') {
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
$major = $PyMin.Split('.')[0]
|
||||||
|
if ($PyMax.Split('.')[0] -ne $major) {
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
$candidates = @()
|
||||||
|
for ($minor = [int]$PyMax.Split('.')[1]; $minor -ge [int]$PyMin.Split('.')[1]; $minor--) {
|
||||||
|
if ($Platform -eq 'windows') {
|
||||||
|
$candidates += , @('py', @("-$major.$minor"))
|
||||||
|
}
|
||||||
|
$candidates += , @("python$major.$minor", @())
|
||||||
|
}
|
||||||
|
return $candidates
|
||||||
|
}
|
||||||
|
|
||||||
$given = Get-SetValue 'python'
|
$given = Get-SetValue 'python'
|
||||||
if ($given) {
|
if ($given) {
|
||||||
if (-not (Test-Usable $given) -or -not (Test-PythonCandidate $given (Get-PythonExtra $given))) {
|
if (-not (Test-Usable $given) -or -not (Test-PythonCandidate $given (Get-PythonExtra $given))) {
|
||||||
Add-Problem "The path given for Python does not work: $given" `
|
Add-Problem "The path given for Python does not work: $given" `
|
||||||
"every wikitool command runs on Python $PyMin or newer, and this path did not start one" `
|
"every wikitool command runs on Python $PySpan, and this path did not start one" `
|
||||||
"Check the path - it has to be the python executable itself, version $PyMin or newer.`nThen run: $Self --set python=<full path to python>"
|
"Check the path - it has to be the python executable itself, version $PySpan.`nThen run: $Self --set python=<full path to python>"
|
||||||
$script:BadSet = $true
|
$script:BadSet = $true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -808,6 +853,7 @@ if ($given) {
|
|||||||
} else {
|
} else {
|
||||||
$order = @(@('python3', @()), @('python', @()))
|
$order = @(@('python3', @()), @('python', @()))
|
||||||
}
|
}
|
||||||
|
$order += Get-VersionedCandidate
|
||||||
foreach ($candidate in $order) {
|
foreach ($candidate in $order) {
|
||||||
foreach ($path in (Find-OnPath $candidate[0])) {
|
foreach ($path in (Find-OnPath $candidate[0])) {
|
||||||
if (Test-PythonCandidate $path $candidate[1]) {
|
if (Test-PythonCandidate $path $candidate[1]) {
|
||||||
@@ -835,16 +881,30 @@ if ($script:Py) {
|
|||||||
Add-Report 'OK' 'python' $script:PyVersion $script:Py
|
Add-Report 'OK' 'python' $script:PyVersion $script:Py
|
||||||
$Found['python'] = $script:Py
|
$Found['python'] = $script:Py
|
||||||
} elseif (-not $script:BadSet) {
|
} elseif (-not $script:BadSet) {
|
||||||
$label = Get-ManifestField 'tool' 'python' 5
|
$label = Get-ManifestField 'tool' 'python' 6
|
||||||
$why = Get-ManifestField 'tool' 'python' 6
|
$why = Get-ManifestField 'tool' 'python' 7
|
||||||
if ($script:PyOld) {
|
# On Linux the fix is the distribution's own package, which may hold no Python of
|
||||||
Add-Report 'TOO_OLD' 'python' $script:PyOld.Version $script:PyOld.Path
|
# the span at all (Debian 12 has 3.11, Ubuntu 24.04 3.12); then the only way is a
|
||||||
Add-Problem "$label $($script:PyOld.Version) is too old - this stack needs $PyMin or newer." $why `
|
# Python installed some other way, named with --set. No other tool is suggested.
|
||||||
"$(Get-InstallHint 'python')`nOr, if a newer one is already installed, give its full path:`n$Self --set python=<full path to python>"
|
$distro = ''
|
||||||
|
if ($Platform -eq 'linux') {
|
||||||
|
$distro = "`nThe package source of this Linux distribution may offer no Python $PySpan -`nthen that command installs one outside the span, and a Python $PySpan`ninstalled another way has to be named with --set (below)."
|
||||||
|
}
|
||||||
|
if ($script:PyOut) {
|
||||||
|
if (Test-VersionGe $script:PyOut.Version $PyMin) {
|
||||||
|
$status = 'TOO_NEW'
|
||||||
|
$adjective = 'new'
|
||||||
|
} else {
|
||||||
|
$status = 'TOO_OLD'
|
||||||
|
$adjective = 'old'
|
||||||
|
}
|
||||||
|
Add-Report $status 'python' $script:PyOut.Version $script:PyOut.Path
|
||||||
|
Add-Problem "$label $($script:PyOut.Version) is too $adjective - this stack needs Python $PySpan." $why `
|
||||||
|
"$(Get-InstallHint 'python')$distro`nOr, if a Python $PySpan is already installed, give its full path:`n$Self --set python=<full path to python>"
|
||||||
} else {
|
} else {
|
||||||
Add-Report 'MISSING' 'python' '-' '-'
|
Add-Report 'MISSING' 'python' '-' '-'
|
||||||
Add-Problem "$label $PyMin or newer was not found." $why `
|
Add-Problem "$label $PySpan was not found." $why `
|
||||||
"$(Get-InstallHint 'python')`nOr, if it is installed somewhere this check did not look, give its full path:`n$Self --set python=<full path to python>"
|
"$(Get-InstallHint 'python')$distro`nOr, if it is installed somewhere this check did not look, give its full path:`n$Self --set python=<full path to python>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,8 +912,8 @@ foreach ($tool in $Tools) {
|
|||||||
if ($tool -eq 'python') {
|
if ($tool -eq 'python') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
$label = Get-ManifestField 'tool' $tool 5
|
$label = Get-ManifestField 'tool' $tool 6
|
||||||
$why = Get-ManifestField 'tool' $tool 6
|
$why = Get-ManifestField 'tool' $tool 7
|
||||||
$minimum = Get-ManifestField 'tool' $tool 3
|
$minimum = Get-ManifestField 'tool' $tool 3
|
||||||
$given = Get-SetValue $tool
|
$given = Get-SetValue $tool
|
||||||
$path = ''
|
$path = ''
|
||||||
@@ -1066,8 +1126,24 @@ function Get-LastLine {
|
|||||||
return ((($Text -split "`n") | Select-Object -Last 5 | ForEach-Object { " $_" }) -join "`n")
|
return ((($Text -split "`n") | Select-Object -Last 5 | ForEach-Object { " $_" }) -join "`n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# A venv keeps the Python it was created with, whatever the search above found. One
|
||||||
|
# outside the span - an instance set up under an older stack - is built again on $Py;
|
||||||
|
# `--clear` takes the stamps with it, so the install below runs. A venv inside the span
|
||||||
|
# stays, even when $Py is another version of it.
|
||||||
$venvPython = Get-VenvPython
|
$venvPython = Get-VenvPython
|
||||||
|
$rebuild = $false
|
||||||
if (-not $venvPython -or $null -eq (Invoke-Native -Path $venvPython -Arguments @('-m', 'pip', '--version'))) {
|
if (-not $venvPython -or $null -eq (Invoke-Native -Path $venvPython -Arguments @('-m', 'pip', '--version'))) {
|
||||||
|
$rebuild = $true
|
||||||
|
} else {
|
||||||
|
$probe = Invoke-Native -Path $venvPython -Arguments @('-c', $PyProbe)
|
||||||
|
$venvVersion = if ($probe) { ($probe -split "`n")[0].Trim() } else { '' }
|
||||||
|
if (-not $venvVersion -or -not (Test-PythonAdmitted $venvVersion)) {
|
||||||
|
$rebuild = $true
|
||||||
|
$shown = if ($venvVersion) { $venvVersion } else { '-' }
|
||||||
|
Write-Line ('REBUILD venv {0,-8} Python {0} is outside {1} - building tools/.venv again on {2}' -f $shown, $PySpan, $script:PyVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($rebuild) {
|
||||||
$created = Invoke-NativeVerbose -Path $script:Py -Arguments @('-m', 'venv', '--clear', $Venv)
|
$created = Invoke-NativeVerbose -Path $script:Py -Arguments @('-m', 'venv', '--clear', $Venv)
|
||||||
$venvPython = Get-VenvPython
|
$venvPython = Get-VenvPython
|
||||||
if ($created.Code -ne 0 -or -not $venvPython) {
|
if ($created.Code -ne 0 -or -not $venvPython) {
|
||||||
@@ -1088,7 +1164,7 @@ if (Test-Path -LiteralPath $Stamp -PathType Leaf) {
|
|||||||
$have = (Get-Content -Raw -LiteralPath $Stamp).Trim()
|
$have = (Get-Content -Raw -LiteralPath $Stamp).Trim()
|
||||||
}
|
}
|
||||||
if ($want -ne $have) {
|
if ($want -ne $have) {
|
||||||
$installed = Invoke-NativeVerbose -Path $venvPython -Arguments @('-m', 'pip', 'install', '--disable-pip-version-check', '--quiet', '-r', $Requirements)
|
$installed = Invoke-NativeVerbose -Path $venvPython -Arguments @('-m', 'pip', 'install', '--disable-pip-version-check', '--quiet', '--require-hashes', '-r', $Requirements)
|
||||||
if ($installed.Code -ne 0) {
|
if ($installed.Code -ne 0) {
|
||||||
Add-Problem 'The libraries wikitool needs could not be installed into tools/.venv.' `
|
Add-Problem 'The libraries wikitool needs could not be installed into tools/.venv.' `
|
||||||
'they are downloaded once from the internet; without them no wikitool command starts' `
|
'they are downloaded once from the internet; without them no wikitool command starts' `
|
||||||
@@ -1123,7 +1199,7 @@ if ($With -eq 'browser' -or (Test-Path -LiteralPath $BrowserStamp -PathType Leaf
|
|||||||
$have = (Get-Content -Raw -LiteralPath $BrowserStamp).Trim()
|
$have = (Get-Content -Raw -LiteralPath $BrowserStamp).Trim()
|
||||||
}
|
}
|
||||||
if ($want -ne $have -or -not (Test-Browser)) {
|
if ($want -ne $have -or -not (Test-Browser)) {
|
||||||
$installed = Invoke-NativeVerbose -Path $venvPython -Arguments @('-m', 'pip', 'install', '--disable-pip-version-check', '--quiet', '-r', $BrowserRequirements)
|
$installed = Invoke-NativeVerbose -Path $venvPython -Arguments @('-m', 'pip', 'install', '--disable-pip-version-check', '--quiet', '--require-hashes', '-r', $BrowserRequirements)
|
||||||
if ($installed.Code -ne 0) {
|
if ($installed.Code -ne 0) {
|
||||||
Add-Problem 'The optional browser component could not be installed into tools/.venv.' `
|
Add-Problem 'The optional browser component could not be installed into tools/.venv.' `
|
||||||
'only raw login and pages a site handler fetches through a browser need it; everything else works without it' `
|
'only raw login and pages a site handler fetches through a browser need it; everything else works without it' `
|
||||||
|
|||||||
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user