unaltraweb 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +29 -5
- data/README.md +2 -0
- data/docs/_documentation/en/33-reusable-workflows.md +1 -1
- data/docs/_documentation/en/43-workspace-path-policies.md +7 -0
- data/docs/_documentation/en/47-manual-context.md +19 -0
- data/docs/_documentation/en/48-artifact-storage.md +152 -0
- data/docs/_documentation/en/49-practice-inputs-editions.md +170 -0
- data/docs/_documentation/en/50-practice-artifact-storage.md +383 -0
- data/docs/_documentation/en/51-retained-private-intake.md +292 -0
- data/docs/_documentation/en/52-selected-file-private-storage.md +194 -0
- data/docs/_documentation/en/53-original-private-archives.md +190 -0
- data/docs/agents/manual-context-121.md +62 -5
- data/docs/agents/manual-context-fix-121.md +130 -0
- data/docs/agents/manual-context-pilot-review-121.md +277 -0
- data/docs/agents/manual-context-release-081-121.md +76 -0
- data/docs/agents/mcp-contract.md +51 -5
- data/docs/agents/original-private-archive.md +101 -0
- data/docs/agents/practice-artifact-storage-review.md +90 -0
- data/docs/agents/retained-compatibility.md +99 -0
- data/docs/agents/retained-private-intake.md +117 -0
- data/docs/agents/retained-variant-batch.md +103 -0
- data/docs/agents/software-release-090.md +66 -0
- data/docs/agents/web-practices-reconciliation.md +88 -0
- data/docs/agents/web-s4-manuals-readiness.md +126 -0
- data/docs/agents/web-storage-followup.md +98 -0
- data/docs/agents/zip-only-flat-storage.md +79 -0
- data/scripts/manual/candidate-storage-s3-requirements.txt +8 -0
- data/scripts/review_manual_context_pilots.py +287 -0
- data/scripts/test_candidate_transfer.py +52 -0
- data/scripts/test_manual_context_export.py +32 -2
- data/scripts/test_wheel_install.py +36 -0
- data/scripts/unaltraweb-mcp-bootstrap.sh +1 -1
- data/scripts/validate_workflows.py +105 -10
- data/src/unaltraweb_mcp/component-contract.json +24 -20
- metadata +24 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Bounded storage follow-up before real manual adoption
|
|
2
|
+
|
|
3
|
+
## Separate source scopes
|
|
4
|
+
|
|
5
|
+
The established Web owner continues from `710c73765e44ef57e57b0b638dd4eeb9ea53d706`
|
|
6
|
+
in the same primary checkout/local branch. Existing-WIP checkpoint admission
|
|
7
|
+
selects only intended technical files with hooks and preservation verification.
|
|
8
|
+
|
|
9
|
+
- #114 is a separate two-file checkpoint
|
|
10
|
+
`385fd396a68889d05c231da9153bfb8fdff0174f`, reviewed in
|
|
11
|
+
[Draft PR132](https://github.com/dosquartsdedocs/unaltraweb/pull/132), based on
|
|
12
|
+
PR131's immutable source. It prunes explicitly excluded private roots before
|
|
13
|
+
snapshot traversal and retains source/index/blob/implementation-input safety.
|
|
14
|
+
Live socket/source/receipt regressions and the full 821-test established-tree
|
|
15
|
+
suite (28 skips) pass before that checkpoint. `TODO.md` stays separate WIP.
|
|
16
|
+
- The transport follow-up is separately stacked on that checkpoint. It corrects
|
|
17
|
+
official Bitbucket URL interpretation and retains local S3 uncertainty evidence;
|
|
18
|
+
it does not recreate the adapter, alter frozen product/route schemas or admit
|
|
19
|
+
Geodisseny's untyped outputs. PR129/130/131 review sources retain their heads.
|
|
20
|
+
|
|
21
|
+
## Native repository parser
|
|
22
|
+
|
|
23
|
+
Official `git@ssh.bitbucket.org:<workspace>/<repo>.git` and
|
|
24
|
+
`ssh://git@ssh.bitbucket.org[:22]/<workspace>/<repo>.git` identify logical
|
|
25
|
+
`bitbucket.org/<workspace>/<repo>`. Standard existing hosts and explicit default
|
|
26
|
+
SSH port 22 are admitted. HTTPS/web IDs retain their old host/port/credential
|
|
27
|
+
rules. Fetch/push declarations must still agree with native consumer metadata;
|
|
28
|
+
repo/bucket spelling remains exact. No workstation alias, lookalike host,
|
|
29
|
+
password-bearing URL, nondefault port, remote rewrite or SSH repair is added.
|
|
30
|
+
|
|
31
|
+
## Small local uncertainty record
|
|
32
|
+
|
|
33
|
+
The existing source/config/destination/manifest checks and named-v1 transfer stay
|
|
34
|
+
authoritative. A new private attempt directory outside the immutable stage holds
|
|
35
|
+
only whitelisted intent metadata and an append-only, fsynced observation chain.
|
|
36
|
+
Before requests it binds exact source/config/policy/destination/manifest identity;
|
|
37
|
+
once an UploadId is observed, its exact bucket/key/id is retained before parts.
|
|
38
|
+
Acknowledged part counts/bytes and create/complete/readback/abort phases are bounded.
|
|
39
|
+
|
|
40
|
+
The source review reports Geodisseny candidate metadata of 32 PDF/ZIP files,
|
|
41
|
+
437,022,560 bytes total and a 101,583,048-byte maximum. This exceeds the existing
|
|
42
|
+
64-MiB multipart threshold and makes lost abort/complete observations a real
|
|
43
|
+
readiness concern. This unit reuses that read-only metadata; tests use small
|
|
44
|
+
synthetic providers and the pinned SDK model, with no real bucket fixture.
|
|
45
|
+
|
|
46
|
+
Lost create responses retain an unknown ID. Failed parts can request abort of
|
|
47
|
+
the exact observed owned tuple after retaining intent; abort ACK is distinguished
|
|
48
|
+
from remote absence/verified cleanup. Abort uncertainty retains the tuple. After
|
|
49
|
+
completion uncertainty no automatic abort or retry is attempted: final bytes may
|
|
50
|
+
already exist and can be inspected read-only. Evidence or binding tampering stops
|
|
51
|
+
further mutation. Safe failures expose only fixed messages, phases and private
|
|
52
|
+
receipt pointers, excluding provider bodies, credentials and teacher content.
|
|
53
|
+
|
|
54
|
+
`inspect-attempt` verifies local intent/event hashes and the bounded chain; it
|
|
55
|
+
does not resolve auth, call a provider or recover anything. Explicit `verify`
|
|
56
|
+
may establish exact existing output bytes while still refusing missing later
|
|
57
|
+
metadata. Success/repeat creates separate local evidence without rewriting old
|
|
58
|
+
stages, producer/manifest identity or prior attempt records. No journal is uploaded.
|
|
59
|
+
Local evidence is not a remote registry, ownership inference, recovery executor
|
|
60
|
+
or cleanup permission. A partial/damaged local record is not claimed complete.
|
|
61
|
+
|
|
62
|
+
## Qualification boundaries
|
|
63
|
+
|
|
64
|
+
Selected source/PR/CI/checkpoint/test/schema/CLI/evidence pins are returned in
|
|
65
|
+
the new ignored `sandbox/coordination/web-storage-followup-return.json`.
|
|
66
|
+
Matching source-containing MCP/PDF and public wheel/docs checks qualify source,
|
|
67
|
+
not a containing published release or a real manual pilot. Existing earlier
|
|
68
|
+
mismatched PDF tuple evidence remains retained; freshness and companion pins are
|
|
69
|
+
not bypassed.
|
|
70
|
+
|
|
71
|
+
TIGIT/TIG still need closed native products. Geodisseny's current simple manifests
|
|
72
|
+
and author/proof state require the separately bounded native-intake gate already
|
|
73
|
+
reported. Actual project-scoped bucket/auth/readback/ACL/restore/link qualification,
|
|
74
|
+
reviewed runtime publication/adoption and author/native acceptance remain owner
|
|
75
|
+
work. This slice performs no real S4/Meum/teaching upload, bucket creation, public
|
|
76
|
+
URL activation, consumer edit, client cutover, merge/tag/release or new SSH script.
|
|
77
|
+
|
|
78
|
+
## Local source verification
|
|
79
|
+
|
|
80
|
+
- Full required source suite: **836 tests, 28 explicit skips**, with the declared
|
|
81
|
+
public dependency environment. The two new repository parser regressions and
|
|
82
|
+
thirteen attempt-evidence regressions include the real pinned Botocore multipart
|
|
83
|
+
part/abort failure model, and synthetic lost-create/uncertain-complete/readback,
|
|
84
|
+
source/config/destination/evidence tampering, symlink confinement, privacy and
|
|
85
|
+
idempotent stage-preservation cases.
|
|
86
|
+
- Distribution/workflow/wheel/whitespace checks pass. The public wheel includes
|
|
87
|
+
the local evidence helper and factory-free CLI inspection interface.
|
|
88
|
+
- Independent native common inspector/planner/named-v1 fetch still reconstructs
|
|
89
|
+
two ZIPs and one private PDF exactly, with object-URL methods unavailable. Local
|
|
90
|
+
journals never enter the three-file product or its four remote objects.
|
|
91
|
+
- A source-containing local MCP check, full MCP/PDF/practice/preview smoke and docs
|
|
92
|
+
build pass. Both local MCP/PDF builders use SHA-256
|
|
93
|
+
`d3d580ef5810383fa195da5633137123f55164b059766950dd204deba01a30bf`.
|
|
94
|
+
Matching development source and earlier failed published-worker evidence remain
|
|
95
|
+
distinct from any published runtime selection.
|
|
96
|
+
|
|
97
|
+
Committed-tree CI, exact source/driver/helper pins and checkpoint preservation
|
|
98
|
+
evidence are recorded in the new owner return after technical publication.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# ZIP-only private files-v1 — producer source increment
|
|
2
|
+
|
|
3
|
+
The direct owner simplifies the successful private Geo pilot: when original
|
|
4
|
+
student/teacher ZIPs contain their PDFs, remote selection is those ZIPs only. Local
|
|
5
|
+
standalone PDFs, source/worker/evidence/provenance, editorial/recipient/language
|
|
6
|
+
state and original ZIP bytes/roots/names remain authoritative and preserved.
|
|
7
|
+
|
|
8
|
+
This same-checkout unit starts at PR135/source
|
|
9
|
+
`966031685c0d88fa5237134b6117157086fb0dcb`. The owner reports the actual preceding
|
|
10
|
+
MEGA pilot completed PLAN/snapshot/stage/publish/verify/common restore, host final
|
|
11
|
+
SHA `7869b7305265ae3456824298c42e7e31d2b066e150798734e39e54585579b4f8`,
|
|
12
|
+
two original student payloads plus six metadata/alias objects. That genuine
|
|
13
|
+
named-v1 proof is preserved, not reinterpreted as a release or normal runtime
|
|
14
|
+
integration, and grants no automatic old-object cleanup authority.
|
|
15
|
+
|
|
16
|
+
## Minimal public opt-in
|
|
17
|
+
|
|
18
|
+
Route schema v3 adds required explicit `delivery_layout:named-v1|files-v1` per
|
|
19
|
+
artifact. Frozen older route/request/product/policy/native formats remain intact;
|
|
20
|
+
scaffold defaults stay unconfigured v2. Files-v1 requires authenticated-private-v1
|
|
21
|
+
and private S3, retaining exact native repository-named bucket, explicit project/
|
|
22
|
+
destination credentials and teacher/private boundaries. The existing public CLI/
|
|
23
|
+
plan/stage/native product/S3/attempt implementation is reused.
|
|
24
|
+
|
|
25
|
+
Only selected `role:output` transfers to `<explicit-prefix>/<original-path>`.
|
|
26
|
+
For Geo's example this is exactly `practiques/ca/avaluacio-multicriteri.zip` and
|
|
27
|
+
`practiques/ca/avaluacio-multicriteri-docent.zip` in bucket `geodisseny`.
|
|
28
|
+
Product/artifact/control/alias/receipt/journal metadata remains local. A new local
|
|
29
|
+
delivery seal binds the chosen layout to the reviewed product/output paths so a
|
|
30
|
+
named stage cannot be silently flattened. Product identity stays destination/
|
|
31
|
+
layout-independent; old named stages/journals remain their original format.
|
|
32
|
+
|
|
33
|
+
Existing native conditional create/reuse and byte/size/MIME/download/private-ACL
|
|
34
|
+
readback are retained. A different existing object/header or uncertain create is
|
|
35
|
+
refused without overwrite/delete/reupload/retry. Conditional-ETag replacement is
|
|
36
|
+
not qualified by this source increment and remains a separately explicit action.
|
|
37
|
+
Attempt intent lists only actual selected plain keys, retaining source/config/
|
|
38
|
+
layout/destination/evidence guards and exact owned multipart observations.
|
|
39
|
+
|
|
40
|
+
The common FILE_STORAGE_V1/mcp_artifacts.files contract is inspected read-only.
|
|
41
|
+
Its existing authenticated files-v1 fetch requires a retained LOCAL manifest,
|
|
42
|
+
downloads only native output entries and may preserve that local inventory
|
|
43
|
+
alongside outputs. Local evidence is not remotely reconstructed; a full product
|
|
44
|
+
claim would be false. No common reader/host engine is copied into Web/manuals, and
|
|
45
|
+
the public wheel has no private hub/MEGA runtime dependency.
|
|
46
|
+
|
|
47
|
+
## Synthetic verification and actual owner next step
|
|
48
|
+
|
|
49
|
+
Representative synthetic original student/teacher ZIP-only selection retains
|
|
50
|
+
embedded PDFs and authentic local worker/member/proof evidence. Tests exercise
|
|
51
|
+
plan/snapshot/private stage, only two plain ZIP objects remotely, exact byte/header/
|
|
52
|
+
ACL/readback, metadata privacy, missing/corrupt/collision/conditional race refusals,
|
|
53
|
+
layout-bound stage integrity, owned uncertainty/tamper/no replay and old profiles.
|
|
54
|
+
An independent existing common files-v1 reader reconstructs the original ZIPs
|
|
55
|
+
from local inventory and natively compares their embedded PDFs to originals.
|
|
56
|
+
|
|
57
|
+
The Geo owner separately proves real containment/candidate state and edits its own
|
|
58
|
+
request/routing only after qualified source/public wheel selection. Review ZIP-only
|
|
59
|
+
intake and route-v3 files-v1 plans, explicit `practiques/ca` prefix and exact private
|
|
60
|
+
host binding; create new layout-sealed stages without mutating old ones. Publish/
|
|
61
|
+
verify original ZIPs, fetch using retained local inventories, then compare ZIP/PDF
|
|
62
|
+
bytes and native headers/private ACL. Only afterwards inspect the exact superseded
|
|
63
|
+
eight pilot objects for a separate owner retirement decision.
|
|
64
|
+
|
|
65
|
+
This producer source unit reads/modifies no real course bodies, consumer files,
|
|
66
|
+
original ZIPs, cloud objects, credentials or client/runtime selections. No merge,
|
|
67
|
+
tag/release/image publication/deploy, new session/worktree or deletion occurs.
|
|
68
|
+
Exact source/PR/CI/package/CLI/schema/API and synthetic common fetch evidence is
|
|
69
|
+
returned in `sandbox/coordination/web-zip-only-flat-storage-return.json`.
|
|
70
|
+
|
|
71
|
+
Local qualification: **867 source tests, 28 skips**, including nine focused
|
|
72
|
+
selected-file/native-SDK cases; distribution/workflow/clean wheel, real MCP schema
|
|
73
|
+
discovery, matching MCP/PDF/practice/preview smoke, docs build and whitespace pass.
|
|
74
|
+
Source/factory/installed dev package code is
|
|
75
|
+
`4170c62aa79074557453aa3eacaa1d653125b8bb47ed94ccf561a7564e145e29`.
|
|
76
|
+
The independent existing common files-v1 reader fetches exactly two original ZIPs
|
|
77
|
+
from LOCAL manifests, with matching headers/private ACL and exact embedded PDF
|
|
78
|
+
bytes, and reports incomplete full metadata restoration honestly. These are
|
|
79
|
+
synthetic/source qualifications; actual Geo adoption/retirement remains separate.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"""Opt-in, version-bound #121 review against the published 0.8.0 controller.
|
|
2
|
+
|
|
3
|
+
Creates synthetic sources, invokes the REAL installed CLI without network/socket,
|
|
4
|
+
and retains successes AND expected refusals. It does not repair the exporter,
|
|
5
|
+
render figures, manufacture transport archives, or mount a teaching manual.
|
|
6
|
+
Native computation locks below are explicitly synthetic check fixtures, not
|
|
7
|
+
evidence that R/Python rendering took place. Itemarium checking is optional and
|
|
8
|
+
uses its read-only source tree with a separately prepared Python interpreter.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import base64
|
|
14
|
+
import hashlib
|
|
15
|
+
import importlib.util
|
|
16
|
+
import io
|
|
17
|
+
import json
|
|
18
|
+
import os
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
import subprocess
|
|
21
|
+
import sys
|
|
22
|
+
import tarfile
|
|
23
|
+
import uuid
|
|
24
|
+
|
|
25
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
26
|
+
IMAGE = "sha256:e0502369c85c59f9e512fbd9fdb17dbc128845d057a1423375425e68ce2e79a2"
|
|
27
|
+
OLD_IMAGE = "sha256:ea14b1224382e47031b979d294f970b66773155584ac8f9eb94a33dc6421b0c9"
|
|
28
|
+
SOURCE = "54afe7588c36e959a7eb75d5f52763a7456108d7"
|
|
29
|
+
PRODUCER = "sha256:a678d2b2649e3479d0049ca0ca8a500aba5bb3f0a59b070cd7aaf5c0c6b466d0"
|
|
30
|
+
SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="30" height="20"><rect width="30" height="20" fill="white"/><text x="1" y="12">Fixture</text></svg>'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def sha(data):
|
|
34
|
+
return hashlib.sha256(data).hexdigest()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def save(path, value):
|
|
38
|
+
with path.open("x", encoding="utf-8") as stream:
|
|
39
|
+
json.dump(value, stream, indent=2, sort_keys=True, ensure_ascii=False)
|
|
40
|
+
stream.write("\n")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def write(root, name, data):
|
|
44
|
+
path = root / name
|
|
45
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
46
|
+
with path.open("xb") as stream:
|
|
47
|
+
stream.write(data.encode() if isinstance(data, str) else data)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def command(argv, *, cwd=None, expected=0, env=None):
|
|
51
|
+
result = subprocess.run(argv, cwd=cwd, env=env, capture_output=True, text=True, timeout=180)
|
|
52
|
+
if expected is not None and result.returncode != expected:
|
|
53
|
+
raise RuntimeError(f"Command failed: {argv}: {result.returncode}\n{result.stderr[-4000:]}")
|
|
54
|
+
return result
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def cases(root):
|
|
58
|
+
from PIL import Image
|
|
59
|
+
import yaml
|
|
60
|
+
png = io.BytesIO()
|
|
61
|
+
Image.new("RGB", (2, 2), "navy").save(png, format="PNG")
|
|
62
|
+
encoded = base64.b64encode(png.getvalue()).decode()
|
|
63
|
+
rows = [
|
|
64
|
+
{"id": "baseline", "body": 'Text.\n\n\n', "ok": True},
|
|
65
|
+
{"id": "missing-id", "no_id": True, "error": "unaltraweb.manual.id"},
|
|
66
|
+
{"id": "missing-figure", "body": '\n', "error": "Missing editorial input"},
|
|
67
|
+
{"id": "public-input", "compute": "assets/data/input.gpkg", "ok": True},
|
|
68
|
+
{"id": "private-input", "compute": "_practices/fixture/data/input.gpkg", "error": "outside the public manual source roots"},
|
|
69
|
+
{"id": "private-input-other-chapter", "compute": "_practices/fixture/data/input.gpkg", "unreferenced": True,
|
|
70
|
+
"chapter": "first", "error": "outside the public manual source roots"},
|
|
71
|
+
{"id": "changed-public-input", "compute": "assets/data/input.gpkg", "changed_input": True,
|
|
72
|
+
"error": "source_or_environment_changed"},
|
|
73
|
+
{"id": "private-image", "body": '\n',
|
|
74
|
+
"extra": {"_practices/fixture/private.png": png.getvalue()}, "error": "outside the public manual source roots"},
|
|
75
|
+
{"id": "components", "body": '''{% include note.md %}
|
|
76
|
+
|
|
77
|
+
{% cite fixture %}
|
|
78
|
+
|
|
79
|
+
::: table "Table caption"
|
|
80
|
+
| A | B |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| 1 | 2 |
|
|
83
|
+
:::
|
|
84
|
+
|
|
85
|
+
::: subfigures a+b "Group caption"
|
|
86
|
+

|
|
87
|
+

|
|
88
|
+
:::
|
|
89
|
+
''', "extra": {"_includes/note.md": "Term\n: Exact definition.\n\n>>>> Warning text.\n",
|
|
90
|
+
"_bibliography/manual.bib": '@book{fixture, title={Fixture reference}, author={Author, A}, year={2026}}'}, "ok": True},
|
|
91
|
+
{"id": "liquid-expression", "body": "Title: {{ page.title }}\n", "error": "unresolved Liquid/include"},
|
|
92
|
+
{"id": "include-parameters", "body": '{% include note.md label="Example" %}\n',
|
|
93
|
+
"extra": {"_includes/note.md": "A note."}, "error": "without parameters"},
|
|
94
|
+
{"id": "html-caption-code", "body": '<img src="assets/img/plain.svg" alt="Alt `code`" title="Caption `literal`">\n',
|
|
95
|
+
"ok": True, "expected_caption": "Caption `literal`"},
|
|
96
|
+
{"id": "embedded-raster", "body": '\n',
|
|
97
|
+
"image": "assets/img/embedded.svg", "extra": {"assets/img/embedded.svg": '<svg xmlns="http://www.w3.org/2000/svg"><image href="data:image/png;base64,' + encoded + '" width="2" height="2"/></svg>'},
|
|
98
|
+
"error": "cannot receive SVG <image>"},
|
|
99
|
+
{"id": "external-raster", "body": '\n',
|
|
100
|
+
"image": "assets/img/external.svg", "extra": {"assets/img/external.svg": '<svg xmlns="http://www.w3.org/2000/svg"><image href="https://example.invalid/image.png"/></svg>'},
|
|
101
|
+
"error": "cannot receive SVG <image>"},
|
|
102
|
+
{"id": "qgis-vector", "body": '\n', "image": "assets/img/map.svg",
|
|
103
|
+
"extra": {"assets/img/map.svg": SVG.replace("<rect", '<metadata>{"producer":"unaltracaptura-qgis"}</metadata><rect')},
|
|
104
|
+
"error": "QGIS capture handoff is not supported"},
|
|
105
|
+
{"id": "qgis-untyped", "body": '\n',
|
|
106
|
+
"image": "assets/img/map.svg", "extra": {"assets/img/map.svg": SVG}, "ok": True},
|
|
107
|
+
]
|
|
108
|
+
for row in rows:
|
|
109
|
+
case = root / row["id"]
|
|
110
|
+
case.mkdir()
|
|
111
|
+
config = {"theme": "unaltraweb", "title": "Synthetic review", "default_lang": "ca", "languages": ["ca"],
|
|
112
|
+
"exclude": ["tmp/", "_practices/"], "unaltraweb": {"site_profile": "unaltremanual", "manual": {"id": "review-121"}}}
|
|
113
|
+
if row.get("no_id"):
|
|
114
|
+
del config["unaltraweb"]["manual"]["id"]
|
|
115
|
+
write(case, "_config.yml", yaml.safe_dump(config))
|
|
116
|
+
write(case, ".gitignore", "/tmp/\n")
|
|
117
|
+
write(case, "assets/img/plain.svg", SVG)
|
|
118
|
+
body = row.get("body", 'Text.\n\n\n')
|
|
119
|
+
if row.get("compute"):
|
|
120
|
+
write(case, ".unaltraweb/computations.yml", "version: 1\nsource_roots: [assets/compute]\n")
|
|
121
|
+
write(case, row["compute"], b"OPAQUE SYNTHETIC FINGERPRINT INPUT; NOT A GIS VALIDITY TEST\n")
|
|
122
|
+
front = {"title": "Computed fixture", "lang": "ca", "ref": "computed-fixture", "unaltraweb_compute": {
|
|
123
|
+
"engine": "python", "mode": "figure", "inputs": [row["compute"]], "outputs": ["assets/img/result.svg"]}}
|
|
124
|
+
write(case, "assets/compute/figure.qmd", "---\n" + yaml.safe_dump(front) + "---\nSynthetic source; no computation execution.\n")
|
|
125
|
+
write(case, "assets/img/result.svg", SVG)
|
|
126
|
+
if not row.get("unreferenced"):
|
|
127
|
+
body = '\n'
|
|
128
|
+
write(case, "_chapters/ca/first.md", "---\ntitle: First\nlang: ca\nref: first\n---\n" + body)
|
|
129
|
+
for name, data in row.pop("extra", {}).items():
|
|
130
|
+
write(case, name, data)
|
|
131
|
+
command(["git", "init", "-b", "fixture"], cwd=case)
|
|
132
|
+
paths = [p.relative_to(case).as_posix() for p in case.rglob("*") if p.is_file() and ".git" not in p.parts]
|
|
133
|
+
command(["git", "add", "--", *paths], cwd=case)
|
|
134
|
+
command(["git", "-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "commit", "-m", "Synthetic review sources"], cwd=case)
|
|
135
|
+
save(root / "cases.json", rows)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def worker(root):
|
|
139
|
+
"""Executed in the exact published image. No exporter function is replaced."""
|
|
140
|
+
from unaltraweb_mcp import __version__
|
|
141
|
+
from unaltraweb_mcp.manual_context import producer_identity
|
|
142
|
+
assert root == Path("/cases") and os.environ.get("UW_REVIEW_WORKER") == "1"
|
|
143
|
+
identity = producer_identity(Path("/opt/unaltraweb"))
|
|
144
|
+
assert __version__ == "0.8.0" and identity["revision"] == PRODUCER
|
|
145
|
+
rows = json.loads((root / "cases.json").read_text())
|
|
146
|
+
results = []
|
|
147
|
+
for row in rows:
|
|
148
|
+
case = root / row["id"]
|
|
149
|
+
native_status = None
|
|
150
|
+
if row.get("compute"):
|
|
151
|
+
spec = importlib.util.spec_from_file_location("review_native_compute", "/opt/unaltraweb/scripts/computations/render.py")
|
|
152
|
+
native = importlib.util.module_from_spec(spec)
|
|
153
|
+
spec.loader.exec_module(native)
|
|
154
|
+
config, config_path = native.load_config(case)
|
|
155
|
+
record, = native.discover_sources(case, config)
|
|
156
|
+
fingerprint, dependencies, image = native.fingerprint(case, config, config_path, record)
|
|
157
|
+
saved = {"fingerprint": fingerprint, "dependencies": dependencies, "image": image,
|
|
158
|
+
"image_identity": native.inspect_image(image["image"]),
|
|
159
|
+
"outputs": [{"path": p, **native.file_signature(case / p)} for p in record["output_paths"]]}
|
|
160
|
+
save(case / ".unaltraweb/computations.lock.json", {"version": 1, "records": {record["source_path"]: saved}})
|
|
161
|
+
native_status = native.status(case)
|
|
162
|
+
assert native_status["ok"], native_status
|
|
163
|
+
if row.get("changed_input"):
|
|
164
|
+
with (case / row["compute"]).open("ab") as stream:
|
|
165
|
+
stream.write(b"CHANGED INPUT\n")
|
|
166
|
+
before = {p.relative_to(case).as_posix(): sha(p.read_bytes()) for p in case.rglob("*")
|
|
167
|
+
if p.is_file() and ".git" not in p.parts and "tmp" not in p.relative_to(case).parts}
|
|
168
|
+
argv = [sys.executable, "-I", "-B", "-m", "unaltraweb_mcp.cli", "--project", str(case), "mcp",
|
|
169
|
+
"manual-context-export", "--name", "review", "--language", "ca"]
|
|
170
|
+
if row.get("chapter"):
|
|
171
|
+
argv += ["--chapter", row["chapter"]]
|
|
172
|
+
ran = command(argv, expected=None)
|
|
173
|
+
result = json.loads(ran.stdout)
|
|
174
|
+
expected = (ran.returncode == 0 and result.get("ok") is True) if row.get("ok") else (
|
|
175
|
+
ran.returncode == 1 and result.get("ok") is False and row["error"] in result.get("error", ""))
|
|
176
|
+
item = {"id": row["id"], "expected_behavior_observed": expected, "command": argv, "exit_code": ran.returncode,
|
|
177
|
+
"result": result, "stderr": ran.stderr, "source_hashes": before,
|
|
178
|
+
"synthetic_native_status": native_status, "renderer_executed": False}
|
|
179
|
+
archive = case / "tmp/manual-context/review/manual-context.tar.gz"
|
|
180
|
+
item["archive_created"] = archive.exists()
|
|
181
|
+
if result.get("ok"):
|
|
182
|
+
assert archive.is_file() and sha(archive.read_bytes()) == result["sha256"]
|
|
183
|
+
with tarfile.open(archive) as content:
|
|
184
|
+
members = {m.name: content.extractfile(m).read() for m in content.getmembers()}
|
|
185
|
+
manifest = json.loads(members.pop("manual-context.json"))
|
|
186
|
+
assert set(manifest["files"]) == set(members)
|
|
187
|
+
assert all(entry["sha256"] == sha(members[p]) and entry["size_bytes"] == len(members[p]) for p, entry in manifest["files"].items())
|
|
188
|
+
item["manifest"] = manifest
|
|
189
|
+
if row.get("expected_caption"):
|
|
190
|
+
item["expected_caption"] = row["expected_caption"]
|
|
191
|
+
item["caption_preserved"] = manifest["figures"][0]["caption"] == row["expected_caption"]
|
|
192
|
+
else:
|
|
193
|
+
assert not archive.exists(), "A refusal left a transport package"
|
|
194
|
+
assert all(sha((case / p).read_bytes()) == value for p, value in before.items())
|
|
195
|
+
save(root / (row["id"] + ".result.json"), item)
|
|
196
|
+
results.append(item)
|
|
197
|
+
save(root / "producer-review.json", {"ok": all(row["expected_behavior_observed"] for row in results),
|
|
198
|
+
"purpose": "Version-bound baseline review, not acceptance of known defects", "producer": identity,
|
|
199
|
+
"synthetic_only": True, "real_manual_mounted": False, "renderer_executed": False, "cases": results})
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
RECEIVER = '''import json, sys
|
|
203
|
+
from pathlib import Path
|
|
204
|
+
import itemarium
|
|
205
|
+
from itemarium.app.media import read_image
|
|
206
|
+
from itemarium.app.manual_package import check_package
|
|
207
|
+
from itemarium.runtime_identity import source_sha256
|
|
208
|
+
root = Path(sys.argv[1]); engine = Path(itemarium.__file__).parent
|
|
209
|
+
before = source_sha256(engine); results = []
|
|
210
|
+
for case in json.loads((root/'cases.json').read_text()):
|
|
211
|
+
result = json.loads((root/(case['id']+'.result.json')).read_text())['result']
|
|
212
|
+
row = {'id':case['id']}
|
|
213
|
+
if result.get('ok'):
|
|
214
|
+
row['package_check'] = check_package(package_path=root/case['id']/result['path'], sha256=result['sha256'])
|
|
215
|
+
if case.get('image'):
|
|
216
|
+
try:
|
|
217
|
+
read_image(root/case['id']/case['image']); row['image_check'] = {'ok':True}
|
|
218
|
+
except ValueError as error:
|
|
219
|
+
row['image_check'] = {'ok':False, 'error':str(error)}
|
|
220
|
+
results.append(row)
|
|
221
|
+
assert source_sha256(engine) == before
|
|
222
|
+
report = {'engine_version':itemarium.__version__, 'engine_source_sha256':before, 'cases':results,
|
|
223
|
+
'imports_performed':False, 'manufacturer_of_alternate_packages':False,
|
|
224
|
+
'image_checks_are_member_validation_only':True}
|
|
225
|
+
with (root/'receiver-review.json').open('x') as output:
|
|
226
|
+
json.dump(report, output, sort_keys=True, indent=2); output.write('\\n')
|
|
227
|
+
'''
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def main():
|
|
231
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
232
|
+
parser.add_argument("--output", type=Path)
|
|
233
|
+
parser.add_argument("--receiver-python", type=Path)
|
|
234
|
+
parser.add_argument("--receiver-source", type=Path)
|
|
235
|
+
parser.add_argument("--worker", type=Path, help=argparse.SUPPRESS)
|
|
236
|
+
args = parser.parse_args()
|
|
237
|
+
if args.worker:
|
|
238
|
+
worker(args.worker)
|
|
239
|
+
return
|
|
240
|
+
if not args.output or bool(args.receiver_python) != bool(args.receiver_source):
|
|
241
|
+
parser.error("Supply --output; pair --receiver-python with --receiver-source")
|
|
242
|
+
if not (ROOT / "mcp-factory.yml").is_file():
|
|
243
|
+
parser.error("Run this review harness from the unaltraweb source checkout")
|
|
244
|
+
output = args.output.resolve()
|
|
245
|
+
if output != args.output or not output.is_relative_to(ROOT / "tmp") or not output.parent.is_dir():
|
|
246
|
+
parser.error("Use a new absolute output below this checkout's tmp, with an existing parent")
|
|
247
|
+
observed, = json.loads(command(["docker", "image", "inspect", IMAGE]).stdout)
|
|
248
|
+
assert observed["Id"] == IMAGE and observed["Config"]["Labels"]["org.opencontainers.image.revision"] == SOURCE
|
|
249
|
+
output.mkdir(mode=0o700)
|
|
250
|
+
cases(output)
|
|
251
|
+
name = "unaltraweb-review121-" + uuid.uuid4().hex
|
|
252
|
+
argv = ["docker", "run", "--rm", "--pull", "never", "--name", name, "--network", "none", "--read-only",
|
|
253
|
+
"--user", f"{os.getuid()}:{os.getgid()}", "--cpus", "2", "--memory", "2g", "--pids-limit", "256",
|
|
254
|
+
"--cap-drop", "ALL", "--security-opt", "no-new-privileges", "--tmpfs", "/tmp:rw,nosuid,nodev,size=268435456",
|
|
255
|
+
"-e", "HOME=/tmp", "-e", "PYTHONDONTWRITEBYTECODE=1", "-e", "UW_REVIEW_WORKER=1",
|
|
256
|
+
"--mount", f"type=bind,source={output},target=/cases",
|
|
257
|
+
"--mount", f"type=bind,source={Path(__file__).resolve()},target=/review.py,readonly",
|
|
258
|
+
"--entrypoint", "python3", IMAGE, "-I", "-B", "/review.py", "--worker", "/cases"]
|
|
259
|
+
for path in (output, Path(__file__).resolve()):
|
|
260
|
+
if any(c in str(path) for c in ",\r\n"):
|
|
261
|
+
raise ValueError("Review mount path needs a simple literal spelling")
|
|
262
|
+
ran = command(argv, expected=None)
|
|
263
|
+
save(output / "execution.json", {"command": argv, "exit_code": ran.returncode, "stdout": ran.stdout, "stderr": ran.stderr})
|
|
264
|
+
command(["docker", "info", "--format", "{{.ID}}"])
|
|
265
|
+
absent = command(["docker", "container", "inspect", name], expected=None)
|
|
266
|
+
assert absent.returncode == 1 and "No such" in absent.stderr, "Exact review container absence not established"
|
|
267
|
+
if ran.returncode:
|
|
268
|
+
raise RuntimeError(ran.stderr[-6000:])
|
|
269
|
+
report = json.loads((output / "producer-review.json").read_text())
|
|
270
|
+
assert report["ok"], "A scenario differed from the recorded 0.8.0 behavior; inspect retained results"
|
|
271
|
+
old, = json.loads(command(["docker", "image", "inspect", OLD_IMAGE]).stdout)
|
|
272
|
+
assert old["Id"] == OLD_IMAGE
|
|
273
|
+
old_result = command(["docker", "run", "--rm", "--pull", "never", "--network", "none", "--read-only",
|
|
274
|
+
"--entrypoint", "unaltraweb-mcp", OLD_IMAGE, "mcp", "manual-context-export", "--name", "probe"], expected=None)
|
|
275
|
+
assert old_result.returncode == 2 and "invalid choice" in old_result.stderr
|
|
276
|
+
save(output / "old-runtime.json", {"image_id": OLD_IMAGE, "exit_code": old_result.returncode, "stderr": old_result.stderr})
|
|
277
|
+
if args.receiver_python:
|
|
278
|
+
environment = {**os.environ, "PYTHONPATH": str(args.receiver_source.resolve()), "PYTHONDONTWRITEBYTECODE": "1"}
|
|
279
|
+
# Keep a venv interpreter's spelling: resolving its python symlink would
|
|
280
|
+
# silently select the system interpreter and lose the prepared dependencies.
|
|
281
|
+
command([str(args.receiver_python.absolute()), "-B", "-c", RECEIVER, str(output)], env=environment)
|
|
282
|
+
print(json.dumps({"ok": True, "output": str(output), "cases": len(report["cases"]),
|
|
283
|
+
"receipt_sha256": sha((output / "producer-review.json").read_bytes()), "exact_container_absent": True}, indent=2))
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if __name__ == "__main__":
|
|
287
|
+
main()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Synthetic native candidate for the real Actions-v4 transfer regression.
|
|
3
|
+
|
|
4
|
+
No consumer content, publication, secrets, network acquisition or S3 account.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
15
|
+
sys.path[:0] = [str(ROOT), str(ROOT / "src"), str(ROOT / "test")]
|
|
16
|
+
from unaltraweb_mcp import candidate_storage as storage
|
|
17
|
+
import test_release_assets as native
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
22
|
+
parser.add_argument("operation", choices=["prepare", "verify"])
|
|
23
|
+
parser.add_argument("--path", required=True, type=Path)
|
|
24
|
+
parser.add_argument("--sha256", default="")
|
|
25
|
+
args = parser.parse_args()
|
|
26
|
+
fixture = native.ReleaseAssetVerificationTests()
|
|
27
|
+
fixture.setUp()
|
|
28
|
+
try:
|
|
29
|
+
fixture.repository = os.environ.get("GITHUB_REPOSITORY", fixture.repository)
|
|
30
|
+
fixture.reviewed_sha = os.environ.get("GITHUB_SHA", fixture.reviewed_sha)
|
|
31
|
+
fixture.write_assets()
|
|
32
|
+
binding = storage.identity(fixture.repository, fixture.selector, fixture.reviewed_sha,
|
|
33
|
+
os.environ.get("GITHUB_RUN_ID", "123"), os.environ.get("GITHUB_RUN_ATTEMPT", "1"))
|
|
34
|
+
if args.operation == "prepare":
|
|
35
|
+
sha = storage.seal(fixture.assets, args.path, storage.DEFAULT_POLICY, binding)
|
|
36
|
+
if os.environ.get("GITHUB_OUTPUT"):
|
|
37
|
+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as handle:
|
|
38
|
+
handle.write(f"sha256={sha}\n")
|
|
39
|
+
print(json.dumps({"sha256": sha, "synthetic": True, "publishes": False}))
|
|
40
|
+
else:
|
|
41
|
+
storage.verify(args.path, storage.DEFAULT_POLICY, binding, args.sha256)
|
|
42
|
+
arguments = fixture.arguments()
|
|
43
|
+
arguments.assets = args.path / "release-assets"
|
|
44
|
+
result = native.verify_release_assets.verify(arguments)
|
|
45
|
+
print(json.dumps({**result, "synthetic": True, "publishes": False}))
|
|
46
|
+
finally:
|
|
47
|
+
fixture.tearDown()
|
|
48
|
+
return 0
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if __name__ == "__main__":
|
|
52
|
+
raise SystemExit(main())
|
|
@@ -14,11 +14,12 @@ from pathlib import Path
|
|
|
14
14
|
import sys
|
|
15
15
|
import subprocess
|
|
16
16
|
import uuid
|
|
17
|
+
import tarfile
|
|
17
18
|
|
|
18
19
|
ROOT = Path(__file__).resolve().parents[1]
|
|
19
20
|
sys.path.insert(0, str(ROOT / "src"))
|
|
20
21
|
sys.path.insert(0, str(ROOT / "test"))
|
|
21
|
-
from test_manual_context import fixture, write, commit # noqa: E402
|
|
22
|
+
from test_manual_context import fixture, write, commit, computation_fixture # noqa: E402
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
def save(path, value):
|
|
@@ -27,6 +28,18 @@ def save(path, value):
|
|
|
27
28
|
stream.write("\n")
|
|
28
29
|
|
|
29
30
|
|
|
31
|
+
def verify_private_inputs_html(project, result):
|
|
32
|
+
with tarfile.open(project / result["path"]) as archive:
|
|
33
|
+
files = {entry.name: archive.extractfile(entry).read() for entry in archive.getmembers()}
|
|
34
|
+
manifest = json.loads(files["manual-context.json"])
|
|
35
|
+
assert manifest["figures"][0]["caption"] == "Caption `literal`"
|
|
36
|
+
assert manifest["figures"][0]["alt"] == "Alt `code`"
|
|
37
|
+
assert set(files) == {"manual-context.json", *manifest["files"]}
|
|
38
|
+
data = b"".join(files.values())
|
|
39
|
+
assert b"PRIVATE_CHECK_ONLY_SENTINEL" not in data and b"_practices/" not in data
|
|
40
|
+
assert b"UNALTRAWEBEXPORTPROTECTED" not in data
|
|
41
|
+
|
|
42
|
+
|
|
30
43
|
async def export(project, name, image=""):
|
|
31
44
|
from mcp import ClientSession, StdioServerParameters
|
|
32
45
|
from mcp.client.stdio import stdio_client
|
|
@@ -78,6 +91,7 @@ def main():
|
|
|
78
91
|
parser.add_argument("--output", type=Path, required=True)
|
|
79
92
|
parser.add_argument("--single", action="store_true")
|
|
80
93
|
parser.add_argument("--image", default="", help="Already-built MCP image; pull-never, network-disabled fixture stdio")
|
|
94
|
+
parser.add_argument("--private-inputs-html", action="store_true", help="Exercise P1/P2 with explicitly synthetic native computation records")
|
|
81
95
|
args = parser.parse_args()
|
|
82
96
|
output = args.output.resolve()
|
|
83
97
|
if output != args.output or not output.is_relative_to(ROOT / "tmp") or not output.parent.is_dir():
|
|
@@ -86,7 +100,20 @@ def main():
|
|
|
86
100
|
project = output / "manual-fixture"
|
|
87
101
|
project.mkdir()
|
|
88
102
|
fixture(project)
|
|
103
|
+
if args.private_inputs_html:
|
|
104
|
+
write(project, "_practices/fixture/data/input.csv", "PRIVATE_CHECK_ONLY_SENTINEL,1\n")
|
|
105
|
+
write(project, "_practices/fixture/data/parameters.yml", "defaults: &defaults {value: PRIVATE_CHECK_ONLY_SENTINEL}\nselected: *defaults\n")
|
|
106
|
+
computation_fixture(project, inputs=["_practices/fixture/data/input.csv", "_practices/fixture/data/parameters.yml"])
|
|
107
|
+
chapter = project / "_chapters/ca/first.md"
|
|
108
|
+
original = chapter.read_text()
|
|
109
|
+
original = original.replace('{: data-caption-source="Autoria sintètica"}',
|
|
110
|
+
'<img src="assets/img/map.png" alt="Alt `code`" title="Caption `literal`">')
|
|
111
|
+
write(project, "_chapters/ca/first.md", original)
|
|
112
|
+
commit(project, ["_practices/fixture/data/input.csv", "_practices/fixture/data/parameters.yml", ".unaltraweb/computations.yml", ".unaltraweb/computations.lock.json",
|
|
113
|
+
"assets/compute/figure.qmd", "assets/img/figure.svg", "_chapters/ca/first.md"], "P1/P2 synthetic native check inputs")
|
|
89
114
|
first = asyncio.run(export(project, "v1", args.image))
|
|
115
|
+
if args.private_inputs_html:
|
|
116
|
+
verify_private_inputs_html(project, first["export"])
|
|
90
117
|
save(output / "producer-v1.json", first)
|
|
91
118
|
command = [sys.executable, "-B", "-m", "unaltraweb_mcp.cli", "--project", str(project), "mcp", "manual-context-export",
|
|
92
119
|
"--name", "cli-block", "--language", "ca", "--chapter", "first", "--section", "first#method"]
|
|
@@ -96,13 +123,16 @@ def main():
|
|
|
96
123
|
assert cli["ok"] and cli["sections"] == 1 and cli["figures"] == 1, cli
|
|
97
124
|
save(output / "producer-cli.json", {"command": command, "result": cli})
|
|
98
125
|
result = {"ok": True, "synthetic_manual": True, "producer_export_invoked": True, "transport": "mcp-stdio",
|
|
99
|
-
"first": first["export"], "cli_verified": True, "questions_generated": 0
|
|
126
|
+
"first": first["export"], "cli_verified": True, "questions_generated": 0,
|
|
127
|
+
"private_inputs_html": args.private_inputs_html, "computation_render_executed": False}
|
|
100
128
|
if not args.single:
|
|
101
129
|
original = (project / "_chapters/ca/first.md").read_text()
|
|
102
130
|
write(project, "_chapters/ca/first.md", original + "\nSegona versió: text afegit.\n")
|
|
103
131
|
write(project, "_chapters/ca/second.md", "---\ntitle: Segon\nref: second\nlang: ca\nweight: 20\n---\nCapítol afegit en la segona versió.\n")
|
|
104
132
|
commit(project, ["_chapters/ca/first.md", "_chapters/ca/second.md"], "Second fixture revision")
|
|
105
133
|
second = asyncio.run(export(project, "v2", args.image))
|
|
134
|
+
if args.private_inputs_html:
|
|
135
|
+
verify_private_inputs_html(project, second["export"])
|
|
106
136
|
save(output / "producer-v2.json", second)
|
|
107
137
|
result["next"] = second["export"]
|
|
108
138
|
assert first["export"]["manual"]["id"] == second["export"]["manual"]["id"]
|