Release 2.7.0: executable handbooks and native user-site workflows

This commit is contained in:
cflmy committed 2026-11-10 17:03:06 +08:00
1 parent aa0c4d0f55
commit d9aef957f7
562 files changed
+21064 -20387

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
---
name: marqdo-dev
description: Write, refactor and verify Marqdo programs, standard libraries and extensions through the executable development handbook. Use native Marqdo file tools and marqdo call; extend capability gaps through plugins or explicit external tools.
---
Read [the executable development entry](../marqdo-dev/index.mq.md), then [the programming guide](../../doc/library-development.mq.md). The same guide governs programs, libraries and executable SKILLs. For installed skills, resolve these paths against the Marqdo source checkout.
Use `**statement**` to execute and `*return*` to return; write `[intent](actual code)` inside executable positions, and `access(coll, key)` to read collections. The guide provides real examples. Native file tasks live in [files.mq.md](../marqdo-dev/files.mq.md): read, bounded excerpt, write, patch, search, inventory, audit and apply. Use excerpt for long generated lines; its source locations remain one-based and clipped text is inspection evidence, not replacement source. Do not generate Python or shell programs for ordinary file operations.
Prepare the native engineering plugin with the development entry before using its analysis or process tasks. The repository development binary is `target/debug/marqdo`; installed older binaries may need a bootstrap Cargo build through `lib/sys.mq.md exec`. All subsequent task execution uses `marqdo call`. Keep decisions and sequencing in readable mq.md; use a new extension or a documented foreign tool only for a real capability gap.
The guide is authoritative for narrative over 50%, immediate parameter/return tables, inline statements and returns, GFM data, index.mq.md organization, recursive Markdown web components, failure evidence and verification. Read each task's contract and grant its actual effects. External processes retain their OS authority. Do not rewrite intentional test fixtures or restore removed compose_* APIs.
Use the development entry's audit task to discover and review maintained repository sources. Its failed Result retains every finding; write_report=True saves the same evidence under .marqdo/audit. It does not execute inspected source or treat known placeholder warnings as completed logic.
Build current WASM with the entry's build_browser task. If the system target is incompatible, call [toolchain.mq.md](../marqdo-dev/toolchain.mq.md) rust_wasm_linux and pass its returned compiler path. Prepare the workspace browser driver with prepare_browser, then run test_browser for actual SPA/history and two-tab collaboration behavior. These tasks retain native file IO and use existing compiler/browser tools only at their documented boundaries.
+108
View File
@@ -0,0 +1,108 @@
---
markup: occlusion
title: Real browser preparation and verification through Marqdo
import:
fs: lib/fs.mq.md
sys: lib/sys.mq.md
re: lib/re.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
engineering: ext/engineering/index.mq.md
---
Build current browser assets through the development entry's build_browser task. This module prepares the external browser driver and runs the actual UI cases, including the native browser-effects demonstration and both complete literary sites. Files and orchestration remain native Marqdo; browser automation is a documented external capability, and no Python program performs the development workflow.
## prepare
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | "1.65.0" | Pinned Playwright package version verified by this repository |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result of workspace-local dependency and Chromium preparation |
Use `version`="1.65.0" to prepare the external browser-test driver under .marqdo/browser-tests. Node, npm and Playwright are explicit test-tool boundaries; the application itself remains Marqdo, and each test starts the real server through marqdo call. Native filesystem operations create the selected workspace directories. The package and browser caches stay there, with no global npm installation or Python runner. Grant plugin, process.exec and fs.write.
Preparation is separate from verification because installing a browser does not test a page. Each command must succeed before the next one starts. The pinned version and child-only PLAYWRIGHT_BROWSERS_PATH make the driver reproducible. If a required system library is absent, preserve the actual error rather than reporting browser validation as complete. This task changes no application source or repository package manifest.
1. not [A pinned stable package version](re.is_match(text=`version`, pattern="^[0-9]+[.][0-9]+[.][0-9]+$"))
Return *[Require an explicit stable package version](result.error(code="browser.version", message="use a pinned numeric Playwright version"))*.
We **[Create the task-owned workspace tool directory](fs.make_dirs(path=".marqdo/browser-tests"))**.
We **package = "playwright@" + version**.
`install_args` =
| argument |
|---|
| npm |
| install |
| "--prefix" |
| .marqdo/browser-tests |
| "--cache" |
| .marqdo/browser-tests/npm-cache |
| "--no-save" |
| "--package-lock=false" |
| `package` |
We **installed = [Prepare the pinned external browser driver](engineering.checked(argv=`install_args`, timeout_ms=180000, max_output=65536))**.
1. not access(`installed`, "ok")
Return *installed*.
We **cache = sys.cwd() + "/.marqdo/browser-tests/browsers"** and **environment = [Keep browser downloads inside this workspace](table.put(in=None, at="PLAYWRIGHT_BROWSERS_PATH", value=`cache`))**.
`browser_args` =
| argument |
|---|
| node |
| .marqdo/browser-tests/node_modules/playwright/cli.js |
| install |
| chromium |
Return *[Prepare the actual headless Chromium runtime](engineering.checked(argv=`browser_args`, env=`environment`, timeout_ms=300000, max_output=65536))*.
## verify
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| out | text | ".marqdo/browser-handbook-assets" | Current build_browser output directory |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result from real browser effects, SPA, collaboration, bilingual network and bilingual complete-site browser cases |
Use `out`=".marqdo/browser-handbook-assets" after build_browser has produced the current WASM and prepare has installed the pinned browser driver. This task copies only the two named generated runtime assets with native Marqdo file operations; client sources remain in their project directories. Both source artifacts must exist before any example is staged. Grant plugin, process.exec and fs.write.
The external Node test harness supplies browser automation and process supervision only. It starts each application's callable serve function on a selected loopback port, then uses the actual WASM, DOM events, history and WebSocket transport. The browser-effects case verifies duplicate-row identity, literal labels, clipboard/download payloads, completed draft storage, timer cancellation, real history, ordered HTTP success/failure records and local WebSocket echo. SPA checks cover native list records, editing quoted text, new ids and back/forward behavior. Two tabs verify presence, remote snapshots, the first local edit after a remote update and an empty document. The English and Chinese network-site cases uses an owned database created and removed through native Marqdo file calls, verifying real echo, form-validation retry, current article data and authenticated administration. The complete English and Chinese sites also verify original theme declarations, current card/detail separation, real session navigation, the gated custom desk and logout. Their font requests are explicitly aborted so local acceptance proves declared families and fallback rendering, not external font delivery. Narrow viewport checks expose layout overflow. A saved native report retains actual failures; a source contract or constructed effect map is not substituted for a browser result.
We **wasm = out + "/marqdo_wasm.wasm"** and **bridge = out + "/marqdo-bridge.js"**.
1. not [The current WASM exists](fs.exists(path=`wasm`)) or not [The canonical bridge exists](fs.exists(path=`bridge`))
Return *[Require a real current browser build](result.error(code="browser.assets", message="call build_browser before browser verification"))*.
`sites` =
| path |
|---|
| examples/browser-app/static |
| examples/web-spa-app/static |
| examples/web-collab-doc/static |
| examples/web-net-site/public/generated |
| examples/web-net-site-zh/public/generated |
- [Stage only the two generated browser resources](for sites as directory)
We **[Keep the static destination inside the granted root](fs.make_dirs(path=`directory`))**.
We **wasm_dest = directory + "/marqdo_wasm.wasm"** and **bridge_dest = directory + "/marqdo-bridge.js"**.
We **[Copy the actual current WASM natively](fs.copy_file(src=`wasm`, dest=`wasm_dest`))** and **[Copy the canonical bridge natively](fs.copy_file(src=`bridge`, dest=`bridge_dest`))**.
We **cache = sys.cwd() + "/.marqdo/browser-tests/browsers"** and **environment = [Use only the prepared workspace browser cache](table.put(in=None, at="PLAYWRIGHT_BROWSERS_PATH", value=`cache`))**.
`argv` =
| argument |
|---|
| node |
| "--test" |
| tests/browser_handbook.mjs |
We **observed = [Run actual browser interaction tests](engineering.checked(argv=`argv`, env=`environment`, timeout_ms=150000, max_output=65536))**.
We **[Retain the actual test report with native IO](fs.write_json(path=".marqdo/browser-tests/result.json", value=`observed`))**.
Return *observed*.
+73
View File
@@ -0,0 +1,73 @@
---
markup: occlusion
title: Native verification for Markdown data refactors
import:
document: lib/document.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
---
Extract static literal tables into readable Markdown data leaves while callable sources explain their use. Compare actual old function values with the new native parser before applying source changes. These pure tasks do not execute the supplied data as a program or mutate files.
## literal_tables
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| specifications | list | required | Records with a unique key and literal Markdown table text |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing ordered key/value records for all selected literal tables |
Use `specifications` to inspect a planned Markdown data split before writing it. Each key identifies the original file and function, while text carries that table's exact source. The standard document parser preserves native literal types and shapes and refuses dynamic expressions. No file, import, process or code fence is executed. Duplicate identities are a failed Result rather than an overwritten observation, and parser diagnostics retain their actual failure. This task is pure; it supplies data evidence, not permission to replace source.
We **rows = [Start the ordered literal evidence](table.empty_list())** and **keys = [Track exact source identities](table.empty_list())**.
- [Read every explicitly selected literal table](for specifications as specification)
We **key = [Read its source identity](access(`specification`, "key"))** and **source = [Read its exact table source](access(`specification`, "text"))**.
1. [This identity was already observed](table.contains(list=`keys`, item=`key`))
Return *[Keep duplicate source identity explicit](result.error(code="data.duplicate", message=`key`, operation="literal_tables"))*.
We **value = [Use the native literal table parser](document.table(text=`source`))** and **keys = [Retain this identity](table.append(list=`keys`, item=`key`))**.
`row` =
| key | value |
|---|---|
| `key` | `value` |
We **rows = [Keep the complete native value](table.append(list=`rows`, item=`row`))**.
Return *[Expose ordered immutable data evidence](result.ok(value=`rows`))*.
## compare
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| expected | list | required | Baseline key/value records obtained from actual original functions |
| actual | list | required | Key/value records obtained from the proposed literal data |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with exact count and the source keys whose native values differ |
Use `expected` and `actual` for a data-only refactor review. Identities and cardinality are checked before any source mutation, then values are compared through native equality. A boolean must remain a boolean, and row/column/list structure must remain the same. The failed Result keeps mismatched identities in value, allowing --require-ok to stop a migration without losing evidence. This task neither writes files nor declares a later behavioral change equivalent; deliberate content edits need their own review.
We **mismatched = [Start actual data differences](table.empty_list())** and **expected_keys = [Read baseline identities](table.pluck(list=`expected`, key="key"))** and **actual_keys = [Read proposed identities](table.pluck(list=`actual`, key="key"))**.
1. len(`expected`) != len(`actual`) or len(table.unique(list=`expected_keys`)) != len(`expected`) or len(table.unique(list=`actual_keys`)) != len(`actual`)
Return *[Reject missing or repeated data identities](result.error(code="data.identities", message="baseline and actual must have equal counts and unique keys", operation="compare"))*.
- [Compare each source's actual native value](for expected as row)
We **key = [Read its identity](access(`row`, "key"))** and **found = [Find the corresponding proposed value](table.find(list=`actual`, key="key", value=`key`))** and **same = False**.
1. `found` != None
We **same = [Compare original and proposed types and shapes](access(row, "value") == access(found, "value"))**.
1. not `same`
We **mismatched = [Retain the differing source identity](table.append(list=`mismatched`, item=`key`))**.
We **count = [Keep the actual baseline count](len(expected))**.
`evidence` =
| count | mismatched |
|---|---|
| `count` | `mismatched` |
1. len(`mismatched`) == 0
Return *[Retain the unchanged data evidence](result.ok(value=`evidence`))*.
We **failed = [Keep the refactor incomplete](result.error(code="data.value_drift", message="inspect the mismatched source keys", operation="compare"))**.
Return *[Preserve differences on failure](table.put(in=`failed`, at="value", value=`evidence`))*.
+476
View File
@@ -0,0 +1,476 @@
---
markup: occlusion
title: Native repository file operations
import:
fs: lib/fs.mq.md
re: lib/re.mq.md
hash: lib/hash.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
engineering: ext/engineering/index.mq.md
---
Repository development reads and writes through Marqdo's own filesystem tools.
These functions are the same operations used by the handbooks, not shell text
that another agent must regenerate. Paths stay under the granted filesystem
root; pass --fs-root . at the checkout root. read/search need fs.read, while
write/patch need fs.write. Writes imply reads but grant no process or network IO.
A write is an explicit edit requested by the caller. Read the current file and
review the intended change before writing; these functions do not decide which
files belong to a task. Patch is useful for a unique bounded change; write is
useful for an explicitly reviewed complete artifact. Neither creates parent
directories implicitly, and neither promises a transaction across multiple files.
## read
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | UTF-8 source path under --fs-root |
| 返回 | 类型 | 说明 |
|---|---|---|
| source | text | Exact UTF-8 file contents without interpretation |
Use `path` to read a source document before editing it. The returned text is
data: embedded bold, returns, imports and shell-looking content are not run.
A missing path, invalid UTF-8 or root escape produces the native filesystem
diagnostic. For binary data use lib/fs.read_bytes or read_chunk instead.
After selecting the source we return *[Read the actual UTF-8 artifact](fs.read_text(path=`path`))*.
## write
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | Destination under --fs-root; parent must exist |
| source | text | required | Reviewed complete UTF-8 content, including intentional newlines |
| 返回 | 类型 | 说明 |
|---|---|---|
| sha256 | text | SHA256 of the bytes actually written |
Use `path` and `source` for an explicit authored artifact. JSON argument input
carries quotes, Unicode, literal dollar signs and newlines without generating
a program in another language. Existing files are replaced only because the
caller selected write. A single-file atomic replacement does not turn a batch
of writes into a transaction or erase unrelated work on failure.
We **written = [Atomically replace this selected UTF-8 artifact](fs.atomic_write(path=`path`, text=`source`))**.
After writing, return *[Hash the actual resulting file](fs.file_hash(path=`path`))*.
## patch
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | Existing UTF-8 file under --fs-root |
| find | text | required | Exact nonempty fragment that occurs once |
| replace | text | required | Reviewed replacement fragment |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Native patch result; missing/ambiguous matches are diagnostics |
Use `path`, `find` and `replace` when changing one known part of a file.
The exact-match requirement catches drift between reading and editing, though
it is not a concurrent kernel compare-and-swap. A whole-file replacement belongs
to write. This helper never falls back to a model-generated search-and-replace
program when the old fragment no longer matches.
Once the bounded change is reviewed, return *[Apply one exact native text patch](fs.text_patch(path=`path`, find=`find`, replace=`replace`))*.
## search
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | "." | Selected source directory under --fs-root |
| pattern | text | required | Unicode regex applied to each source line |
| glob | text | "**/*.mq.md" | File pattern; choose **/*.rs for runtime code |
| 返回 | 类型 | 说明 |
|---|---|---|
| matches | list | Records with path, one-based line and original text |
Use `path`=".", `pattern` and `glob`="**/*.mq.md" to search actual sources.
The native walker does not traverse symlinks and prunes generated/cache trees.
Reading remains UTF-8 and bounded by the filesystem implementation. Each result
retains its source path and line so an agent can read that artifact rather than
guessing from a detached snippet. This is a source query, not a code execution.
`excluded` =
| pattern |
|---|
| .git/** |
| **/target/** |
| **/node_modules/** |
| **/.marqdo/** |
| **/vendor/** |
| **/__pycache__/** |
We **paths = [Find source files through the native filesystem](fs.find(path=`path`, pattern=`glob`, exclude=`excluded`))** and
**matches = [Start the source-location result list](table.empty_list())**.
- [Read each selected text source](for paths as file)
We **actual_path = path + "/" + file** and
**lines = [Read its UTF-8 lines](fs.read_lines(path=`actual_path`))** and **number = 0**.
- [Test the requested expression against each line](for lines as source)
We **number = number + 1** to retain one-based source coordinates.
1. [This line matches the requested source query](re.is_match(text=`source`, pattern=`pattern`))
`hit` =
| path | line | text |
|---|---|---|
| `actual_path` | `number` | `source` |
We **matches = [Retain this source location](table.append(list=`matches`, item=`hit`))**.
When the selected sources are exhausted we return *matches*.
## read_many
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| paths | list | required | Explicit UTF-8 source paths selected for one review batch |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Sources and hashes for the exact requested files |
Use `paths` when reviewing a small related batch. Native filesystem reads
preserve the full UTF-8 text; hashes identify the exact returned source used to prepare a patch. The digest is
computed from that text, so a later filesystem change cannot pair new bytes with
an older source in the same record.
Reading does not run imports, main or embedded code. Choose a bounded batch so
the returned source remains useful to the agent rather than dumping a whole
repository into one response. Any missing or escaping path is a native error.
The same path/hash pair can be passed to apply for a preflight drift check.
We **records = [Start the source review batch](table.empty_list())**.
- [Read only the selected artifacts](for paths as path)
We **source = [Read the exact UTF-8 source](fs.read_text(path=`path`))** and
**sha256 = [Identify the bytes used for this review](hash.sha256(text=`source`))**.
`record` =
| path | source | sha256 |
|---|---|---|
| `path` | `source` | `sha256` |
We **records = [Retain the source and its observed identity](table.append(list=`records`, item=`record`))**.
Return *records* after reading the selected batch.
## inventory
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| paths | list | required | Explicit source paths to inspect without executing |
| include_body | bool | False | Include compiler AST debug evidence for a migration |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Source, hash and actual compiler analysis for each selected artifact |
Use `paths` and `include_body`=False for an authored source review.
Marqdo reads each file through lib/fs, then sends its text to the compiler-backed
extension analyzer. The analyzer parses the same language, supplies real
parameters/defaults/contracts and measures each function's narrative ratio.
Imports are not executed or followed by this text inspection; full program checks
still use marqdo check. It needs fs.read and the engineering plugin, and makes no
network request or edit. A parse failure stays attached to that file as a Result
instead of making the rest of the inventory disappear.
We **records = [Start the executable source inventory](table.empty_list())**.
- [Inspect the selected source with its actual compiler](for paths as path)
We **source = [Read the original source through the native filesystem](fs.read_text(path=`path`))** and
**sha256 = [Retain its observed byte identity](hash.sha256(text=`source`))** and
**analysis = [Parse contracts and statements without running them](engineering.analyze(source=`source`, include_body=`include_body`))**.
`record` =
| path | source | sha256 | analysis |
|---|---|---|---|
| `path` | `source` | `sha256` | `analysis` |
We **records = [Keep the actual per-file evidence](table.append(list=`records`, item=`record`))**.
Return *records* after the requested source inventory.
## apply
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| updates | list | required | Reviewed records containing path/source and optional expected_sha256 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing paths and SHA256 values actually written |
Use `updates` to apply a reviewed batch through native file IO. Each record
selects its path and complete source; expected_sha256 optionally ties that edit
to the previously read version. All supplied digests and duplicate destinations
are checked before the first write, preventing an ordinary stale review from
partially changing the batch. Path access checks also happen before writing.
This is still not a multi-file transaction or a kernel CAS. Each file replacement
is atomic on its own; a later disk failure can leave earlier reviewed files
written. Parent directories must already exist. A deliberate new file can omit
expected_sha256, while updating an observed file should retain its hash.
The result lists actual file hashes rather than claiming compliance with a style
rule. Call the static and behavioral checks after applying the batch.
We **seen = [Start the destination preflight list](table.empty_list())**.
- [Preflight every reviewed destination before writing](for updates as update)
We **path = [Read the selected destination](access(update, "path"))** and
**exists = [Apply the native root policy before any write](fs.exists(path=`path`))** and
**expected = [Read its optional reviewed source identity](table.get(map=`update`, key="expected_sha256"))**.
1. [This destination occurs twice](table.contains(list=`seen`, item=`path`))
Return *[Reject duplicate writes in one batch](result.error(code="authoring.duplicate", message=`path`, operation="files.apply"))*.
1. `expected` != None
1. not `exists`
Return *[Keep a missing reviewed artifact visible](result.error(code="authoring.missing", message=`path`, operation="files.apply"))*.
1. fs.file_hash(path=`path`) != `expected`
Return *[Refuse a stale reviewed update](result.error(code="authoring.changed", message=`path`, operation="files.apply"))*.
We **seen = [Retain this checked destination](table.append(list=`seen`, item=`path`))**.
We **written = [Start the actual write evidence list](table.empty_list())**.
- [Write each explicit reviewed artifact through Marqdo](for updates as update)
We **path = [Read its checked destination](access(update, "path"))** and
**saved = [Atomically replace the selected UTF-8 content](fs.atomic_write(path=`path`, text=access(update, "source")))** and
**sha256 = [Identify the bytes that were actually written](fs.file_hash(path=`path`))**.
`evidence` =
| path | sha256 |
|---|---|
| `path` | `sha256` |
We **written = [Retain this actual file result](table.append(list=`written`, item=`evidence`))**.
Return *[The completed native edit batch](result.ok(value=`written`))*.
## analyze_updates
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| updates | list | required | Proposed path/source records; no filesystem mutation |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Compiler metadata for each proposed artifact |
Use `updates` before applying an authored batch. Each proposal is analyzed
as text by the real compiler without replacing the current file or executing
the proposal. The path is an identity label for the report; no untrusted path
is opened here. Parameter order/defaults and statement projections allow a
reviewer to distinguish documentation changes from behavioral changes.
The projection deliberately omits source locations and occlusion labels from
executable statements; it is review evidence, not a proof of all runtime behavior.
Keep real golden calls and backend tests for observable behavior. Parse failures
remain per-file Results so another proposal's valid syntax cannot mask them.
We **reports = [Start the proposed-source review](table.empty_list())**.
- [Analyze one proposed artifact without writing it](for updates as update)
We **path = [Retain its intended destination label](access(update, "path"))** and
**source = [Read the proposed UTF-8 value](access(update, "source"))** and
**analysis = [Use the actual parser and contract checker](engineering.analyze(source=`source`))**.
`report` =
| path | analysis |
|---|---|
| `path` | `analysis` |
We **reports = [Retain the actual compile evidence](table.append(list=`reports`, item=`report`))**.
Return *reports* after analyzing all proposals.
## _missing_contracts
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| functions | list | required | Compiler-projected function tree from engineering.analyze |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Executable functions whose return contract is missing |
Use `functions` from the compiler projection; never infer functions by scanning
hash-prefixed source lines. Content-only headings have no executable statements
and are omitted, so a prose section does not acquire a fictional return table.
Nested functions are inspected recursively and retain compiler source lines.
This is a pure structural check. The compiler separately checks declared
parameter names and types. A return table's presence is not proof that prose is
accurate or that an effectful function behaves correctly. Keep runtime tests for
those properties. The source tree is ordinary data and no imports are executed.
We **missing = [Start the actual missing-contract findings](table.empty_list())**.
- [Inspect real callable units and their nested definitions](for functions as function)
We **contract = [Read its parsed public contract](access(function, "contract"))** and
**active = [Distinguish executable units from content-only headings](len(access(function, "semantic")) > 0)**.
We **missing_return = True** until an actual return contract is observed.
1. `contract` != None
We **missing_return = [Inspect the existing contract without indexing None](access(contract, "returns") == None)**.
1. `active` and `missing_return`
We **name = [Keep the exact callable name](access(function, "name"))** and **line = [Keep its source location](access(function, "line"))**.
`finding` =
| name | line | issue |
|---|---|---|
| `name` | `line` | "missing return contract" |
We **missing = [Retain the source-based finding](table.append(list=`missing`, item=`finding`))**.
We **nested = [Inspect child definitions by the same rule](_missing_contracts(functions=access(function, "children")))** and
**missing = [Combine findings without executing a function](table.concat(a=`missing`, b=`nested`))**.
Return *missing* for the caller's report.
## _active_lines
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| functions | list | required | Compiler-projected function tree |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Source heading lines belonging to executable units |
Use `functions` from the compiler projection. An executable statement or a
declared parameter makes a unit part of the callable audit; a plain content
heading is not a zero-length program. This distinction also covers field-only
object schemas, which use field contracts rather than fictional return tables.
The walk includes nested definitions and retains their actual heading lines.
It is a pure projection, not a source-text pattern or an import traversal.
An explicit return of None and an empty-payload assignment are still statements,
so intentionally unfinished callable code stays visible to the authoring checks.
The compiler's narrative measurements are used unchanged for every selected unit.
We **lines = [Start the actual executable heading locations](table.empty_list())**.
- [Inspect real declarations and their nested definitions](for functions as function)
1. len(access(`function`, "semantic")) > 0 or len(access(`function`, "params")) > 0
We **lines = [Retain this executable source unit](table.append(list=`lines`, item=access(function, "line")))**.
We **nested = [Inspect nested source units by the same rule](_active_lines(functions=access(function, "children")))** and
**lines = [Keep the combined executable locations](table.concat(a=`lines`, b=`nested`))**.
Return *lines* for matching the unchanged narrative measurements.
## audit
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| paths | list | required | Explicit maintained source paths; exclude intentional invalid fixtures |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with compact per-file parser, narrative and contract findings |
Use `paths` for a selected maintained source batch. The same compiler that
runs Marqdo parses each source, checks declared contracts and measures narrative
per function. This task reads through the native filesystem and gives the plugin
only source text. It neither executes imports nor writes files. Requires
fs.read and plugin; it performs no network request.
A ratio at or below one half is a finding, including a data-heavy callable.
Do not solve findings by adding repeated filler or inventing return values for
pure content. Reorganize large code/data into useful modules and explain actual
inputs, decisions and limits. This structural audit is an editing aid; run check
for dependency validation and real cases for behavioral and visual results.
Pure content headings are excluded from callable ratios. Compiler warnings stay
in diagnostics for review; errors, parser failures and authoring gaps make the
batch incomplete. This allows a documented empty-payload demonstration to retain
its warning without replacing the example with fake business logic.
The result retains all selected file findings even if one fails parsing. A
complete batch returns ok=true. An incomplete batch returns ok=false with the
same evidence in value, so --require-ok can stop automation without discarding
the review report. Missing files or root violations remain native diagnostics.
Newline-bearing paths have no special meaning here; they are ordinary input data.
We **reports = [Start the compact source review](table.empty_list())** and **complete = True**.
- [Audit every explicitly selected source without running it](for paths as path)
We **source = [Read the source using native Marqdo IO](fs.read_text(path=`path`))** and
**analysis = [Use the actual compiler projection](engineering.analyze(source=`source`))** and
**parse_ok = [Retain whether parsing succeeded](access(analysis, "ok"))** and
**diagnostics = [Start this file diagnostic list](table.empty_list())** and
**ratio_gaps = [Start this file narrative findings](table.empty_list())** and
**missing_contracts = [Start this file contract findings](table.empty_list())**.
1. `parse_ok`
We **data = [Read the successful source projection](access(analysis, "value"))** and
**diagnostics = [Retain genuine contract diagnostics](access(data, "diagnostics"))** and
**missing_contracts = [Inspect executable units recursively](_missing_contracts(functions=access(data, "functions")))**.
We **ratios = [Read the measured function units](access(data, "ratios"))** and **active_lines = [Identify actual executable units](_active_lines(functions=access(data, "functions")))**.
- [Review the narrative measure of each unit](for ratios as ratio)
We **line = [Read the measured source heading location](access(ratio, "line"))**.
1. [This is an executable source unit](table.contains(list=`active_lines`, item=`line`)) and access(`ratio`, "ratio") <= 0.5
We **ratio_gaps = [Retain this function and its actual measured ratio](table.append(list=`ratio_gaps`, item=`ratio`))**.
1. not `parse_ok`
We **diagnostics = [Retain the real parser failure](table.append(list=`diagnostics`, item=access(analysis, "error")))**.
We **errors = 0** before examining the diagnostic severities.
- [Keep errors separate from expected illustrative warnings](for diagnostics as diagnostic)
We **severity = [Read a diagnostic severity when provided](table.get(map=`diagnostic`, key="severity"))**.
1. `severity` == "error"
We **errors = errors + 1**.
We **ok = [Require all structural checks for this file](parse_ok and errors == 0 and len(ratio_gaps) == 0 and len(missing_contracts) == 0)**.
1. not `ok`
We **complete = False** to retain the incomplete batch state.
`report` =
| path | ok | diagnostics | ratio_gaps | missing_contracts |
|---|---|---|---|---|
| `path` | `ok` | `diagnostics` | `ratio_gaps` | `missing_contracts` |
We **reports = [Retain this file evidence without its full source dump](table.append(list=`reports`, item=`report`))**.
We **count = [Retain the actual number of selected sources](len(`paths`))**.
`evidence` =
| complete | count | reports |
|---|---|---|
| `complete` | `count` | `reports` |
1. `complete`
Return *[The complete structural evidence](result.ok(value=`evidence`))*.
We **failed = [Retain the incomplete authoring result](result.error(code="authoring.incomplete", message="inspect the per-file findings in value", operation="files.audit"))**.
Return *[Keep the report available on failure](table.put(in=`failed`, at="value", value=`evidence`))*.
## excerpt
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | UTF-8 artifact under --fs-root |
| start | number | 1 | First one-based line to inspect |
| count | number | 40 | Number of lines, from 1 through 200 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | A record with total_lines and selected {line,text} records; each line is clipped to 2000 characters |
Use `path`, `start`=1 and `count`=40 when a generated HTML line or a large source file would overflow the agent's output window. Line numbers refer to the original file, so the excerpt can guide a precise later read or patch. This is a bounded inspection view: clipping does not alter the file or turn a truncated excerpt into suitable replacement source. Start and count must be positive integral numbers; selection past the end returns no lines. The native reader still validates UTF-8 and the granted filesystem root.
We **lines = [Read UTF-8 lines through the native filesystem](fs.read_lines(path=`path`))**.
1. `start` < 1 or `count` < 1 or `count` > 200
Return *[Explain the supported inspection window](result.error(code="files.excerpt_window", message="start >= 1; count must be 1..200"))*.
We **selected = [Select only the requested line range](table.slice(list=`lines`, start=(`start` - 1), end=(`start` - 1 + `count`)))** and **records = [Start the source-location list](table.empty_list())**.
We **number = [Keep the original first line number](start)**.
- [Inspect each selected line](for selected as line)
We **visible = [Limit one generated line to 2000 characters](re.replace(text=`line`, pattern="(?s)\\A(.{0,2000}).*\\z", with="$1"))**.
`record` =
| line | text |
|---|---|
| `number` | `visible` |
We **records = [Retain the original location and readable text](table.append(list=`records`, item=`record`))**.
We **number = [Advance the original line number](number + 1)**.
We **total = [Count the actual source lines](len(lines))**.
`window` =
| total_lines | lines |
|---|---|
| `total` | `records` |
After selecting this window, return *window*.
+225
View File
@@ -0,0 +1,225 @@
---
markup: occlusion
title: 以 Marqdo 本身开发和验证 Marqdo
import:
files: ./files.mq.md
browser_tools: ./browser.mq.md
fs: lib/fs.mq.md
repository: ./repository.mq.md
table: lib/table.mq.md
text: lib/text.mq.md
sys: lib/sys.mq.md
result: lib/result.mq.md
engineering: ext/engineering/index.mq.md
---
本目录是开发智能体的可执行手册。先阅读 [编程规范](../../doc/library-development.mq.md),再按具体任务调用本目录的函数。单文件标准库本身就是手册;只有多文件库或工程才需要 index.mq.md 组织入口。叙述应解释任务、数据、失败和限制,不能靠重复句子凑比例。
日常读写通过 files.mq.md 的 read、excerpt、write、patch、search、inventory 和 apply 完成。批量写入前可携带 expected_sha256,防止覆盖已经变化的源码。大段文本使用 CLI 的 --args-json 文件或标准输入传送;它保留换行、引号、中文和以美元符号开头的字面数据。不要为了搬运源码再生成 Python 或 shell 程序。
原生库能完成的计算和文件操作直接使用 lib。缺少可复用能力时新增拓展库;需要现有操作系统工具时使用 engineering.run 的参数数组。编排、条件、重试和结果判断留在 mq.md 中。process.exec 与 plugin 是真实的外部能力授权,fs-root 不能限制外部进程自己的权限。
调用示例:marqdo call skills/marqdo-dev/index.mq.md prepare_engineering --effects process.exec --fs-root . --json。读取文件可调用 files.mq.md read 并传入 path;修订现有文件优先使用 patch 或带哈希的 apply。每个真实函数标题下都应先给出参数和返回值表,然后是能够独立指导调用者的叙述。
## prepare_engineering
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:构建工程插件,失败时保留 Cargo 输出 |
第一次使用工程拓展前执行此任务。这里通过已有 sys.exec 引导 Cargo 构建本仓库的原生插件,之后开发和发布流程都可以使用同一份工程拓展。构建需要本机 Rust 工具链和已经可用的依赖缓存;不会安装 Python,也不修改版本或发布远端资源。
调用需要 process.exec。子进程退出不为零时返回失败,调用者应查看真实 stderr 并修复编译问题;成功只表示本机插件已构建,不意味着其他平台包已验证。依赖尚未缓存时应按仓库工具链配置获取依赖,再运行同一任务。
`args` =
| argument |
|---|
| "build" |
| "-p" |
| "marqdo" |
| "-p" |
| "marqdo_plugin_engineering" |
| "--offline" |
We **built = [构建已维护的工程边界插件](sys.exec(cmd="cargo", args=`args`, capture=True))**。
1. access(`built`, "code") != 0
返回*[保留构建错误](result.error(code="dev.plugin_build", message=str(`built`), operation="prepare_engineering"))*。
构建完成后返回*[真实 Cargo 证据](result.ok(value=`built`))*。
## check
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | 需要完整检查依赖的真实文件路径 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:编译检查和逐函数叙述比例检查的进程证据 |
使用 `path` 指定本次修改的入口或单文件库。从仓库根目录调用,并授权 plugin。检查器加载真实依赖,验证契约、参数与调用,同时要求函数的叙述比例超过一半。故意损坏的测试夹具和明确标记禁止修改的人工测试不应当被这项作者任务批量改写。
检查通过不能证明页面视觉效果、网络服务或发布凭据正确。根据变更运行实际用例:纯函数比较返回值,文件操作使用临时目录,外部发布操作使用隔离服务夹具。失败时先修复实际问题,保留诊断位置,不通过删除业务能力或补空话来消除告警。
`argv` =
| argument |
|---|
| "target/debug/marqdo" |
| "check" |
| `path` |
| "--narrative-ratio" |
We **checked = [检查真实文件及其可读性](engineering.run(argv=`argv`))**。
检查结束后返回*[按实际退出状态保留通过或失败证据](engineering.check_exit(outcome=`checked`))*。
## audit
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| write_report | bool | False | 保存同一份真实报告到忽略目录 .marqdo/audit |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:实际发现的维护源码与逐文件问题清单 |
使用 `write_report`=False,在仓库根目录授权 plugin 和 fs.read,即可发现维护中的源码并逐个审查。文件枚举、读取和报告写入都由固有能力完成;分析使用真实编译器,不会运行被审查程序或其导入。需要保留证据时传 True 并增加 fs.write。
测试夹具、人工保护样例和历史兼容文件保留既有语义。占位演示的 warning 留在报告中供阅读,不伪造实现以消除提示。失败 Result 仍携带完整清单,因此可结合 --require-ok 阻止后续自动化;比例与契约通过后还应执行实际用例,不能把结构审查当成运行成功。
审查完成后返回*[实际仓库源码的完整观察结果](repository.audit(write_report=`write_report`))*。
## test
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| targets | list | required | 明确选择的 Rust 集成测试目标名称 |
| filter | any | None | 可选测试名称过滤文本;不是 Cargo 命令选项 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:真实 Cargo 退出状态、标准输出与错误输出 |
使用 `targets` 和可选的 `filter`=None,在仓库根目录授权 plugin。目标清单转成逐个 --test 参数,Cargo 在离线模式下执行;这里不会安装依赖、调用 Python 或生成 shell 程序。需要先完成工具链与插件引导,测试使用的本地服务或其他依赖仍按各目标的实际要求准备。
传入的是测试目标名称和可选名称过滤器,不能用空目标清单或把命令选项伪装成过滤文本。构建错误、断言失败、超时与启动失败都返回失败结果;失败仍携带真实执行证据,便于定位哪个用例没有通过。成功只说明所选测试通过,不覆盖未运行的目标,更不能替代发布服务的实际状态验证。名称过滤只缩小用例集合;检查输出中的实际运行数量,避免过滤器没有命中却被当作完成验收。
这个入口把重复的测试命令收进源码手册。修改相关模块后运行对应目标,已通过后只有新改动、失败或未解决的疑问才扩大或重复检查。外部进程保留操作系统权限,--fs-root 不是 Cargo 子进程的沙箱。
1. len(`targets`) == 0
Return *[要求明确的验收范围](result.error(code="dev.test_targets", message="select at least one integration test target", operation="test"))*.
1. `filter` != None
1. [过滤器不能冒充 Cargo 选项](text.starts_with(text=`filter`, prefix="-"))
Return *[拒绝选项形式的过滤文本](result.error(code="dev.test_filter", message="filter is a test name, not an option", operation="test"))*.
`argv` =
| argument |
|---|
| "cargo" |
| "test" |
| "--offline" |
- [将每个目标作为独立参数交给测试工具](for targets as target)
1. [测试目标不能冒充命令选项](text.starts_with(text=`target`, prefix="-"))
Return *[保留错误目标的诊断](result.error(code="dev.test_targets", message=`target`, operation="test"))*.
We **argv = [增加明确的集成测试选择标记](table.append(list=`argv`, item="--test"))** and **argv = [增加原样传入的目标名称](table.append(list=`argv`, item=`target`))**.
1. `filter` != None
We **argv = [追加可选的用例名称过滤器](table.append(list=`argv`, item=`filter`))**.
We **checked = [执行实际离线构建与验收](engineering.run(argv=`argv`, timeout_ms=300000, max_output=2097152))**.
验收结束后返回*[按真实退出状态判断结果并保留输出](engineering.check_exit(outcome=`checked`))*。
## build_browser
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| out | text | ".marqdo/browser-handbook-assets" | Workspace output directory for current WASM and canonical bridge |
| compiler | any | None | Optional absolute rustc path from toolchain.rust_wasm_linux |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with native artifact hashes and the actual bounded build report path |
Use `out`=".marqdo/browser-handbook-assets" and `compiler`=None from the checkout root. This task calls Marqdo's own wasm build operation through the explicit engineering process boundary, then hashes its real outputs with native filesystem tools. If the system compiler lacks a compatible WASM target, first call [the workspace toolchain task](toolchain.mq.md) and pass its returned compiler path. That override applies only to this child process, with no global environment or system installation change.
Grant plugin, process.exec and fs.write. Native directory validation runs before the external build and keeps selected output under the granted root. Compiler logs are bounded and saved natively to .marqdo/build/browser.json; the CLI returns compact evidence so an oversized log does not hide the error. A failed Result remains failed for --require-ok and points to that report. Success includes the hashes of both generated files, not an assumption based on Cargo's exit code. Browser interaction and real HTTP mounting still need their own tests after this build.
We **[Validate and create the selected native output directory](fs.make_dirs(path=`out`))** and **[Create the native build-report directory](fs.make_dirs(path=".marqdo/build"))** and **environment = None**.
1. `compiler` != None
We **environment = [Select this compiler for one child process](table.put(in=None, at="RUSTC", value=`compiler`))**.
`argv` =
| argument |
|---|
| "target/debug/marqdo" |
| wasm |
| build |
| "-o" |
| `out` |
We **execution = [Build the current official browser artifact](engineering.run(argv=`argv`, env=`environment`, timeout_ms=300000, max_output=65536))** and **checked = [Retain actual build success or failure](engineering.check_exit(outcome=`execution`))**.
We **[Save bounded compiler evidence through native IO](fs.write_json(path=".marqdo/build/browser.json", value=`checked`))**.
1. not access(`checked`, "ok")
We **failed = [Keep this build incomplete](result.error(code="dev.browser_build", message="inspect .marqdo/build/browser.json", operation="build_browser"))**.
Return *failed*.
We **wasm = out + "/marqdo_wasm.wasm"** and **bridge = out + "/marqdo-bridge.js"** and **wasm_sha256 = [Hash the actual new WASM](fs.file_hash(path=`wasm`))** and **bridge_sha256 = [Hash the actual canonical bridge](fs.file_hash(path=`bridge`))**.
`receipt` =
| out | wasm_sha256 | bridge_sha256 | report |
|---|---|---|---|
| `out` | `wasm_sha256` | `bridge_sha256` | .marqdo/build/browser.json |
Return *[Expose real browser build evidence](result.ok(value=`receipt`))*.
## prepare_browser
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | "1.65.0" | Pinned Playwright driver version |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result of workspace-local browser driver preparation |
Use `version`="1.65.0" when preparing actual browser tests. The browser handbook keeps dependency installation and browser caches inside the workspace, using native directory operations and explicit existing npm/Playwright tools. Grant plugin, process.exec and fs.write. This prepares a driver only; call build_browser for current runtime artifacts and test_browser for actual behavior. No Python runner or global npm package is required.
Return *[Prepare the pinned external browser capability](browser_tools.prepare(version=`version`))*.
## test_browser
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| out | text | ".marqdo/browser-handbook-assets" | Current native browser build output |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result from actual browser-effects, SPA, collaboration and bilingual network/complete-site browser tests |
Use `out`=".marqdo/browser-handbook-assets" after prepare_browser and build_browser. The browser handbook stages the named runtime files with native IO, then supervises real callable servers and drives current WASM through the official bridge. The test result includes actual failures and is saved under .marqdo/browser-tests. Grant plugin, process.exec and fs.write; use --require-ok to stop a later task when a browser case fails. Constructed effects and source audit results remain separate evidence.
Return *[Verify the actual callable sites in a real browser](browser_tools.verify(out=`out`))*.
## prepare_web
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:当前 Go Web 插件构建的真实退出状态和日志 |
先完成 prepare_engineering,再从仓库根调用并授权 plugin。既有构建脚本负责调用 Go/cgo 编译本仓库的原生 Web 实现,并把编译产物放到插件解析器使用的构建目录。需要本机 Go 与 C 编译工具链;这里不安装工具、不更改全局环境,也不选择新的发布版本。Windows 构建仍须具备脚本要求的 cgo 工具链,Linux 的通过不能替代 Windows 验证。
这个入口把常用插件准备动作保存在可执行手册中。工程边界为子进程传递本仓库的 Git 信任配置,避免 Go 的 VCS 检查因不同文件所有者失败;该配置不写入全局 Git 设置,也不关闭 VCS 来源记录。只有编译和编译产物处理外联维护中的构建工具;日常源码读写仍使用原生文件任务。缺少工具、编译错误或非零退出会保留实际日志并返回失败,不能继续把旧插件当成本轮实现。成功只证明当前平台的插件已构建,随后还需运行对应 HTTP 与浏览器用例。
`argv` =
| argument |
|---|
| bash |
| scripts/build-web-plugin.sh |
构建结束后返回 *[在保留来源记录的受控进程边界编译当前插件](engineering.checked(argv=`argv`, timeout_ms=300000, max_output=65536))*。
+80
View File
@@ -0,0 +1,80 @@
---
markup: occlusion
title: Native audit of the maintained Marqdo repository
import:
files: ./files.mq.md
fs: lib/fs.mq.md
table: lib/table.mq.md
text: lib/text.mq.md
---
This repository task discovers the maintained source scope using native file
operations and passes it to the compiler-backed audit. It is an actual callable
workflow, not a generated inventory script. Read the development index for
bootstrap and the programming guide for how to resolve findings.
Only lib, ext, public, examples, skills and doc are selected. Intentional invalid
tests and protected man-test programs are outside this scope. Historical
.compat.mq.md examples remain compatibility evidence. Compiler warnings on
documented placeholders stay in the report; they do not turn into fake logic.
A report records the current source state, not a promise that the task is done.
## audit
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| write_report | bool | False | Also write the actual Result to .marqdo/audit/handbooks.json |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Actual repository source audit, with evidence retained on failure |
Use `write_report`=False from the checkout root with plugin and fs.read.
Each selected directory is discovered natively; no Python, shell enumeration or
maintained list of hundreds of filenames is needed. Hidden staging trees,
dependency installs and build outputs are pruned. The historical compatibility
suffix is the only source-name exclusion within this maintained scope.
The audit does not run found programs or load their imports. It reports source
parser/contract errors, missing callable return contracts and executable-unit
narrative gaps. Actual dependency checks, behavior, rendering and service
publication require their own workflow tests. An incomplete source report is
returned as a failed Result so --require-ok stops automation.
Set write_report=True and grant fs.write to retain the same actual evidence
under the ignored audit directory. This intentionally replaces that generated
report; it never rewrites a program to silence a finding. A later audit reflects
later files, and a historical report does not establish compliance of new edits.
Missing selected directories retain a native error rather than silently narrowing
the task to make it appear complete.
`directories` =
| path |
|---|
| "lib" |
| "ext" |
| "public" |
| "examples" |
| "skills" |
| "doc" |
`excluded` =
| pattern |
|---|
| "**/.marqdo/**" |
| "**/node_modules/**" |
| "**/target/**" |
We **paths = [Start the currently discovered source scope](table.empty_list())**.
- [Discover maintained modules through native file operations](for directories as directory)
We **names = [Discover actual Marqdo source files](fs.find(path=`directory`, pattern="**/*.mq.md", exclude=`excluded`))**.
- [Keep current sources while preserving historical compatibility examples](for names as relative)
1. not [This file is an explicitly historical compatibility source](text.ends_with(text=`relative`, suffix=".compat.mq.md"))
We **path = directory + "/" + relative** and **paths = [Retain this actual maintained source](table.append(list=`paths`, item=`path`))**.
We **observed = [Audit the actual discovered sources without executing them](files.audit(paths=`paths`))**.
1. `write_report`
We **directory = [Prepare only the ignored generated audit directory](fs.make_dirs(path=".marqdo/audit"))** and
**saved = [Retain the same real success or failure evidence](fs.write_json(path=".marqdo/audit/handbooks.json", value=`observed`))**.
Return *observed* with all incomplete findings intact.
+134
View File
@@ -0,0 +1,134 @@
---
markup: occlusion
title: Workspace-only Rust toolchain for real WASM validation
import:
fs: lib/fs.mq.md
net: lib/net.mq.md
re: lib/re.mq.md
text: lib/text.mq.md
table: lib/table.mq.md
sys: lib/sys.mq.md
result: lib/result.mq.md
engineering: ext/engineering/index.mq.md
---
This development tool handles one concrete environment gap: a compatible Linux x86 compiler and WASM standard library. Native Marqdo handles files, HTTP, SHA256 and decisions; the existing tar executable handles the official xz archive format. Call rust_wasm_linux, then pass its compiler path as the child RUSTC for the ordinary Marqdo wasm build command. Other operating systems use their own supported toolchain setup.
## rust_wasm_linux
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | "1.93.1" | Pinned stable Rust version for the isolated Linux x86 toolchain |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with compiler path, matching host/WASM standard libraries and native digest receipts |
Use `version`="1.93.1" on Linux x86 when the current compiler has no compatible wasm32-unknown-unknown standard library. The task prepares a complete official compiler plus its matching host and WASM standard libraries in the reserved .marqdo/toolchain cache. A distribution compiler rebuilt from source can reject official precompiled metadata even when its visible release number is identical; installing only one target archive is therefore insufficient in that case. This task changes no system compiler, global environment, shell profile or Python setup. The returned compiler path can be passed as RUSTC in a single engineering process environment.
Run from the checkout root with plugin, process.exec, fs.read, fs.write and network.read. Each download is bounded and verified against its official checksum before tar extracts a component. Failures preserve their real evidence and stop the remaining sequence. Repeating the task rechecks cached bytes rather than assuming an existing filename is valid. The final compiler probe must report the requested version before a manifest is written. The result proves toolchain preparation; a separate wasm build and browser test must still verify this repository's artifact.
1. not [A stable numeric release](re.is_match(text=`version`, pattern="^[0-9]+[.][0-9]+[.][0-9]+$"))
Return *[Explain the required version shape](result.error(code="toolchain.version", message="use a stable numeric Rust release"))*.
We **directory = ".marqdo/toolchain/rust-linux-x86-" + version** and **receipts = [Start verified distribution receipts](table.empty_list())**.
We **[Create this task-owned workspace directory](fs.make_dirs(path=`directory`))**.
`components` =
| @ | component | target |
|---|---|---|
| 1 | rustc | x86_64-unknown-linux-gnu |
| 2 | rust-std | x86_64-unknown-linux-gnu |
| 3 | rust-std | wasm32-unknown-unknown |
- [Prepare matching compiler and target components](for components as specification)
We **installed = [Download, verify and extract this exact component](_component(version=`version`, component=access(specification, "component"), target=access(specification, "target"), directory=`directory`))**.
1. not access(`installed`, "ok")
Return *installed*.
We **receipts = [Retain its native digest receipt](table.append(list=`receipts`, item=access(installed, "value")))**.
We **compiler = sys.cwd() + "/" + directory + "/bin/rustc"** and **probed = [Verify the extracted compiler actually starts](engineering.checked(argv=table.append(list=table.append(list=table.empty_list(), item=`compiler`), item="--version"), timeout_ms=30000, max_output=32768))**.
1. not access(`probed`, "ok")
Return *probed*.
We **reported = [Read the actual compiler version](access(access(`probed`, "value"), "stdout"))**.
1. not [The requested release was installed](text.starts_with(text=`reported`, prefix=("rustc " + `version` + " ")))
Return *[Retain the unexpected compiler identity](result.error(code="toolchain.compiler", message=`reported`))*.
`manifest` =
| version | compiler | components |
|---|---|---|
| `version` | `compiler` | `receipts` |
We **[Save the verified workspace toolchain receipt](fs.write_json(path=(directory + "/manifest.json"), value=`manifest`))**.
Return *[Expose the compiler for an explicit child environment](result.ok(value=`manifest`))*.
## _component
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable numeric Rust release |
| component | text | required | rustc or rust-std |
| target | text | required | x86_64-unknown-linux-gnu or wasm32-unknown-unknown |
| directory | text | required | Task-owned workspace toolchain directory |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with the verified component digest and extraction evidence |
Use `version`, `component`, `target` and `directory` only for the fixed compiler/standard-library components selected by rust_wasm_linux. Source bytes and checksums come from the official Rust distribution over HTTPS. A cached archive is reused only after its current native SHA256 matches the fetched checksum. A truncated transfer or HTTP failure is preserved as a failed Result; extraction never runs on an unchecked archive. Downloading, hashing and directory creation use native Marqdo. Tar is the explicit system boundary for the xz distribution format, with an argument array rather than generated shell code. Extraction is restricted to this component's own archive subtree and the selected workspace directory. No Python interpreter or system installation directory participates.
The extracted files retain their official executable modes, while --no-same-owner keeps archive ownership out of this workspace installation. The tar installer script is not executed. Component receipts identify the checked archive bytes; only the later compiler probe and repository build establish that those files work together. A failed extraction leaves the task-owned cache available for a verified retry. The caller's operating system still governs the external tar process, so this helper uses the fixed official component subtree rather than a caller-supplied archive member.
1. not [A stable numeric release](re.is_match(text=`version`, pattern="^[0-9]+[.][0-9]+[.][0-9]+$"))
Return *[Reject an invalid release name](result.error(code="toolchain.version", message="stable numeric Rust release required"))*.
1. (`component` != "rustc" and `component` != "rust-std") or (`target` != "x86_64-unknown-linux-gnu" and `target` != "wasm32-unknown-unknown") or (`component` == "rustc" and `target` != "x86_64-unknown-linux-gnu")
Return *[Reject an unsupported component](result.error(code="toolchain.component", message="this task supports the Linux x86 compiler and its host/WASM standard libraries"))*.
We **package = component + "-" + version + "-" + target** and **url = "https://static.rust-lang.org/dist/" + package + ".tar.xz"** and **cache = directory + "/downloads"**.
We **[Create the native download cache](fs.make_dirs(path=`cache`))**.
We **archive = cache + "/" + package + ".tar.xz"** and **checksum = [Read the official bounded checksum](net.get(url=(url + ".sha256"), max_bytes=4096))**.
1. not access(`checksum`, "ok")
Return *checksum*.
We **body = [Read the checksum text](access(access(`checksum`, "value"), "body"))** and **expected = [Select its SHA256 field](table.first(list=text.str_split(s=text.str_trim(s=`body`), sep=" ")))**.
1. not [A complete SHA256 was returned](re.is_match(text=`expected`, pattern="^[a-f0-9]{64}$"))
Return *[Retain the invalid checksum response](result.error(code="toolchain.checksum", message="official checksum is not a SHA256 digest"))*.
We **ready = False** before inspecting this cache entry.
1. [The selected archive is already cached](fs.exists(path=`archive`))
We **actual = [Hash its actual cached bytes](fs.file_hash(path=`archive`))** and **ready = actual == expected**.
1. not `ready`
We **downloaded = [Stream the official component into its cache path](net.download(url=`url`, path=`archive`, timeout_ms=120000, max_bytes=268435456))**.
1. not access(`downloaded`, "ok")
Return *downloaded*.
We **actual = [Verify the bytes before extraction](fs.file_hash(path=`archive`))**.
1. `actual` != `expected`
Return *[Stop on a mismatching component](result.error(code="toolchain.digest", message="downloaded Rust component SHA256 differs from the official checksum"))*.
We **member = component**.
1. `component` == "rust-std"
We **member = "rust-std-" + target**.
We **subtree = [Select the verified component path](package + "/" + member)**.
`argv` =
| argument |
|---|
| tar |
| "--extract" |
| "--xz" |
| "--no-same-owner" |
| "--file" |
| `archive` |
| "--directory" |
| `directory` |
| "--strip-components=2" |
| `subtree` |
We **extracted = [Extract only this verified distribution component](engineering.checked(argv=`argv`, timeout_ms=120000, max_output=32768))**.
1. not access(`extracted`, "ok")
Return *extracted*.
`receipt` =
| package | sha256 |
|---|---|
| `package` | `actual` |
Return *[Retain the verified component identity](result.ok(value=`receipt`))*.
+14
View File
@@ -0,0 +1,14 @@
---
name: marqdo-release
description: Prepare, publish and verify a user-authorized Marqdo full, cli or extension release through its executable mq.md handbook. Use for release versioning, immutable tags, matching CI gates, GitHub/R2 parity and Ubuntu PPA publication.
---
Read [the executable release entry](../marqdo-release/index.mq.md) and use its task routing. Version and mode come from the user; an already stated choice remains authorized. Inspection of an old release does not authorize republishing it. Never infer a new version, replace a tag, force-push or bypass hooks.
Use `marqdo call` on the actual handbook headings. The repository development binary is `target/debug/marqdo`; prepare its engineering plugin through [the development entry](../marqdo-dev/index.mq.md). File reading and authoring use native [file tools](../marqdo-dev/files.mq.md). No Python release orchestrator is required. New OS/service capabilities belong at explicit plugin or external-tool boundaries; version decisions, retries and publication order remain readable mq.md.
The entry preserves full/cli/ext deliverables, separate editor sources, clean-main tagging, bilingual authored notes, exact-commit Release and EK gates, both native platforms, GitHub/R2 identical bytes, VERSION-after-ZIP ordering and Ubuntu source/build/apt evidence. Every applicable obligation must be verified before declaring completion. Default full/cli work includes PPA; gh-pages deployment needs its own instruction.
Read-only status and verification are separate from publication. Grant effects stated by each task. Inspect Result.ok before value; use --require-ok when an external automation must stop on a failed Result. Credentials stay in their existing private stores. Interactive sudo/GPG/dput or a failed service request remains incomplete: report the concrete failure and the exact handbook recovery call, preserving local evidence.
Independent extension releases commit reviewed bilingual notes at doc/releases/ext-X.Y.Z.md before tagging. The [pack handbook](../../skills/marqdo-release/packs.mq.md) and extension-release.yml run native staging, both platform builds, exact-tag release creation and non-clobbering gh asset upload through marqdo call. An existing upload is inspected rather than replaced. Windows execution remains a CI obligation; a local Linux ZIP cannot prove it.
+47
View File
@@ -0,0 +1,47 @@
---
markup: occlusion
title: Native release boundary
import:
engineering: ext/engineering/index.mq.md
result: lib/result.mq.md
---
The release handbook composes native Marqdo libraries and this narrow extension
boundary. Ordinary file reads/writes, version decisions, asset lists and state
checks stay in Marqdo. Authenticated service requests, bounded OS commands and
ZIP-format inspection use the engineering native plugin. No Python loader,
generated command program or duplicate release orchestrator is involved.
A native plugin has the calling OS user's authority. Root is a working/artifact
location and cannot be described as an OS sandbox. These calls need plugin
effects; their public task contracts additionally declare any native filesystem,
network or environment operations they perform. Reading the handbook authorizes
none of its external publication steps.
## request
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| operation | text | required | Native boundary operation selected by the task |
| payload | map | required | Structured arguments; never credentials |
| root | text | "." | Existing checkout/artifact root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Actual boundary Result; failed child exit stays failed |
Use `operation`, `payload` and `root`="." for a documented external boundary.
The extension reports transport success separately from a child's exit code.
Release commands require code zero and no timeout, so convert a completed but
failed child into a release failure before another phase can continue. Stdout
and stderr retain bounded diagnostic evidence with known credentials redacted.
Other operations preserve their own Result without manufacturing success.
We **answer = [Invoke the maintained native engineering boundary](engineering.request(operation=`operation`, payload=`payload`, root=`root`))**.
1. not access(`answer`, "ok")
Return *answer* with its original error.
1. `operation` == "command"
We **execution = [Read the bounded child result](access(answer, "value"))**.
1. access(`execution`, "code") != 0 or access(`execution`, "timed_out")
Return *[Keep the unsuccessful child visible](result.error(code="release.command_failed", message=str(`execution`), operation="command"))*.
Return *answer* when this requested boundary completed successfully.
+228
View File
@@ -0,0 +1,228 @@
---
markup: occlusion
title: Native artifact IO for the release handbook
import:
engineering: ext/engineering/index.mq.md
fs: lib/fs.mq.md
net: lib/net.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
text: lib/text.mq.md
re: lib/re.mq.md
uuid: lib/uuid.mq.md
sys: lib/sys.mq.md
---
These functions are the concrete IO used by assets.mq.md. Native Marqdo libraries read, hash, download, stage and clean files. The extension handles authenticated R2 writes and ZIP-format inspection. Source identity, release completeness and publication ordering remain visible Marqdo dataflow.
## verify
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| asset | map | required | Exact GitHub asset record including size and digest |
| path | text | required | Local file selected inside the granted filesystem root |
| root | text | "." | Checkout root matching --fs-root; relative to the granted runtime cwd |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with native hash evidence and validated archive metadata |
Use `asset`, `path` and `root`="." to verify local bytes before publication.
Size and SHA256 come from lib/fs; a GitHub digest, when supplied, must match.
The native engineering extension inspects only the ZIP/VSIX format and CRCs.
Ordinary file facts stay in Marqdo instead of an external script. A mismatched
length or hash remains a failed Result and cannot advance the CDN pointer.
The format layer rejects escaping entries, duplicate names, symlinks and excessive
expansion. It does not extract or execute a CLI. Source pack version, native file
roles and VSIX version are checked by assets.content after this byte-level stage.
This function requires fs.read and plugin; executable-only assets use the same
size/hash checks without pretending they contain an archive.
We **information = [Read the native file information](fs.stat(path=`path`))** and
**size = [Read its actual byte count](access(information, "size"))** and
**sha256 = [Hash the actual file through the native filesystem](fs.file_hash(path=`path`))** and
**expected = [Read GitHub's optional digest metadata](table.get(map=`asset`, key="digest"))** and
**name = [Retain the asset's exact filename](access(asset, "name"))**.
1. `size` != access(`asset`, "size") or (`expected` != None and `expected` != "sha256:" + `sha256`)
Return *[Reject bytes that differ from GitHub metadata](result.error(code="release.asset_digest", message=`name`, operation="asset_io.verify"))*.
`record` =
| name | size | sha256 |
|---|---|---|
| `name` | `size` | `sha256` |
1. [This asset is an archive format](text.ends_with(text=`name`, suffix=".zip") or text.ends_with(text=`name`, suffix=".vsix"))
We **archive = [Inspect ZIP entries and their CRCs without extraction](engineering.inspect_zip(path=`path`, root=`root`))**.
1. not access(`archive`, "ok")
Return *archive* with the actual format error.
We **record = [Retain the inspected format evidence](table.merge(a=`record`, b=access(archive, "value")))**.
Return *[The verified local byte identity](result.ok(value=`record`))*.
## fetch
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| asset | map | required | GitHub asset record chosen by the release catalog |
| directory | text | required | Release-specific destination under --fs-root |
| root | text | "." | Checkout root matching --fs-root; relative to the granted runtime cwd |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with a reused or freshly downloaded verified local artifact |
Use `asset`, `directory` and `root`="." after assets.catalog has checked all
required filenames. A local file is reused only after its size, hash and archive
format are verified again. Otherwise native net.download streams into an atomic
replacement under the granted filesystem root. Failed HTTP transfers do not
replace an existing destination. The proxy route is tried before the original
GitHub asset URL; explicit fixture URLs remain visible in test metadata.
Downloads have a 64 MiB per-file limit and a 90-second request timeout here.
These limits cover the current release matrix; a larger future artifact needs
a deliberate documented limit change. No credential is put into a URL or native
download header. Role-specific contents are checked by the calling task.
We **name = [Read the exact catalog filename](access(asset, "name"))** and
**path = directory + "/" + name** and **prepared = [Create the explicit staging directory](fs.make_dirs(path=`directory`))**.
1. [A local candidate already exists](fs.exists(path=`path`))
We **existing = [Recheck its actual byte identity](verify(asset=`asset`, path=`path`, root=`root`))**.
1. access(`existing`, "ok")
Return *existing* without downloading it again.
We **original = [Read the selected asset's original URL](access(asset, "browser_download_url"))** and
**proxy = [Select the documented GitHub mirror](text.replace(text=`original`, old="https://github.com/", new="https://proxy.cflmy.top/github.com/"))**.
`urls` =
| url |
|---|
| `proxy` |
| `original` |
We **headers = [Identify this public verification download](table.put(in=None, at="User-Agent", value="marqdo-engineering"))**.
We **last = [Start with no completed transfer](result.error(code="release.download", message=`name`, operation="asset_io.fetch"))**.
- [Try the bounded public download routes](for urls as url)
We **downloaded = [Stream the official artifact through native IO](net.download(url=`url`, path=`path`, headers=`headers`, timeout_ms=90000, max_bytes=67108864))**.
1. access(`downloaded`, "ok")
We **last = [Check the downloaded bytes and archive format](verify(asset=`asset`, path=`path`, root=`root`))**.
1. access(`last`, "ok")
Return *last* with its real evidence.
2. *
We **last = downloaded** to preserve the last transport failure.
Return *last* when neither route produced a verified artifact.
## cdn
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | Versioned or latest VERSION/pack path from the release model |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing public pointer text or native download hash |
Use `path` only for a modeled CDN object. The public base is ext.marqdo.com
unless an explicit fixture override is configured. VERSION is read as UTF-8;
binary packs use native net.download, fs.file_hash and native cleanup in a
UUID-named directory under .marqdo/release-check. No Python body reader or local
file writer participates. A handled network failure cleans its owned directory.
A successful HTTP request proves only that URL's bytes; the caller compares the
hash with GitHub and decides whether the release is complete. Edge-cache delay
remains visible. Unexpected filesystem diagnostics may leave the uniquely owned
staging directory for inspection; no unrelated directory is removed.
This task needs network.read, fs.write, environment.read and random.read.
We **valid = [Accept only modeled public artifact paths](re.is_match(text=`path`, pattern="^(latest|v[0-9]+\\.[0-9]+\\.[0-9]+)/(VERSION|marqdo-[A-Za-z0-9._-]+\\.zip)$"))**.
1. not `valid`
Return *[Reject an arbitrary CDN cache path](result.error(code="release.cdn_path", message="expected a modeled release path", operation="asset_io.cdn"))*.
We **base = [Read the explicit fixture override if configured](sys.env_get(name="MARQDO_RELEASE_CDN"))**.
1. `base` == None
We **base = "https://ext.marqdo.com"** for normal public verification.
We **url = base + "/" + path**.
We **headers = [Identify this public verification download](table.put(in=None, at="User-Agent", value="marqdo-engineering"))**.
1. [This object is a version pointer](text.ends_with(text=`path`, suffix="/VERSION"))
We **read = [Read the public UTF-8 version pointer](net.get(url=`url`, headers=`headers`, timeout_ms=30000))**.
1. not access(`read`, "ok")
Return *read* with its actual network error.
We **response = [Read the HTTP result](access(read, "value"))**.
1. access(`response`, "status") != 200
Return *[Keep the public pointer HTTP failure](result.error(code="release.cdn_http", message=str(access(response, "status")), operation="asset_io.cdn"))*.
We **version = [Trim only the pointer's outer whitespace](text.str_trim(s=access(response, "body")))**.
We **pointer = [Keep the version as one named result field](table.put(in=None, at="version", value=`version`))**.
Return *[The actual public version pointer](result.ok(value=`pointer`))*.
We **parent = [Prepare the ignored verification area](fs.make_dirs(path=".marqdo/release-check"))** and
**identifier = [Choose an independent staging identity](uuid.v4())** and **directory = ".marqdo/release-check/" + identifier** and
**created = [Reserve this verification directory](fs.make_dir(path=`directory`))** and **destination = directory + "/artifact.zip"**.
We **downloaded = [Stream public bytes into this owned native stage](net.download(url=`url`, path=`destination`, headers=`headers`, timeout_ms=90000, max_bytes=67108864))**.
1. not access(`downloaded`, "ok")
We **removed = [Clean only this failed request's owned stage](fs.remove_tree(path=`directory`))**.
Return *downloaded* with its real transport failure.
We **sha256 = [Hash the actual public bytes](fs.file_hash(path=`destination`))** and
**information = [Read the downloaded file information](fs.stat(path=`destination`))** and
**size = [Read their actual byte count](access(information, "size"))** and
**removed = [Remove this completed request's owned stage](fs.remove_tree(path=`directory`))**.
`evidence` =
| size | sha256 |
|---|---|
| `size` | `sha256` |
Return *[The measured public object identity](result.ok(value=`evidence`))*.
## upload
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| files | list | required | Exactly three verified path/name/sha256 records |
| root | text | "." | Checkout root matching --fs-root; relative to the granted runtime cwd |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing the actual R2 write evidence |
Use `version`, `files` and `root`="." only for the release already authorized
by the user. The caller has checked all three source/native files against
GitHub before this operation begins. Marqdo controls the write order explicitly:
versioned and latest pack objects first, both VERSION pointers last. Private R2
signing is the only native service boundary. No whole-directory sweep occurs.
An interrupted upload keeps the old pointer until every required pack has
succeeded. Existing older versions are never deleted. The tool returns an error
on the first failed write and preserves already-written object evidence through
the service itself; it does not call a partial batch complete. Public byte-parity
checks still follow in assets.status.
We **count = [Require the source pack and both platform packs](len(`files`))**.
1. `count` != 3
Return *[Reject an incomplete CDN upload set](result.error(code="release.cdn_files", message="exactly three verified packs are required", operation="asset_io.upload"))*.
`prefixes` =
| prefix |
|---|
| "v`version`" |
| latest |
We **written = [Start the service write evidence](table.empty_list())**.
- [Write both public pack namespaces before pointers](for prefixes as prefix)
- [Upload only the preverified pack set](for files as file)
We **key = prefix + "/" + access(file, "name")** and
**uploaded = [Sign and upload the exact checked local bytes](engineering.put_file(path=access(file, "path"), key=`key`, sha256=access(file, "sha256"), root=`root`))**.
1. not access(`uploaded`, "ok")
Return *uploaded* before changing any VERSION pointer.
We **written = [Retain the completed object identity](table.append(list=`written`, item=access(uploaded, "value")))**.
- [Advance pointers only after all six pack writes succeeded](for prefixes as prefix)
We **uploaded = [Write the explicit version pointer](engineering.put_text(key=`prefix` + "/VERSION", text=`version` + "\n", root=`root`))**.
1. not access(`uploaded`, "ok")
Return *uploaded* with the actual pointer failure.
We **written = [Retain this pointer write](table.append(list=`written`, item=access(uploaded, "value")))**.
Return *[All completed service writes](result.ok(value=`written`))*.
+590
View File
@@ -0,0 +1,590 @@
---
markup: occlusion
title: Release assets: bytes, contents and CDN parity
import:
bridge: ./_bridge.mq.md
native: ./asset_io.mq.md
github: ./github.mq.md
model: ./model.mq.md
result: lib/result.mq.md
table: lib/table.mq.md
text: lib/text.mq.md
json: lib/json.mq.md
toml: lib/toml.mq.md
---
Artifacts have a lifecycle: discover the exact GitHub metadata, download to a
release-specific directory, verify bytes and package role, publish only the
three extension packs, then compare every public copy. Full mode requires ten
GitHub assets; Linux CLI and Linux native packages are separate obligations.
The local staging directory is dist/release-X.Y.Z by default. Downloads use
atomic .partial replacement and bounded retries. Verification reads ZIP entries
without extraction. Existing verified files are reusable; a failed operation
never changes an old tag or treats an incomplete upload as completion.
Read-only public checks and local downloads use plugin,fs.write,network.read,environment.read because the checked-in
native transport owns those service and filesystem operations. Publishing is an
explicit external mutation authorized by a release request. Credentials remain
in existing environment or ~/.marqdo/r2.env stores and are not call arguments.
```sh
marqdo call skills/marqdo-release/assets.mq.md download 'version="2.6.0"' --effects plugin,fs.write,network.read,environment.read --fs-root . --json
marqdo call skills/marqdo-release/assets.mq.md status 'version="2.6.0"' --effects plugin,fs.write,network.read,environment.read --fs-root . --json
```
These commands inspect the existing release; they do not republish it. Use
publish only for the version and mode actually authorized. On missing keys,
configure the documented local credential store and call publish again. Never
put credentials in a parameter, notes file, source tree or session binding.
## named
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| assets | list | required | GitHub asset records from one exact release |
| name | text | required | Exact filename to look up |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Matching asset record or None |
Use `assets` and `name` to find one exact release artifact. Prefix matches
are insufficient because source packs, CLI bundles and native packs serve
different roles. This pure helper preserves the GitHub-provided size, digest and
download URL together. It neither creates an asset nor substitutes a file from
a previous release. None means the caller must keep the release incomplete,
even if other files are already downloadable.
- [Find the exact filename in this release](for assets as asset)
1. access(`asset`, "name") == `name`
Return *asset* with its original metadata.
Return *None* when no asset has that exact name.
## catalog
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing the accepted plan and complete GitHub asset records |
Use `version`, `mode`="full" and `root`="." before downloading or publishing.
All required names are checked first, so an incomplete release cannot partially
advance the CDN pointer. Extra GitHub assets are allowed; they do not replace
any required filename. A missing release and a missing platform pack have
separate error codes. Only metadata is fetched here; no local archive is trusted
merely because it has the right filename. Content and digest checks occur next.
For ext mode the same rule requires source, Windows native and Linux native packs.
We **planned = [Read the exact deliverable contract](model.plan(version=`version`, mode=`mode`))**.
1. not access(`planned`, "ok")
Return *planned* with its failure intact.
We **published = [Read this tag's actual GitHub assets](github.release(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`published`, "ok")
Return *published* with its failure intact.
We **release_data = [Read published metadata or None](access(published, "value"))**.
1. `release_data` == None
Return *[Keep a missing release visible](result.error(code="release.missing", message="GitHub release is not published", operation="assets.catalog"))*.
We **plan_data = [Keep the validated mode and names](access(planned, "value"))** and
**assets = [Read GitHub asset records](access(release_data, "assets"))** and
**required = [Read the required filenames](access(plan_data, "required"))**.
- [Require every declared deliverable before continuing](for required as name)
We **asset = [Find this exact artifact](named(assets=`assets`, name=`name`))**.
1. `asset` == None
Return *[Report the missing deliverable](result.error(code="release.asset_missing", message=`name`, operation="assets.catalog"))*.
`catalog_data` =
| plan | release | assets |
|---|---|---|
| `plan_data` | `release_data` | `assets` |
Return *[The complete metadata catalog](result.ok(value=`catalog_data`))*.
## bundle_content
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| entries | list | required | Validated archive entry names |
| platform | text | required | windows or linux, chosen from the catalog filename |
| name | text | required | Exact bundle filename retained in errors |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result confirming CLI, readable libraries and every embedded native plugin |
Use `entries`, `platform` and `name` for an already CRC-checked CLI bundle.
A standalone executable has a different role: the bundle must also carry its
readable standard and extension sources. This task requires the interpreter,
file/table libraries, extension version, web/quantum handbooks and all baseline
native libraries. When engineering sources are present, its native library is
required in the same bundle.
Platform names are explicit data. Windows uses marqdo.exe and DLL names, Linux
uses marqdo and lib-prefixed shared objects. A missing library cannot be excused
by success on the other platform. Archive paths use their portable forward-slash
representation; no extraction or ABI execution happens in this pure layer.
Hash/size/CRC identity comes from the earlier byte check, and the correct-commit
CI gate proves the platform build. This function verifies packaging coherence,
not scientific correctness, loader ABI compatibility or a machine's installed
system dependencies. Its successful Result means every listed bundle obligation
was observed in these actual entry names.
We **binary = "marqdo"** and **prefix = "lib"** and **suffix = ".so"** for Linux.
1. `platform` == "windows"
We **binary = "marqdo.exe"** and **prefix = ""** and **suffix = ".dll"**.
2. `platform` != "linux"
Return *[Reject an unknown bundle platform](result.error(code="release.platform", message=`platform`, operation="bundle_content"))*.
`required` =
| entry |
|---|
| `binary` |
| "lib/fs.mq.md" |
| "lib/table.mq.md" |
| "ext/VERSION" |
| "ext/web/index.mq.md" |
| "ext/quantum/index.mq.md" |
`plugins` =
| plugin |
|---|
| "agent" |
| "linalg" |
| "llm" |
| "quantum" |
| "web" |
1. [This bundle includes engineering sources](table.contains(list=`entries`, item="ext/engineering/index.mq.md"))
We **plugins = [Require the same new native capability](table.append(list=`plugins`, item="engineering"))**.
- [Add each embedded native dependency](for plugins as plugin)
We **required = [Retain the platform-specific native path](table.append(list=`required`, item="ext/native/" + prefix + plugin + suffix))**.
- [Check each actual bundle obligation](for required as entry)
1. not [The bundle contains this required file](table.contains(list=`entries`, item=`entry`))
Return *[Retain the missing packaging entry](result.error(code="release.bundle_content", message=`name` + ": " + `entry`, operation="bundle_content"))*.
Return *[The actual packaging checks passed](result.ok(value=True))*.
## matrix
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| records | list | required | Complete catalog-selected records after individual size/digest/role checks |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result retaining records only when declared engineering sources have both native platforms |
Use `records` after individual content checks on the complete release set.
The source pack declares which extension sources it actually ships. If it contains
engineering/index.mq.md, both native packs must contain that capability too.
A new source pack combined with older native packs would otherwise pass separate
filename checks and fail only when an agent tries to load its new tool.
This check follows package contents rather than guessing a version threshold.
Historical packs without engineering sources retain their original five-plugin
contract. CLI bundles are checked independently by bundle_content, including
their embedded source/native correspondence. The release model and catalog still
own the complete filename matrix for full/cli/ext; this helper does not turn an
arbitrary partial list into proof of an entire release.
The function is pure. It neither downloads, extracts nor executes an archive.
Missing new native capability remains a failed Result before publication, and
a successful result preserves all previously verified records for summarization.
We **engineering = False** and **windows = False** and **linux = False** before inspecting the declared source footprint.
- [Read capability declarations from the source pack](for records as record)
We **name = [Read this verified filename](access(record, "name"))**.
1. [This is the extension source pack](text.ends_with(text=`name`, suffix="-ext.zip"))
We **engineering = [Observe whether engineering sources actually ship](table.contains(list=access(record, "entries"), item="ext/engineering/index.mq.md"))**.
1. not `engineering`
Return *[Keep the historical source/native contract](result.ok(value=`records`))*.
- [Require new capability on each native platform](for records as record)
We **name = [Read this native candidate's filename](access(record, "name"))** and **required = None**.
1. [This is the Windows native pack](text.ends_with(text=`name`, suffix="-native-x86_64-pc-windows-msvc.zip"))
We **windows = True** and **required = "native/engineering.dll"**.
1. [This is the Linux native pack](text.ends_with(text=`name`, suffix="-native-x86_64-unknown-linux-gnu.zip"))
We **linux = True** and **required = "native/libengineering.so"**.
1. `required` != None
1. not [This platform contains its declared engineering library](table.contains(list=access(`record`, "entries"), item=`required`))
Return *[Reject source/native capability drift](result.error(code="release.native_capability", message=`name`, operation="assets.matrix"))*.
1. not `windows` or not `linux`
Return *[Require both native platforms](result.error(code="release.native_platform", message="engineering sources require Windows and Linux native packs", operation="assets.matrix"))*.
Return *[The consistent source/native records](result.ok(value=`records`))*.
## summaries
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| records | list | required | Verified records retained after matrix checks |
| directory | text | required | Actual local staging directory |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Compact name/path/size/SHA256/entry-count evidence rows |
Use `records` and `directory` after verification, not as a replacement for it.
An archive can contain thousands of source paths. Returning every path and full
package metadata at the end of a release obscures the handful of facts an agent
needs to act: exact local path, byte length, digest and entry count.
This pure projection keeps those observed facts in one row per artifact.
It does not invent a verified flag, rehash a file or silently discard an earlier
failure. Executable-only files have zero archive entries. Detailed inspection
remains available from asset_io.verify and engineering.inspect_zip when needed.
The reduced final evidence is also suitable for saving through native fs.write_json,
without requiring another language to parse command output or reconstruct a report.
We **rows = [Start concise artifact evidence](table.empty_list())**.
- [Project already-checked artifacts into readable rows](for records as record)
We **name = [Keep the exact filename](access(record, "name"))** and **size = [Keep the measured size](access(record, "size"))** and **sha256 = [Keep the measured digest](access(record, "sha256"))** and **entries = [Read optional archive details](table.get(map=`record`, key="entries"))** and **entry_count = 0** and **path = directory + "/" + name**.
1. `entries` != None
We **entry_count = [Count the inspected entries](len(entries))**.
`row` =
| name | path | size | sha256 | entry_count |
|---|---|---|---|---|
| `name` | `path` | `size` | `sha256` | `entry_count` |
We **rows = [Retain this measured artifact](table.append(list=`rows`, item=`row`))**.
Return *rows* after projecting each verified record.
## content
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| record | map | required | Verified archive record produced by the byte transport |
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result retaining archive evidence after role-specific content checks |
Use `record` and `version` after a SHA256/size/CRC check. This second layer
checks useful contents: extension sources identify their pack version; native
packs retain their baseline plugins and source-declared new capabilities; bundles include the embedded-library
sources and a CLI; VSIX metadata declares its editor version; the source archive
contains the tagged Cargo version. These checks complement CI and do not claim
to prove ABI compatibility or scientific correctness of every plugin.
An executable-only asset has no ZIP entries and relies on its GitHub digest and
build evidence. A source pack without either handbook entry is unusable for the
document-first workflow even when it decompresses correctly. Native filenames
are checked individually because one missing shared library would otherwise
surface only after installation, far from the publication step that caused it. No archive is extracted or executed while reading its metadata.
Version text is trimmed for comparison, so Windows CRLF and Unix LF identify
the same declared version without changing any archive bytes. SHA256 still
covers the original byte sequence. A source snapshot is checked through its
actual TOML package.version field; a matching dependency version cannot satisfy
that role. Missing metadata remains a failure rather than a guessed version.
We **name = [Read the verified filename](access(record, "name"))**.
1. [This is an executable-only asset](text.ends_with(text=`name`, suffix=".exe"))
Return *[Retain its verified digest evidence](result.ok(value=`record`))*.
We **entries = [Read the archive entry list](access(record, "entries"))** and
**metadata = [Read bounded metadata files](access(record, "metadata"))** and
**required = [Start the role-specific entry list](table.empty_list())**.
1. [This is the source extension pack](text.ends_with(text=`name`, suffix="-ext.zip"))
`required` =
| entry |
|---|
| ext/VERSION |
| ext/quantum/index.mq.md |
| ext/web/index.mq.md |
We **declared = [Read the pack version without assuming platform newlines](table.get(map=`metadata`, key="ext/VERSION"))**.
1. `declared` == None
Return *[Report missing version metadata](result.error(code="release.pack_version", message=`name`, operation="assets.content"))*.
We **pack_version = [Normalize the source pack version field](text.str_trim(s=`declared`))**.
1. `pack_version` != `version`
Return *[Reject a mismatched source pack version](result.error(code="release.pack_version", message=`name`, operation="assets.content"))*.
1. [This is a Linux native pack](text.contains(text=`name`, sub="-native-x86_64-unknown-linux-gnu"))
`required` =
| entry |
|---|
| native/libagent.so |
| native/liblinalg.so |
| native/libllm.so |
| native/libquantum.so |
| native/libweb.so |
1. [This is a Windows native pack](text.contains(text=`name`, sub="-native-x86_64-pc-windows-msvc"))
`required` =
| entry |
|---|
| native/agent.dll |
| native/linalg.dll |
| native/llm.dll |
| native/quantum.dll |
| native/web.dll |
1. [This is the standard-library source pack](text.ends_with(text=`name`, suffix="-stdlib.zip"))
`required` =
| entry |
|---|
| lib/fs.mq.md |
| lib/table.mq.md |
| lib/文件.mq.md |
1. [This is the offline documentation pack](text.ends_with(text=`name`, suffix="-public.zip"))
We **required = [Require the documentation entry](table.append(list=`required`, item="index.html"))**.
1. [This is the tagged source snapshot](text.ends_with(text=`name`, suffix="-source.zip"))
We **cargo_source = [Read the selected manifest metadata](table.get(map=`metadata`, key="Cargo.toml"))**.
1. `cargo_source` == None
Return *[Report missing source manifest](result.error(code="release.source_metadata", message=`name`, operation="assets.content"))*.
We **manifest = [Parse the actual source package declaration](toml.parse(text=`cargo_source`))** and **package_version = [Read the package version](access(access(manifest, "package"), "version"))**.
1. `package_version` != `version`
Return *[Reject a source snapshot from another version](result.error(code="release.source_version", message=`name`, operation="assets.content"))*.
1. [This is the editor extension](text.ends_with(text=`name`, suffix=".vsix"))
We **package = [Decode the VSIX package metadata](json.parse(text=access(metadata, "extension/package.json")))**.
1. access(`package`, "version") != `version`
Return *[Reject a mismatched VSIX version](result.error(code="release.vsix_version", message=`name`, operation="assets.content"))*.
- [Check every entry required by this role](for required as entry)
1. not [The entry is present](table.contains(list=`entries`, item=`entry`))
Return *[Report missing archive content](result.error(code="release.archive_content", message=`name` + ": " + entry, operation="assets.content"))*.
1. not [This is a standalone native pack](text.contains(text=`name`, sub="-native-"))
We **platform = None**.
1. [This is a Windows CLI bundle](text.ends_with(text=`name`, suffix="-x86_64-pc-windows-msvc.zip"))
We **platform = "windows"**.
1. [This is a Linux CLI bundle](text.ends_with(text=`name`, suffix="-x86_64-unknown-linux-gnu.zip"))
We **platform = "linux"**.
1. `platform` != None
We **checked = [Verify the embedded source/native bundle](bundle_content(entries=`entries`, platform=`platform`, name=`name`))**.
1. not access(`checked`, "ok")
Return *checked*.
Return *[Keep the verified digest and content evidence](result.ok(value=`record`))*.
## download
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| directory | any | None | Relative destination; None selects dist/release-X.Y.Z |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with locally downloaded, byte-verified and content-checked assets |
Use `version`, `mode`="full", `directory`=None and `root`=".".
The destination stays inside the checkout. Files are reused only after their
size and GitHub digest are checked again; a .partial file never counts as an
artifact. Network retries try the configured GitHub proxy then the original
asset URL. The download adapter validates archive paths and CRCs without
extracting an executable. Role-specific checks below use the same version.
A failure stops the batch with its real error. Successfully verified files
remain in the destination for a retry, while no R2 pointer or PPA is changed.
plugin,fs.write,network.read,environment.read includes the adapter's local writes and network authority; the
working root is a location constraint, not a subprocess permission sandbox.
We **catalog_result = [Require complete GitHub metadata first](catalog(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`catalog_result`, "ok")
Return *catalog_result* with its failure intact.
We **catalog_data = [Read the accepted metadata](access(catalog_result, "value"))** and
**required = [Read required names](access(access(catalog_data, "plan"), "required"))** and
**assets = [Read their GitHub size and digest records](access(catalog_data, "assets"))**.
1. `directory` == None
We **directory = "dist/release-" + version** for the release staging directory.
We **checked = [Start the verified artifact list](table.empty_list())**.
- [Download and verify each required artifact](for required as name)
We **asset = [Select its unmodified metadata](named(assets=`assets`, name=`name`))**.
`payload` =
| asset | directory |
|---|---|
| `asset` | `directory` |
We **fetched = [Transfer exact GitHub bytes and validate digest and CRC](native.fetch(asset=`asset`, directory=`directory`, root=`root`))**.
1. not access(`fetched`, "ok")
Return *fetched* with the completed earlier files retained.
We **verified = [Check the package's actual role and version](content(record=access(fetched, "value"), version=`version`))**.
1. not access(`verified`, "ok")
Return *verified* before any publication step.
We **checked = [Append the checked evidence](table.append(list=`checked`, item=access(verified, "value")))**.
We **consistent = [Check source/native capabilities across the complete set](matrix(records=`checked`))**.
1. not access(`consistent`, "ok")
Return *consistent* before publication.
We **evidence = [Keep concise observed paths and hashes](summaries(records=`checked`, directory=`directory`))**.
Return *[The real verified local artifacts](result.ok(value=`evidence`))*.
## status
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with CDN parity, version pointers and checked URLs |
Use `version`, `mode`="full" and `root`="." to verify published extension
bytes. CLI mode has no CDN obligation and reports that explicitly. Other modes
require both the versioned and latest download for each of the three packs, plus
both VERSION pointers. Their SHA256 values must match the GitHub-provided digest
for the exact release. Missing digests remain a failure; the task does not infer
integrity from a filename, HTTP status or a previous version's pointer.
This operation is read-only but downloads the bytes to compute their hashes.
A pointer can be published before every edge cache refreshes; any mismatch keeps
complete=False and retains the URL evidence so a later query can verify it.
We **catalog_result = [Read the same release's asset metadata](catalog(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`catalog_result`, "ok")
Return *catalog_result* with its failure intact.
We **catalog_data = [Read the accepted catalog](access(catalog_result, "value"))** and
**checks = [Start public endpoint evidence](table.empty_list())** and **complete = True**.
1. `mode` != "cli"
We **names = [Read the three CDN deliverables](access(access(catalog_data, "plan"), "cdn"))** and
**assets = [Read the exact GitHub asset digests](access(catalog_data, "assets"))**.
`prefixes` =
| prefix |
|---|
| "v`version`" |
| latest |
- [Verify versioned and latest publication independently](for prefixes as prefix)
We **pointer_path = prefix + "/VERSION"** as the explicit public pointer.
We **pointer = [Read the public version pointer](native.cdn(path=`pointer_path`))**.
1. not access(`pointer`, "ok")
Return *pointer* with its service failure.
We **complete = [Keep a mismatched pointer incomplete](complete and access(access(pointer, "value"), "version") == version)**.
- [Compare every pack with its GitHub SHA256](for names as name)
We **asset = [Keep GitHub metadata as the source of truth](named(assets=`assets`, name=`name`))**.
We **asset_path = prefix + "/" + name** as the exact public object.
We **observed = [Hash the actual public download](native.cdn(path=`asset_path`))**.
1. not access(`observed`, "ok")
Return *observed* with its failed public read.
We **digest = [Read the observed SHA256](access(access(observed, "value"), "sha256"))** and
**matches = [Require the same exact release bytes](table.get(map=`asset`, key="digest") == "sha256:" + digest)** and
**complete = complete and matches**.
`evidence` =
| path | sha256 | matches |
|---|---|---|
| "`prefix`/`name`" | `digest` | `matches` |
We **checks = [Retain this endpoint's evidence](table.append(list=`checks`, item=`evidence`))**.
We **needed = [Decide whether this mode publishes extension packs](mode != "cli")**.
`state` =
| complete | required | checks |
|---|---|---|
| `complete` | `needed` | `checks` |
Return *[The measured CDN publication state](result.ok(value=`state`))*.
## publish
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| directory | any | None | Verified staging directory; None uses dist/release-X.Y.Z |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result of verified R2 upload followed by public byte-parity checks |
Use `version`, `mode`="full", `directory`=None and `root`="." only after the
user has instructed this release. CLI-only mode has no extension publication
step. The three local ZIPs must already exist, match GitHub metadata and pass
content checks before any R2 write begins. Their combined capability matrix
must also agree: source-declared plugins require both matching native libraries.
Individually valid archives cannot hide a missing runtime on one platform. Missing credentials produce an error
with the existing uploader command available in this handbook's recovery notes.
The maintained uploader writes all versioned/latest packs before VERSION, keeping
pointer updates after content. It does not delete older versions. After upload,
this function verifies public parity; an edge-cache delay is incomplete evidence,
not a reason to upload unrelated files from the whole dist directory.
We **catalog_result = [Validate the intended release and all required filenames](catalog(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`catalog_result`, "ok")
Return *catalog_result* with its failure intact.
1. `mode` == "cli"
Return *[Report that this mode has no CDN publication](status(version=`version`, mode=`mode`, root=`root`))*.
1. `directory` == None
We **directory = "dist/release-" + version** as the staging directory.
We **catalog_data = [Read the verified metadata catalog](access(catalog_result, "value"))** and
**names = [Read the exact three CDN packs](access(access(catalog_data, "plan"), "cdn"))** and
**assets = [Read their GitHub digests](access(catalog_data, "assets"))** and
**files = [Start the explicit upload path list](table.empty_list())** and
**records = [Retain the complete source and platform content evidence](table.empty_list())**.
- [Verify all local packs before touching R2](for names as name)
We **asset = [Choose the same release asset](named(assets=`assets`, name=`name`))** and
**path = directory + "/" + name**.
`payload` =
| asset | path |
|---|---|
| `asset` | `path` |
We **verified = [Require local size, SHA256 and archive CRC parity](native.verify(asset=`asset`, path=`path`, root=`root`))**.
1. not access(`verified`, "ok")
Return *verified* before any CDN write.
We **checked = [Require the expected contents and version](content(record=access(verified, "value"), version=`version`))**.
1. not access(`checked`, "ok")
Return *checked* with the source or platform error.
We **records = [Retain the verified archive for capability matching](table.append(list=`records`, item=access(verified, "value")))** and
**sha256 = [Retain this file's checked native hash](access(access(verified, "value"), "sha256"))**.
`file` =
| path | name | sha256 |
|---|---|---|
| `path` | `name` | `sha256` |
We **files = [Keep only the verified upload record](table.append(list=`files`, item=`file`))**.
We **matched = [Require the source-declared plugins in both native platform packs](matrix(records=`records`))**.
1. not access(`matched`, "ok")
Return *matched* before publishing any pack or pointer.
`upload` =
| version | files |
|---|---|
| `version` | `files` |
We **uploaded = [Upload only the three verified packs using private R2 credentials](native.upload(version=`version`, files=`files`, root=`root`))**.
1. not access(`uploaded`, "ok")
Return *uploaded* with its failure intact.
Return *[Verify the public bytes after uploading](status(version=`version`, mode=`mode`, root=`root`))*.
+353
View File
@@ -0,0 +1,353 @@
---
markup: occlusion
title: Observe and update GitHub release evidence
import:
bridge: ./_bridge.mq.md
model: ./model.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
fs: lib/fs.mq.md
---
GitHub release tasks keep source identity and publication state explicit. Start
with status for an existing version; notes is a separate mutation that consumes
a reviewed bilingual file. The same release metadata feeds assets.download and
assets.status, so name, size and digest checks do not drift between channels.
Every task returns Result.ok/value/error. Check that inner ok before consuming
value, then inspect complete for gates. A successful query may truthfully report
an incomplete release. plugin grants the native boundary OS/network
authority; credentials are resolved privately from the environment or existing
credential stores. They are never parameters, return values or journal bindings.
Example, from the checkout root:
```sh
marqdo call skills/marqdo-release/github.mq.md status 'version="2.6.0"' --effects plugin --fs-root . --json
```
The command is read-only. A future release uses the version the user actually
specified. A red EK gate, missing Linux build or wrong-commit green run keeps the
release incomplete even if a GitHub download page already exists.
## request
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | API path scoped to /repos/cflmy/marqdo/ |
| method | text | "GET" | GET for observation; PATCH for notes; POST for explicit publication |
| data | any | None | JSON request body; credentials are never arguments |
| missing | bool | False | Whether GET 404 is represented as a successful None |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing service JSON or a transport error |
Use `path`, `method`="GET", `data`=None, `missing`=False and `root`=".".
This function is the authenticated GitHub boundary used by the tasks below.
The proxy is tried before direct GitHub; GET and idempotent note PATCH may be
retried, while an uncertain POST is returned as failure. API failures retain a
code and service name without exposing tokens, headers or signed download URLs.
Reading requires plugin because the native engineering plugin owns HTTPS.
`payload` =
| path | method | data | missing |
|---|---|---|---|
| `path` | `method` | `data` | `missing` |
Return *[Request GitHub JSON through the maintained transport](bridge.request(operation="github", payload=`payload`, root=`root`))*.
## release
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing release metadata, or None when not published |
Use `version`, `mode`="full" and `root`=".".
The mode selects vX.Y.Z or ext-vX.Y.Z through the same pure plan used for
packaging. A missing release is an observable state, not proof that a previous
publish command failed before creating anything. Callers can distinguish it
from a network or authentication failure by inspecting Result.ok first.
This query does not create a release and never invokes the old Windows-only
publication script, whose assumptions predate embedded standard libraries.
We **planned = [Derive the correct release tag](model.plan(version=`version`, mode=`mode`))**.
1. not access(`planned`, "ok")
Return *planned* with its failure intact.
We **plan_data = [Read the accepted tag contract](access(planned, "value"))** and
**path = "/repos/cflmy/marqdo/releases/tags/" + access(plan_data, "tag")**.
Return *[Observe this exact release without creating one](request(path=`path`, missing=True, root=`root`))*.
## commit
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| tag | text | required | Exact tag from the release plan |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with the commit SHA targeted by a lightweight or annotated tag |
Use `tag` and `root`=".". Annotated tags point first to a tag object,
whereas lightweight tags already point to a commit. Follow that distinction
before matching a workflow run. Comparing a tag-object SHA with head_sha would
silently fail to find the correct green run. Only the single annotated object
created by this handbook is accepted; nested tag objects remain an error.
A missing tag is reported as a transport failure rather than guessed from main.
We **reference = [Read the exact remote tag reference](request(path="/repos/cflmy/marqdo/git/ref/tags/" + tag, root=`root`))**.
1. not access(`reference`, "ok")
Return *reference* with its failure intact.
We **object = [Read the tag target](access(access(reference, "value"), "object"))**.
1. access(`object`, "type") == "tag"
We **annotation = [Resolve the annotated tag object](request(path="/repos/cflmy/marqdo/git/tags/" + access(object, "sha"), root=`root`))**.
1. not access(`annotation`, "ok")
Return *annotation* without substituting main.
We **object = [Read the annotated commit target](access(access(annotation, "value"), "object"))**.
1. access(`object`, "type") != "commit"
Return *[Reject an unexpected tag target](result.error(code="release.tag_target", message="tag must resolve to a commit", operation="github.commit"))*.
Return *[The immutable release commit](result.ok(value=access(object, "sha")))*.
## select_run
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| runs | list | required | Workflow runs ordered newest first by the GitHub API |
| sha | text | required | Exact commit that this gate must cover |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Newest run for this commit, or None |
Use `runs` and `sha` to select one observed gate attempt. The first matching
head_sha is the most recent attempt provided by the API; an older successful
attempt cannot mask a later failure for the same commit. Runs for other commits
are irrelevant even if their badges are green. No API access or waiting occurs
here, making this decision directly testable with recorded service responses.
If the bounded query contains no matching run, return None and keep the gate
incomplete. The caller may fetch again after CI starts.
- [Inspect workflow runs in their returned order](for runs as run)
1. access(`run`, "head_sha") == `sha`
Return *run* as the observed attempt for this source.
Return *None* when this commit has no observed run.
## gate
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| workflow | text | required | release.yml, extension-release.yml or executable-knowledge.yml |
| sha | text | required | Commit that the workflow must cover |
| required | list | required | Required job names, such as windows and linux |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with completion, observed run and required-job evidence |
Use `workflow`, `sha`, `required` and `root`=".". Completion requires both a
successful run for the exact commit and every named job with conclusion success.
A skipped or missing Linux job cannot pass just because the Windows job created
a release. This query checks at most 100 recent runs, returns immediately for
queued/running CI, and does not rerun or cancel anything. Polling belongs to the
agent's bounded observation cycle, not an unbounded loop hidden in a tool.
Knowledge checks use the same rule, so uploaded assets never replace a green EK
gate. Missing evidence returns complete=False with the observed run retained.
We **response = [Read recent attempts for one workflow](request(path="/repos/cflmy/marqdo/actions/workflows/" + workflow + "/runs?per_page=100", root=`root`))**.
1. not access(`response`, "ok")
Return *response* with its failure intact.
We **run = [Choose the latest attempt for this commit](select_run(runs=access(access(response, "value"), "workflow_runs"), sha=`sha`))**.
We **complete = False** and **jobs = [Start an empty required-job evidence list](table.empty_list())**.
1. `run` != None
We **answer = [Read this attempt's actual jobs](request(path="/repos/cflmy/marqdo/actions/runs/" + access(run, "id") + "/jobs?per_page=100", root=`root`))**.
1. not access(`answer`, "ok")
Return *answer* with its failed observation.
We **jobs = [Keep the observed jobs](access(access(answer, "value"), "jobs"))** and
**complete = [Require a successful completed run](access(run, "status") == "completed" and access(run, "conclusion") == "success")**.
- [Check that every required platform or knowledge job passed](for required as name)
We **matched = False** before examining this job name.
- [Match this job against observed evidence](for jobs as job)
1. access(`job`, "name") == `name` and access(`job`, "conclusion") == "success"
We **matched = True** because the named job succeeded.
We **complete = complete and matched** to preserve every missing-job failure.
`evidence` =
| complete | sha | run | jobs |
|---|---|---|---|
| `complete` | `sha` | `run` | `jobs` |
Return *[The observed gate and its evidence](result.ok(value=`evidence`))*.
## status
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with exact-source Release and executable-knowledge gates |
Use `version`, `mode`="full" and `root`="." to inspect an existing release.
The Release workflow is matched against the resolved release tag; executable
knowledge is matched against the current remote main tip. Both sources are
returned so a reviewer can see if main has advanced. Every mode requires both
Windows and Linux jobs on the tag commit. Independent packs use extension-release.yml;
full/cli use release.yml. Existing assets cannot replace missing build evidence.
A missing release or an unfinished gate leaves complete=False. This task does
not mutate GitHub, push local work, create tags, or change the requested version.
The returned service metadata is evidence for the next task, not a permission
to publish a different version or overwrite a release's existing files.
We **published = [Inspect the exact version's release](release(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`published`, "ok")
Return *published* with its failure intact.
We **planned = [Read the pure release contract](model.plan(version=`version`, mode=`mode`))**.
1. not access(`planned`, "ok")
Return *planned* with its failure intact.
We **release_data = [Keep the published metadata or None](access(published, "value"))** and
**tag = [Read the planned tag](access(access(planned, "value"), "tag"))**.
We **tagged = [Resolve its actual source commit](commit(tag=`tag`, root=`root`))**.
1. not access(`tagged`, "ok")
Return *tagged* with its failure intact.
We **main = [Observe the remote main tip](request(path="/repos/cflmy/marqdo/git/ref/heads/main", root=`root`))**.
1. not access(`main`, "ok")
Return *main* with its failure intact.
We **main_sha = [Read main's commit SHA](access(access(access(main, "value"), "object"), "sha"))**.
`knowledge_jobs` =
| name |
|---|
| gate |
We **knowledge = [Verify EK on the actual remote main commit](gate(workflow="executable-knowledge.yml", sha=`main_sha`, required=`knowledge_jobs`, root=`root`))**.
1. not access(`knowledge`, "ok")
Return *knowledge* with its failure intact.
We **workflow = "release.yml"** for a CLI or full release.
1. `mode` == "ext"
We **workflow = "extension-release.yml"** for independent extension builds.
`platform_jobs` =
| name |
|---|
| windows |
| linux |
We **platforms = [Require both platform builds for the tagged source](gate(workflow=`workflow`, sha=access(tagged, "value"), required=`platform_jobs`, root=`root`))**.
1. not access(`platforms`, "ok")
Return *platforms* with its failed gate observation.
We **release_gate = [Keep actual platform evidence](access(platforms, "value"))** and **release_complete = [Read the exact-tag completion decision](access(release_gate, "complete"))**.
We **all_complete = [Require the published release and both source-specific gates](release_data != None and release_complete and access(access(knowledge, "value"), "complete"))**,
**release_sha = [Keep the resolved release commit](access(tagged, "value"))** and
**knowledge_state = [Keep the exact-main knowledge evidence](access(knowledge, "value"))** before forming the record.
`status_data` =
| complete | release | release_sha | main_sha | release_ci | knowledge_ci |
|---|---|---|---|---|---|
| `all_complete` | `release_data` | `release_sha` | `main_sha` | `release_gate` | `knowledge_state` |
Return *[The release's observed gates and source identities](result.ok(value=`status_data`))*.
## notes
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| path | text | required | Reviewed UTF-8 bilingual notes file under the filesystem root |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result of updating only the existing release body |
Use `version`, `path`, `mode`="full" and `root`=".". This is an explicit
GitHub mutation and needs the user's release instruction; reading this handbook
or asking for status does not authorize it. The prepared notes must contain
Chinese and English highlights, the actual asset matrix, installation routes,
core-surface delta and validation limits. The author remains responsible for
those claims; this function uploads the reviewed file rather than inventing it.
Reading uses fs.read in addition to plugin. UTF-8 text and its intentional
newlines travel in a structured JSON body, never through shell quoting.
We **published = [Locate the existing release to edit](release(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`published`, "ok")
Return *published* with its failure intact.
We **release_data = [Read its metadata](access(published, "value"))**.
1. `release_data` == None
Return *[Do not invent a release when only editing notes](result.error(code="release.missing", message="release does not exist; wait for CI or attach an ext release", operation="github.notes"))*.
We **body = [Read the exact reviewed bilingual note file](fs.read_text(path=`path`))**.
We **data = [Keep the reviewed body as one named API field](table.put(in=None, at="body", value=`body`))**.
Return *[Publish the reviewed release body](request(path="/repos/cflmy/marqdo/releases/" + access(release_data, "id"), method="PATCH", data=`data`, root=`root`))*.
## create_ext
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable independent extension version |
| path | text | required | Reviewed bilingual notes committed with the release source |
| sha | text | required | Exact source commit expected from the authorized tag |
| root | text | "." | Checkout root matching the granted filesystem root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing newly created or already existing release metadata |
Use `version`, `path`, `sha` and `root`="." only for authorized extension publication. This is an explicit GitHub mutation. First resolve ext-vX.Y.Z to its actual commit and require the caller's expected SHA. Read the committed note file through native filesystem operations before requesting creation. The file must describe this version's real changes and validation limits; the task does not synthesize release claims.
An existing release is returned unchanged so a resumed upload cannot overwrite its notes or assets. A missing release is created once through the authenticated service boundary, with its exact existing tag and reviewed body. Uncertain POST completion is a failure, never an automatic replay; inspect the release before resuming. CI uses this task after packaging and then uploads with the existing gh tool without clobbering prior assets.
We **planned = [Validate the independent extension version](model.plan(version=`version`, mode="ext"))**.
1. not access(`planned`, "ok")
Return *planned*.
We **tag = [Read the exact immutable extension tag](access(access(planned, "value"), "tag"))** and **target = [Resolve the actual remote tag commit](commit(tag=`tag`, root=`root`))**.
1. not access(`target`, "ok")
Return *target*.
1. access(`target`, "value") != `sha`
Return *[Refuse publication from a different source](result.error(code="release.source_mismatch", message="extension tag differs from expected commit", operation="create_ext"))*.
We **body = [Read the reviewed version-specific bilingual notes](fs.read_text(path=`path`))**.
1. `body` == ""
Return *[Require actual reviewed notes](result.error(code="release.notes_empty", message="extension notes must not be empty", operation="create_ext"))*.
We **existing = [Observe whether an earlier creation completed](release(version=`version`, mode="ext", root=`root`))**.
1. not access(`existing`, "ok")
Return *existing*.
1. access(`existing`, "value") != None
Return *existing*, preserving the existing release.
`data` =
| tag_name | name | target_commitish | body | draft | prerelease |
|---|---|---|---|---|---|
| `tag` | `tag` | `sha` | `body` | False | False |
Return *[Create this exact tagged release once](request(path="/repos/cflmy/marqdo/releases", method="POST", data=`data`, root=`root`))*.
+220
View File
@@ -0,0 +1,220 @@
---
markup: occlusion
title: Marqdo release as an executable handbook
import:
model: ./model.mq.md
local: ./local.mq.md
github: ./github.mq.md
assets: ./assets.mq.md
ubuntu: ./ubuntu.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
---
这份入口替代需要智能体重新拼装命令的发版 SKILL。版本和 full/cli/ext 模式必须由用户选择;已有明确选择时沿用授权,不重复询问。读取本手册或检查旧版本不会授权再次发布。当前维护版本的真实只读验证可调用 status 或 verify,并传入 version="2.6.0"。
先调用 plan 查看版本对应的产物与步骤,再由 local.inspect 查看本地状态。local.bump 修订版本,作者用开发手册的原生文件工具撰写双语 CHANGELOG、发布说明与用户文档,local.docs 构建真实文档。需要 CLI 的模式先编译独立编辑器分支,再显式提交审核过的文件并推送 main;EK 在实际提交上变绿后才创建新的不可变标签。每一步保留真实 Result,不通过资产存在来掩盖失败。
多文件工程按职责分开:model 是纯产物契约;local 是本地元数据、Git 与编辑器任务;github 是提交身份及 CI 证据;assets 与 asset_io 是同字节下载、内容检查和 R2 发布;ubuntu 与 package 是 noble 源码构建及 apt 验证。标准库的文件读写、JSON/TOML、哈希、网络、日期和表格负责组合,工程插件仅承担进程、认证和压缩格式边界。开发流程不需要 Python。独立拓展包在 packs.mq.md 中通过原生文件能力暂存与检查,并外联既有 ZIP 工具;ext-v 标签触发 extension-release.yml,两个平台均使用 packs.ci 与 packs.attach_ci 完成构建、精确来源检查、创建 Release 和不覆盖已有资产的上传。创建标签前须提交 doc/releases/ext-X.Y.Z.md 双语说明。
发布必须保留以下约束:main 不跟踪 vscode-extension 源码;标签不可覆盖;不得强推或绕过钩子;full 必须具备 Windows 和 Linux 产物。拓展包同时发布到 GitHub 和 R2,所有 ZIP 先于 VERSION 指针上传。full/cli 还需 Ubuntu PPA 源码上传、构建和 apt 发布证据。Release 与 EK 都应在正确来源提交上成功。双语说明要写实际核心表面变化及验证限制,不能只用模板宣称兼容。
凭据留在原有私密存储,不作为调用参数、源码或会话绑定。网络失败先走配置代理并有界重试,再直连;仍失败时保留本地证据,使用明确配置的外联传输,不能假装完成。sudo、GPG 或 dput 若需要人工输入,报告失败阶段及具体的 marqdo call 恢复命令。gh-pages 部署需要另外的用户指令。
命令形式是 marqdo call skills/marqdo-release/index.mq.md plan 'version="2.6.0"' --json。源码仓库开发时使用已构建的 target/debug/marqdo;先按开发入口 prepare_engineering 准备插件。status 和 verify 都使用 plugin,fs.write,network.read,environment.read,用于本地暂存和公开下载的校验;preflight 只需 plugin,fs.read,plan 不需要效应授权。自动化串接可加 --require-ok:函数返回失败 Result 时退出码非零,并保留真实返回值。所有命令都从仓库根目录传 --fs-root .。
## plan
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z; inspection never chooses another version |
| mode | text | "full" | full, cli or ext |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with exact deliverable names and task routing |
Use `version` and `mode`="full" after the user's version decision.
This pure entry derives filenames and publication obligations; it grants no
effect and writes no resource. Full has ten GitHub deliverables and both native
platforms, cli keeps the independent pack version, and ext has three packs on
both GitHub and R2. Unknown modes and malformed versions fail before IO.
Follow the returned task routing to the actual callable files, whose headings
specify their inputs, outputs and failures. The routing is not a shell program
for the model to reconstruct. Inspecting the plan for an existing version is
safe and does not authorize a replacement release or a new immutable tag.
Return *[Derive the confirmed release contract](model.plan(version=`version`, mode=`mode`))*.
## preflight
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z; inspection never chooses another version |
| mode | text | "full" | full, cli or ext |
| root | text | "." | Checkout/artifact root matching --fs-root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with ready, plan and actual local checkout facts |
Use `version`, `mode`="full" and `root`="." before preparing a
release. This reads actual Git state and native version files; it does not fetch,
reset, stage, sign or publish. A clean main checkout without tracked editor
sources and without the selected local tag is ready for preparation. Existing
tags require inspection of their release state rather than replacement.
A successful Result may contain ready=False. That is a real observation, not
permission to discard dirty files or overwrite refs. During authorized release
preparation, intentional edits remain visible until the explicit commit task.
The later tag task checks matching versions, remote main identity and EK again,
so preflight cannot become stale authorization. Call with plugin,fs.read and a
filesystem root that identifies the same checkout as the plugin's root.
We **planned = [Validate the requested release contract](model.plan(version=`version`, mode=`mode`))**.
1. not access(`planned`, "ok")
Return *planned*.
We **observed = [Read the real checkout without changing it](local.inspect(root=`root`))**.
1. not access(`observed`, "ok")
Return *observed*.
We **plan_data = [Keep the pure release plan](access(planned, "value"))** and **state = [Keep the actual Git and version facts](access(observed, "value"))**.
We **exists = [Preserve any existing immutable tag](table.contains(list=access(state, "tags"), item=access(plan_data, "tag")))** and
**ready = access(state, "branch") == "main" and access(state, "changes") == "" and access(state, "extension_on_main") == "" and not exists**.
`inspection` =
| ready | plan | checkout |
|---|---|---|
| `ready` | `plan_data` | `state` |
Return *[The preparation decision with its evidence](result.ok(value=`inspection`))*.
## status
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z; inspection never chooses another version |
| mode | text | "full" | full, cli or ext |
| root | text | "." | Checkout/artifact root matching --fs-root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with source-specific GitHub CI, CDN parity and Ubuntu state |
Use `version`, `mode`="full" and `root`="." for an existing release.
This entry independently checks GitHub publication and its exact source commits,
the versioned and latest CDN bytes when packs ship, and Ubuntu publication when
the CLI ships. It creates no tag, release, upload or apt mutation. Temporary
download files are owned and cleaned by the native CDN task.
The result keeps each component's evidence and requires all applicable components
to complete. A missing or red gate, different digest, pending build or stale apt
index remains incomplete. Network failures are failed Results, not fabricated
absence. Call with plugin,fs.write,network.read,environment.read: local writes
are only bounded verification staging. An ext-only release skips Ubuntu; a
cli-only release skips CDN. Existing GitHub assets alone never prove completion.
We **source = [Observe publication and CI on the actual source identities](github.status(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`source`, "ok")
Return *source*.
We **cdn = [Verify published pack hashes and VERSION pointers](assets.status(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`cdn`, "ok")
Return *cdn*.
We **ppa = None** and **ppa_complete = True** for an extension-only release.
1. `mode` != "ext"
We **observed = [Check source publication, builds and the actual apt index](ubuntu.status(version=`version`))**.
1. not access(`observed`, "ok")
Return *observed*.
We **ppa = [Retain the real Ubuntu evidence](access(observed, "value"))** and **ppa_complete = [Read its independent completion state](access(ppa, "complete"))**.
We **github_state = [Keep GitHub evidence](access(source, "value"))** and **cdn_state = [Keep CDN evidence](access(cdn, "value"))** and
**complete = access(github_state, "complete") and access(cdn_state, "complete") and ppa_complete**.
`state` =
| complete | github | cdn | ubuntu |
|---|---|---|---|
| `complete` | `github_state` | `cdn_state` | `ppa` |
Return *[The independently measured release state](result.ok(value=`state`))*.
## verify
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z; inspection never chooses another version |
| mode | text | "full" | full, cli or ext |
| root | text | "." | Checkout/artifact root matching --fs-root |
| directory | any | None | Staging directory; None means dist/release-X.Y.Z |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with all verified local artifacts and published completion evidence |
Use `version`, `mode`="full", `root`="." and `directory`=None to
verify an existing release from its actual bytes. First download or reuse every
required GitHub artifact, check size and digest, inspect archive paths and CRCs,
and verify each package's role and version. Then status checks independent
publication channels. Existing valid local files may be reused after rechecking.
This is verification, not publication. It needs plugin,fs.write,network.read,
environment.read and can consume network time for all platform packs. Failed
checks preserve their source error and completed local files for diagnosis;
none triggers a re-upload. Full completion includes Linux and Windows, green
source-specific CI, matching CDN copies and Ubuntu's actual apt index. Keep the
returned hashes as release evidence. A later release still needs its own user
version decision and source review.
We **downloaded = [Validate all required GitHub asset bytes and package contents](assets.download(version=`version`, mode=`mode`, directory=`directory`, root=`root`))**.
1. not access(`downloaded`, "ok")
Return *downloaded*.
We **observed = [Verify all applicable published channels](status(version=`version`, mode=`mode`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed*.
We **artifacts = [Retain exact local hash evidence](access(downloaded, "value"))** and **publication = [Retain independent remote evidence](access(observed, "value"))** and **complete = [Read the real completion decision](access(publication, "complete"))**.
`evidence` =
| complete | artifacts | publication |
|---|---|---|
| `complete` | `artifacts` | `publication` |
Return *[The verified bytes and actual publication state](result.ok(value=`evidence`))*.
## finish
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z |
| mode | text | "full" | full, cli or ext |
| root | text | "." | Checkout/artifact root matching --fs-root |
| directory | any | None | Local artifact staging directory |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result succeeding only when all verified release obligations are complete |
Use `version`, `mode`="full", `root`="." and `directory`=None at the
final verification step of an authorized release. This runs verify on actual
artifact bytes and independent published channels. It does not create another
release, overwrite assets or repeat an upload.
Unlike an observational status query, this completion gate returns a failed
Result when any applicable obligation is pending. The failure retains its
evidence record so a reviewer can identify the unfinished channel. Use
--require-ok when this task is the last step of external automation; a pending
release then produces a nonzero exit status. It needs the same native staging,
network, environment and plugin grants as verify. A service failure retains its
original source diagnostic. Only this successful final gate permits reporting
the chosen release complete; changing the version still requires the user's
explicit decision.
We **observed = [Verify actual artifacts and every applicable publication channel](verify(version=`version`, mode=`mode`, root=`root`, directory=`directory`))**.
1. not access(`observed`, "ok")
Return *observed* with its original failure.
We **evidence = [Retain the complete verification record](access(observed, "value"))**.
1. not access(`evidence`, "complete")
We **failure = [Keep pending publication distinct from successful completion](result.error(code="release.incomplete", message="inspect evidence for the unfinished release obligation", operation="finish"))**.
Return *[Retain evidence with the failed completion gate](table.put(in=`failure`, at="evidence", value=`evidence`))*.
Return *observed* when every required obligation is verified.
+883
View File
@@ -0,0 +1,883 @@
---
markup: occlusion
title: Prepare and publish a reviewed source release
import:
bridge: ./_bridge.mq.md
model: ./model.mq.md
github: ./github.mq.md
fs: lib/fs.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
text: lib/text.mq.md
toml: lib/toml.mq.md
sys: lib/sys.mq.md
datetime: lib/datetime.mq.md
re: lib/re.mq.md
---
Local release tasks replace repeated command-writing with explicit callable
operations. Inspect first, use bump for version metadata, author and review the
bilingual release text, build docs, compile the editor branch separately, commit
reviewed paths, push main, wait for EK, then create the annotated tag.
These are separate tasks because their results are reviewable artifacts and
because waiting for CI is different from creating a new reference. Existing
user authorization carries through the chosen release; none of the tasks asks
for a second version choice. A new release version or a replacement tag needs
its own user decision. No task force-pushes or bypasses hooks.
Every process operation returns Result.ok/value/error. A failed compile, Git
hook or network request stops the dependent task. Multi-file metadata edits are
not a transaction: inspect any partial changes before retrying. No task cleans
or stages unrelated work, commits editor sources on main, or deploys gh-pages.
```sh
marqdo call skills/marqdo-release/local.mq.md inspect --effects plugin,fs.read --fs-root . --json
```
For mutation, use the chosen version and the effect grant described on that
heading. bump needs fs.write and plugin; the rest of the command tasks
use plugin, whose children retain normal OS authority. Do not interpret
--fs-root as a sandbox for external tools. GPG or sudo interaction is reported
at the Ubuntu boundary rather than hidden behind an unconditional success.
## inspect
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| root | text | "." | Checkout root matching --fs-root; relative to the granted runtime cwd |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with Git identity and versions read by native filesystem tools |
Use `root`="." to inspect a checkout without changing it. Git supplies branch,
HEAD, dirty paths and tags through the engineering boundary. Cargo manifests
and ext/VERSION are read with lib/fs and decoded with lib/toml and lib/text.
The version facts are therefore visible in this source rather than hidden in
an external file-reading script. No credential contents are returned.
The plugin root and --fs-root must identify the same directory; this check catches
a caller accidentally combining one checkout's Git state with another checkout's
version files. Local tags are evidence only; remote references are checked before
tagging. This operation requires plugin and fs.read but performs no publication.
We **payload = [Start an empty Git metadata request](table.empty_map())** and
**observed = [Read Git's actual repository state](bridge.request(operation="git_inspect", payload=`payload`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed* with its source error.
We **state = [Read the observed Git metadata](access(observed, "value"))** and
**cwd = [Read the native filesystem working root](sys.cwd())**.
1. access(`state`, "root") != `cwd`
Return *[Refuse inconsistent process and filesystem roots](result.error(code="release.root_mismatch", message="root must match --fs-root", operation="local.inspect"))*.
We **cli = [Read and decode the actual interpreter manifest](toml.parse(text=fs.read_text(path="Cargo.toml")))** and
**wasm = [Read and decode the actual WASM manifest](toml.parse(text=fs.read_text(path="crates/marqdo-wasm/Cargo.toml")))** and
**cli_version = [Read the interpreter package version](access(access(cli, "package"), "version"))** and
**wasm_version = [Read the WASM package version](access(access(wasm, "package"), "version"))** and
**ext_version = [Read the independent pack version](text.str_trim(s=fs.read_text(path="ext/VERSION")))**.
`versions` =
| cli_version | wasm_version | ext_version |
|---|---|---|
| `cli_version` | `wasm_version` | `ext_version` |
We **combined = [Combine native file facts with Git identity](table.merge(a=`state`, b=`versions`))**.
Return *[The actual checkout facts](result.ok(value=`combined`))*.
## command
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| argv | list | required | Exact command and argument vector; never shell source |
| cwd | text | "." | Working directory inside the checkout |
| timeout | number | 120 | Maximum child duration in seconds |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with checked exit status and bounded stdout/stderr |
Use `argv`, `cwd`=".", `timeout`=120 and `root`="." for maintained commands.
This transport keeps arguments separate even when filenames contain spaces,
quotes, dollar signs or backticks. It refuses inline shell programs, forced Git
updates and hook bypass. Git credentials are attached privately when needed;
they never become parameters or command text. Nonzero exit and timeout remain
failed Results, so a later stage cannot silently continue after a failed build.
A child inherits the caller's OS capabilities. This helper does not claim that
--fs-root makes arbitrary subprocesses safe or confines their own file access.
`payload` =
| argv | cwd | timeout |
|---|---|---|
| `argv` | `cwd` | `timeout` |
Return *[Execute this exact maintained argument vector](bridge.request(operation="command", payload=`payload`, root=`root`))*.
## replace_version
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | Cargo manifest relative to the granted filesystem root |
| old | text | required | Observed previous package version |
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Number of replaced manifest version fields |
Use `path`, `old` and `version` only after inspecting the version files.
The exact package-version line is replaced once. Other dependency versions and
surrounding documentation remain intact. The file helper refuses a missing or
ambiguous match, exposing drift instead of rewriting a whole manifest from a
model-generated template. Calling with the same version is a no-op.
This helper writes one file and is not a multi-file transaction. The calling
bump operation records which stage failed so the author can inspect any partial
changes before retrying. It needs fs.write under the supplied filesystem root.
1. `old` == `version`
Return *0* because this manifest already has the requested version.
We **find = "version = \"" + old + "\""** and
**replacement = "version = \"" + version + "\""** as exact manifest lines.
Return *[Replace only the observed package version line](fs.text_patch(path=`path`, find=`find`, replace=`replacement`))*.
## bump
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with updated version metadata and Cargo check evidence |
Use `version`, `mode`="full" and `root`="." after the user chooses the release.
Full updates CLI, WASM and ext/VERSION; cli updates the two Cargo packages; ext
updates only ext/VERSION. Cargo check updates the lockfile for CLI/full and the
Debian stanza preserves the existing maintainer while dating the entry in
Asia/Shanghai. No tag, commit, remote push, R2 upload or PPA upload happens here.
The author still writes the bilingual CHANGELOG, README/tutorial changes and
release notes: version replacement cannot decide or verify their factual claims.
Run docs and the relevant regressions after those authored changes are reviewed.
The native filesystem calls need fs.write; Cargo and packaging transport need
plugin. A failure leaves intentional local changes available for review,
rather than pretending the multi-file edit was atomic or resetting other work.
We **planned = [Validate the user-chosen version and mode](model.plan(version=`version`, mode=`mode`))**.
1. not access(`planned`, "ok")
Return *planned* with its failure intact.
We **observed = [Read current versions before changing any](inspect(root=`root`))**.
1. not access(`observed`, "ok")
Return *observed* with its failure intact.
We **state = [Keep the observed version metadata](access(observed, "value"))**.
1. access(`state`, "branch") != "main" or access(`state`, "extension_on_main") != ""
Return *[Require the main checkout without tracked editor sources](result.error(code="release.branch", message="bump runs on main; editor sources belong only on vscode-extension", operation="local.bump"))*.
1. `mode` != "ext"
We **cli_edit = [Update the interpreter package version](replace_version(path="Cargo.toml", old=access(state, "cli_version"), version=`version`))** and
**wasm_edit = [Update the WASM package version](replace_version(path="crates/marqdo-wasm/Cargo.toml", old=access(state, "wasm_version"), version=`version`))**.
`cargo_args` =
| argument |
|---|
| "cargo" |
| "check" |
| "--offline" |
We **checked = [Update Cargo.lock and verify the new package metadata](command(argv=`cargo_args`, root=`root`, timeout=600))**.
1. not access(`checked`, "ok")
Return *checked* with the local edits left for inspection.
We **packaging = [Add the dated Debian stanza through native file IO](debian(version=`version`))**.
1. not access(`packaging`, "ok")
Return *packaging* before committing any metadata.
1. `mode` != "cli"
We **ext_edit = [Write the independent extension pack version](fs.write_text(path="ext/VERSION", text=`version` + "\n"))**.
Return *[Read back all resulting metadata and dirty paths](inspect(root=`root`))*.
## docs
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result from rebuilding the actual public documentation |
Use `root`="." after authoring public sources and release-facing documentation.
This command runs the checked-in documentation builder, which uses Marqdo View
on the real pages instead of copying stale generated HTML. Generated files stay
ignored and are packaged by CI. Library-only import helpers have no main entry;
their expected page execution status does not authorize inventing a main.
A failed builder is returned as an error and is not treated as proof that docs
were refreshed. This task does not deploy gh-pages; deployment is a separate
user request, even during a full release.
`argv` =
| argument |
|---|
| "bash" |
| "scripts/build-public.sh" |
Return *[Regenerate documentation from the authored Marqdo sources](command(argv=`argv`, root=`root`, timeout=900))*.
## review_index
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| paths | list | required | Exact reviewed repository-relative file paths |
| cwd | text | "." | Git checkout within root; editor stage or main |
| root | text | "." | Checkout root matching --fs-root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result whose value lists the already staged paths |
Use `paths`, `cwd`="." and `root`="." before staging or running a
version-changing tool. This inspection reads the actual Git index with explicit
unquoted path output; UTF-8 names and spaces remain ordinary path data.
Every existing staged path must appear in the supplied reviewed file list.
A refusal leaves both the index and working tree unchanged.
The release source and editor branch share this inspection so a pre-staged
unrelated edit cannot become part of either version commit. It does not inspect
unstaged file content, authorize a commit or reset another task's index.
Newline-bearing filenames are outside this release handbook's path contract.
Requires plugin for Git; there is no network request or filesystem write.
`argv` =
| argument |
|---|
| "git" |
| "-c" |
| "core.quotepath=false" |
| "diff" |
| "--cached" |
| "--name-only" |
We **observed = [Read the current staged file names before any change](command(argv=`argv`, cwd=`cwd`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed* with its Git diagnostic.
We **staged = [Split the observed index into individual file names](text.str_split(s=access(access(observed, "value"), "stdout"), sep="\n"))**.
- [Require each existing index path to be explicitly reviewed](for staged as path)
1. `path` != "" and not [This staged path belongs to the review](table.contains(list=`paths`, item=`path`))
Return *[Preserve unrelated staged work](result.error(code="release.staged_unrelated", message=`path`, operation="review_index"))*.
Return *[The inspected index paths](result.ok(value=`staged`))*.
## commit
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| paths | list | required | Reviewed explicit paths; never use a blanket git add . |
| message | text | required | Commit message describing the actual reviewed release |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with commit output; no remote mutation |
Use `paths`, `message` and `root`="." after reviewing authored changes and
running the relevant checks. This function stages only the supplied paths,
checks the staged patch for whitespace errors, and creates an ordinary commit
with hooks enabled. It does not infer that every dirty file belongs to a release.
Editor sources remain on their own branch: do not include vscode-extension in
these paths. The current branch must be main. Only individual reviewed files are accepted;
a directory path is refused before staging. Deleted files can still be reviewed
by their exact repository path. Retries preserve already-staged deletions: Git no longer knows those missing paths in its index, so they must not be handed to git add again. Existing staged paths must all
appear in that same explicit file list before staging begins, so another task's
index work cannot be swept into the release commit. Broad pathspecs, parent
traversal and nested editor paths are rejected. These checks preserve the index
on refusal; a later hook failure keeps intentional staging available for review. The author can inspect staged changes before
this explicit commit task; a hook failure stays visible and is never bypassed.
`branch_args` =
| argument |
|---|
| "git" |
| "branch" |
| "--show-current" |
We **observed = [Require the source branch before touching its index](command(argv=`branch_args`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed* with the command diagnostic.
We **branch = [Read the actual source branch](text.str_trim(s=access(access(observed, "value"), "stdout")))**.
1. `branch` != "main"
Return *[Keep release source commits on main](result.error(code="release.commit_branch", message="source commit requires main", operation="local.commit"))*.
1. len(`paths`) == 0 or [Editor sources are not main-branch release files](table.contains(list=`paths`, item="vscode-extension"))
Return *[Require explicit reviewed main-branch paths](result.error(code="release.commit_paths", message="provide reviewed paths and exclude vscode-extension", operation="local.commit"))*.
- [Validate individual reviewed repository paths](for paths as path)
1. `path` == "." or `path` == "" or [This path is broad, outside the checkout or editor-only](re.is_match(text=`path`, pattern="(^/|(^|/)\\.\\.(/|$)|(^|/)vscode-extension(/|$)|[:*?])"))
Return *[Require concrete main-branch file paths](result.error(code="release.commit_paths", message=`path`, operation="local.commit"))*.
1. [Inspect an existing reviewed path without opening it](fs.exists(path=`path`))
We **metadata = [Require a file rather than a directory pathspec](fs.stat(path=`path`))**.
1. access(`metadata`, "is_dir")
Return *[Do not stage an entire reviewed directory](result.error(code="release.commit_paths", message=`path`, operation="local.commit"))*.
We **reviewed = [Protect all previously staged work](review_index(paths=`paths`, root=`root`))**.
1. not access(`reviewed`, "ok")
Return *reviewed* before changing the index.
`deleted_args` =
| argument |
|---|
| "git" |
| "-c" |
| "core.quotepath=false" |
| "diff" |
| "--cached" |
| "--name-only" |
| "--diff-filter=D" |
| "--no-renames" |
We **removed = [Read deletions already retained by the reviewed index](command(argv=`deleted_args`, root=`root`))**.
1. not access(`removed`, "ok")
Return *removed* with the original index diagnostic.
We **deleted = [Keep exact already-staged deletion paths](text.str_split(s=access(access(removed, "value"), "stdout"), sep="\n"))** and **stage_paths = [Start only files requiring staging](table.empty_list())**.
- [Preserve reviewed deletions when retrying a failed commit](for paths as path)
1. fs.exists(path=`path`) or not table.contains(list=`deleted`, item=`path`)
We **stage_paths = [Stage existing files and unstaged removals](table.append(list=`stage_paths`, item=`path`))**.
1. len(`stage_paths`) > 0
`prefix` =
| argument |
|---|
| "git" |
| "add" |
| -- |
We **argv = [Append only paths still requiring staging](table.concat(a=`prefix`, b=`stage_paths`))** and
**staged = [Stage those exact reviewed paths](command(argv=`argv`, root=`root`))**.
1. not access(`staged`, "ok")
Return *staged* with its failure intact.
`check_args` =
| argument |
|---|
| "git" |
| "diff" |
| "--cached" |
| "--check" |
We **checked = [Check the exact staged patch](command(argv=`check_args`, root=`root`))**.
1. not access(`checked`, "ok")
Return *checked* with its failure intact.
`commit_args` =
| argument |
|---|
| "git" |
| "commit" |
| "-m" |
| `message` |
Return *[Create an ordinary commit with hooks](command(argv=`commit_args`, root=`root`))*.
## push
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| refspec | text | "HEAD:refs/heads/main" | main, vscode-extension or a same-name stable tag; force syntax is rejected |
| cwd | text | "." | Checkout directory inside root; editor staging may override it |
| root | text | "." | Checkout root matching --fs-root; relative to the granted runtime cwd |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result confirming the exact expected remote ref SHA |
Use `refspec`="HEAD:refs/heads/main", `cwd`="." and `root`="." only for
the authorized source publication. The argument vector and retry order are
visible here: proxy first, then direct GitHub, with two attempts per route.
After each response, including an uncertain timeout, read the remote ref before
deciding to retry. Only its exact expected SHA proves that this push arrived.
A branch must match its destination; stable tags can only push to the same name.
The native boundary also rejects force and hook bypass. A test-only configured
remote can replace the network routes in an isolated fixture. Production
credentials remain private inside the engineering Git boundary. This task never
changes origin and never treats stale remote state as success. If both network
routes fail, retain local refs and use an explicitly configured SSH/HK transport
rather than force-pushing or silently skipping publication.
MARQDO_RELEASE_GIT_REMOTE is an explicit transport override for an already
reviewed SSH/HK route or an isolated fixture. The task does not invent that
route, rewrite origin or generate a jump program. The same branch checks and
exact-SHA readback apply to an override; transport success alone is insufficient.
Configure SSH identities in the existing OS store, never in tool arguments.
We **valid = [Accept only reviewed release refspec shapes](re.is_match(text=`refspec`, pattern="^(HEAD:refs/heads/(main|vscode-extension)|refs/tags/(ext-)?v[0-9]+\\.[0-9]+\\.[0-9]+:refs/tags/(ext-)?v[0-9]+\\.[0-9]+\\.[0-9]+)$"))**.
1. not `valid`
Return *[Reject arbitrary or forced ref updates](result.error(code="release.refspec", message="unsupported release refspec", operation="local.push"))*.
We **parts = [Separate the source and destination ref](text.str_split(s=`refspec`, sep=":"))** and
**source = [Read its local source](access(parts, 1))** and **destination = [Read its remote target](access(parts, 2))**.
1. `source` != "HEAD" and `source` != `destination`
Return *[Keep tag names immutable across push](result.error(code="release.refspec", message="tag destination must equal its source", operation="local.push"))*.
`rev_args` =
| argument |
|---|
| "git" |
| "rev-parse" |
| `source` |
1. `source` == "HEAD"
`branch_args` =
| argument |
|---|
| "git" |
| "branch" |
| "--show-current" |
We **observed = [Read the current source branch before any push](command(argv=`branch_args`, cwd=`cwd`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed*.
We **branch = [Keep the actual source branch](text.str_trim(s=access(access(observed, "value"), "stdout")))**.
1. `destination` != "refs/heads/" + `branch`
Return *[Refuse a different branch destination](result.error(code="release.push_branch", message="source branch must match destination", operation="local.push"))*.
We **local = [Resolve the exact local ref before transport](command(argv=`rev_args`, cwd=`cwd`, root=`root`))**.
1. not access(`local`, "ok")
Return *local* before any remote mutation.
We **expected = [Keep the expected local SHA](text.str_trim(s=access(access(local, "value"), "stdout")))** and
**override = [Read an explicitly configured fixture remote](sys.env_get(name="MARQDO_RELEASE_GIT_REMOTE"))**.
`remotes` =
| remote |
|---|
| "https://proxy.cflmy.top/github.com/cflmy/marqdo.git" |
| "https://github.com/cflmy/marqdo.git" |
1. `override` != None
`remotes` =
| remote |
|---|
| `override` |
`attempts` =
| attempt |
|---|
| 1 |
| 2 |
- [Try each configured route without changing origin](for remotes as remote)
- [Bound retries and verify after uncertain responses](for attempts as attempt)
`push_args` =
| argument |
|---|
| "git" |
| "push" |
| `remote` |
| `refspec` |
We **pushed = [Send the explicit ref without force](command(argv=`push_args`, cwd=`cwd`, root=`root`, timeout=180))**.
`read_args` =
| argument |
|---|
| "git" |
| "ls-remote" |
| `remote` |
| `destination` |
We **read = [Observe whether that exact ref arrived](command(argv=`read_args`, cwd=`cwd`, root=`root`, timeout=90))**.
1. access(`read`, "ok")
We **observed = [Read the server's ref response](text.str_trim(s=access(access(read, "value"), "stdout")))** and
**fields = [Separate the SHA from the ref name](text.str_split(s=`observed`, sep="\t"))**.
1. access(`fields`, 1) == `expected`
`verified` =
| ref | sha | verified |
|---|---|---|
| `destination` | `expected` | True |
Return *[The confirmed remote source identity](result.ok(value=`verified`))*.
Return *[Preserve an unconfirmed network outcome](result.error(code="release.push_unconfirmed", message="proxy retries and direct route did not confirm the expected SHA; retain local refs and inspect the configured transport", operation="local.push"))*.
## tag
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| mode | text | "full" | full, cli or ext; determines the deliverable contract |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result confirming a new annotated tag on the checked remote commit |
Use `version`, `mode`="full" and `root`="." only for the already authorized
release. Main must be clean, contain no tracked editor source, and carry the
mode's matching versions. A local existing tag is rejected. The remote main SHA
must equal local HEAD, and its latest EK gate must be green before this task
creates anything. These conditions preserve the release skill's hard rules.
The remote source identity is retained as evidence for CI matching.
The tag is annotated and then pushed through the same bounded proxy transport.
If pushing fails after local creation, call push with that exact tag refspec;
do not rerun tag, delete the tag or move it to a new commit. An ext tag triggers
extension-release.yml, which runs packs.ci and packs.attach_ci on Windows and Linux.
Commit reviewed bilingual doc/releases/ext-X.Y.Z.md notes before creating that tag.
The notes travel in the tagged checkout, so CI reads the reviewed content rather
than reconstructing publication text. Existence and nonempty checks are only a
preflight: the author must still verify the actual changes, asset scope and test
limits before committing. A clean checkout ensures the note file is included in
the source decision; the later CI creation task verifies the same commit again.
This function creates an immutable release reference. Its invocation needs the
release authorization; merely reading this file or running inspect is read-only.
We **planned = [Validate the authorized version and release mode](model.plan(version=`version`, mode=`mode`))**.
1. not access(`planned`, "ok")
Return *planned* with its failure intact.
1. `mode` == "ext"
We **notes_path = "doc/releases/ext-" + version + ".md"**.
1. not [The independent pack's reviewed notes exist](fs.exists(path=`notes_path`))
Return *[Require committed version-specific release notes](result.error(code="release.notes_missing", message=`notes_path`, operation="local.tag"))*.
1. [The independent pack's note file is empty](fs.read_text(path=`notes_path`) == "")
Return *[Require actual bilingual release content](result.error(code="release.notes_empty", message=`notes_path`, operation="local.tag"))*.
We **observed = [Require an actual clean main checkout](inspect(root=`root`))**.
1. not access(`observed`, "ok")
Return *observed* with its failure intact.
We **state = [Read observed branch and version metadata](access(observed, "value"))** and
**tag_name = [Read the mode's immutable tag name](access(access(planned, "value"), "tag"))**.
1. access(`state`, "branch") != "main" or access(`state`, "changes") != "" or access(`state`, "extension_on_main") != ""
Return *[Reject a dirty or wrong-branch release](result.error(code="release.dirty", message="tagging requires clean main without tracked editor sources", operation="local.tag"))*.
1. [This tag already exists locally](table.contains(list=access(`state`, "tags"), item=`tag_name`))
Return *[Preserve the existing immutable tag](result.error(code="release.tag_exists", message="existing tag requires inspection; never replace it", operation="local.tag"))*.
1. `mode` != "ext" and (access(`state`, "cli_version") != `version` or access(`state`, "wasm_version") != `version`)
Return *[Reject mismatched CLI metadata](result.error(code="release.versions", message="CLI and WASM must match the chosen version", operation="local.tag"))*.
1. `mode` != "cli" and access(`state`, "ext_version") != `version`
Return *[Reject a mismatched extension pack](result.error(code="release.versions", message="ext/VERSION must match the chosen pack version", operation="local.tag"))*.
We **remote = [Read the current remote main reference](github.request(path="/repos/cflmy/marqdo/git/ref/heads/main", root=`root`))**.
1. not access(`remote`, "ok")
Return *remote* with its failure intact.
We **sha = [Read the remote source identity](access(access(access(remote, "value"), "object"), "sha"))**.
1. `sha` != access(`state`, "commit")
Return *[Require the reviewed commit to be pushed first](result.error(code="release.unpushed", message="remote main differs from local HEAD", operation="local.tag"))*.
`required` =
| name |
|---|
| gate |
We **knowledge = [Require green EK before publishing a tag](github.gate(workflow="executable-knowledge.yml", sha=`sha`, required=`required`, root=`root`))**.
1. not access(`knowledge`, "ok")
Return *knowledge* with its failure intact.
1. not access(access(`knowledge`, "value"), "complete")
Return *[Keep a red or running gate visible](result.error(code="release.ek_incomplete", message="wait for or fix EK on the exact main commit", operation="local.tag"))*.
`argv` =
| argument |
|---|
| "git" |
| "tag" |
| "-a" |
| `tag_name` |
| "-m" |
| `tag_name` |
We **created = [Create the new annotated tag without replacement](command(argv=`argv`, root=`root`))**.
1. not access(`created`, "ok")
Return *created* with its failure intact.
Return *[Push the same immutable tag and verify the remote SHA](push(refspec="refs/tags/" + tag_name + ":refs/tags/" + tag_name, root=`root`))*.
## editor_workspace
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Validated release version naming the isolated editor stage |
| root | text | "." | Checkout root matching --fs-root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing the isolated vscode-extension directory |
Use `version` and `root`="." after model.plan validates the release.
This task creates a separate clone under .marqdo/release/editor-X.Y.Z. The main
checkout never receives editor files. Git clones only the vscode-extension branch;
proxy transport is attempted before direct GitHub. A failed clone that leaves a
directory is retained for diagnosis rather than deleted or reset to retry.
An existing stage is reusable only when its branch is vscode-extension and its
origin is one of this project's explicit release transports. That check prevents
npm from being sent into an unrelated repository merely because its path exists.
The stage is deliberately persistent: inspect a failed install or compile there,
then call extension again. No source merge, hard reset, stash or force checkout
is performed. Requires plugin and fs.write under the same root. Normal Git
credential stores remain private inside the engineering boundary.
The returned path is only local preparation evidence, not a pushed editor
commit. The extension task below performs package versioning, dependency install,
compilation, narrowly scoped staging and normal push. Publishing on the editor
branch remains part of the user's authorized CLI/full release; simply reading
this file or running preflight authorizes none of those mutations.
We **directory = ".marqdo/release/editor-" + version** and **parent = [Prepare the ignored release stage parent](fs.make_dirs(path=".marqdo/release"))**.
`remotes` =
| remote |
|---|
| "https://proxy.cflmy.top/github.com/cflmy/marqdo.git" |
| "https://github.com/cflmy/marqdo.git" |
1. not [An existing stage needs inspection before reuse](fs.exists(path=`directory`))
- [Try maintained transports without replacing an existing stage](for remotes as remote)
`clone_argv` =
| argument |
|---|
| "git" |
| "clone" |
| "--single-branch" |
| "--branch" |
| "vscode-extension" |
| `remote` |
| `directory` |
We **cloned = [Clone only the editor-source branch](command(argv=`clone_argv`, root=`root`, timeout=300))**.
1. access(`cloned`, "ok")
Return *[Validate the newly created stage before using npm](editor_workspace(version=`version`, root=`root`))*.
1. [A failed partial clone needs explicit diagnosis](fs.exists(path=`directory`))
Return *cloned* with its preserved directory.
Return *[Report exhausted clone transports](result.error(code="release.editor_clone", message="both editor clone transports failed", operation="editor_workspace"))*.
`branch_argv` =
| argument |
|---|
| "git" |
| "branch" |
| "--show-current" |
We **observed = [Read the stage's real branch](command(argv=`branch_argv`, cwd=`directory`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed*.
We **branch = [Trim the actual branch name](text.str_trim(s=access(access(observed, "value"), "stdout")))**.
1. `branch` != "vscode-extension"
Return *[Preserve a stage on another branch](result.error(code="release.editor_branch", message="stage must remain on vscode-extension", operation="editor_workspace"))*.
`origin_argv` =
| argument |
|---|
| "git" |
| "remote" |
| "get-url" |
| "origin" |
We **observed = [Read the stage's source repository](command(argv=`origin_argv`, cwd=`directory`, root=`root`))**.
1. not access(`observed`, "ok")
Return *observed*.
We **origin = [Keep the actual origin URL](text.str_trim(s=access(access(observed, "value"), "stdout")))**.
1. not [The source belongs to this release project](table.contains(list=`remotes`, item=`origin`))
Return *[Refuse an unrelated editor stage](result.error(code="release.editor_origin", message="stage origin is outside the maintained project transports", operation="editor_workspace"))*.
`stage` =
| directory | branch |
|---|---|
| `directory` | `branch` |
Return *[The inspected isolated editor checkout](result.ok(value=`stage`))*.
## extension
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| root | text | "." | Checkout directory; pass --fs-root . from its root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with an isolated editor-branch commit and confirmed remote SHA |
Use `version` and `root`="." for an authorized full/cli release. This handbook
prepares a separate clone under .marqdo/release and checks out only the
vscode-extension branch there. Main never receives the ignored editor source.
A failed existing stage is resumed without reset or deletion so local evidence
remains reviewable. npm updates package.json and its lockfile; install and
compile run before that version commit is pushed. Unrelated staged files are
refused before npm modifies anything. Repeating a successful build with unchanged
version files skips the empty commit and resumes exact-SHA push verification.
An editor-branch failure leaves main unchanged and retains its separate workspace.
This task requires Node/npm and network access through plugin. CI packages
the VSIX from the pushed branch; this local task verifies compilation but does
not upload a separate Marketplace package. A compile or push failure propagates
and leaves the stage available for inspection. No model-generated terminal
program is needed to repeat these same mechanics for the next release.
We **planned = [Accept a valid confirmed editor version](model.plan(version=`version`, mode="cli"))**.
1. not access(`planned`, "ok")
Return *planned* with its failure intact.
We **workspace = [Prepare or resume the isolated editor-source checkout](editor_workspace(version=`version`, root=`root`))**.
1. not access(`workspace`, "ok")
Return *workspace* with its failure intact.
We **cwd = [Keep the editor checkout separate from main](access(access(workspace, "value"), "directory"))**.
`reviewed_paths` =
| path |
|---|
| "vscode-extension/package.json" |
| "vscode-extension/package-lock.json" |
We **reviewed = [Protect unrelated editor index work before npm changes versions](review_index(paths=`reviewed_paths`, cwd=`cwd`, root=`root`))**.
1. not access(`reviewed`, "ok")
Return *reviewed* before installing or versioning.
`version_argv` =
| argument |
|---|
| "npm" |
| "version" |
| `version` |
| "--no-git-tag-version" |
| "--allow-same-version" |
| "--prefix" |
| "vscode-extension" |
We **updated = [Update the editor package and lockfile version](command(argv=`version_argv`, cwd=`cwd`, root=`root`))**.
1. not access(`updated`, "ok")
Return *updated* with its failure intact.
`install_argv` =
| argument |
|---|
| "npm" |
| "ci" |
| "--no-audit" |
| "--prefix" |
| "vscode-extension" |
We **installed = [Install the declared editor build dependencies](command(argv=`install_argv`, cwd=`cwd`, root=`root`, timeout=600))**.
1. not access(`installed`, "ok")
Return *installed* with its failure intact.
`compile_argv` =
| argument |
|---|
| "npm" |
| "run" |
| "compile" |
| "--prefix" |
| "vscode-extension" |
We **compiled = [Compile the editor source before publishing it](command(argv=`compile_argv`, cwd=`cwd`, root=`root`, timeout=300))**.
1. not access(`compiled`, "ok")
Return *compiled* with its failure intact.
`stage_argv` =
| argument |
|---|
| "git" |
| "add" |
| -- |
| "vscode-extension/package.json" |
| "vscode-extension/package-lock.json" |
We **staged = [Stage only the editor version files](command(argv=`stage_argv`, cwd=`cwd`, root=`root`))**.
1. not access(`staged`, "ok")
Return *staged* with its failure intact.
`changed_args` =
| argument |
|---|
| "git" |
| "diff" |
| "--cached" |
| "--name-only" |
We **changes = [Observe whether the successful rebuild changed the version files](command(argv=`changed_args`, cwd=`cwd`, root=`root`))**.
1. not access(`changes`, "ok")
Return *changes* with the index diagnostic.
We **changed = [Retain the actual staged changes](text.str_trim(s=access(access(changes, "value"), "stdout")))**.
1. `changed` != ""
`commit_argv` =
| argument |
|---|
| "git" |
| "commit" |
| "-m" |
| "vscode-extension: bump to `version` for release" |
We **committed = [Commit the compiled version when there is a real change](command(argv=`commit_argv`, cwd=`cwd`, root=`root`))**.
1. not access(`committed`, "ok")
Return *committed* with its hook or commit failure.
Return *[Push only the editor branch and verify its SHA](push(refspec="HEAD:refs/heads/vscode-extension", cwd=`cwd`, root=`root`))*.
## debian
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable X.Y.Z explicitly chosen by the user |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result reporting whether a Debian source stanza was added |
Use `version` after its release plan has been validated. The existing
changelog supplies the maintainer identity; Marqdo reads it, checks whether that
upstream already has a revision, and creates the dated stanza through native
file IO. Asia/Shanghai supplies the release date, independent of the execution
host's default timezone. This is a local metadata edit, not a source upload.
An existing revision for this upstream is retained, including packaging fixes.
The source archive rules remain the packaging tool's responsibility: never
rewrite an orig archive already accepted by Launchpad. This helper needs fs.write
and time.read, preserves older changelog entries, and returns a recoverable
failure if the old maintainer line cannot be identified.
We **previous = [Read the actual Debian changelog](fs.read_text(path="debian/changelog"))**.
1. [This upstream already has a packaging revision](text.starts_with(text=`previous`, prefix="marqdo (" + `version` + "-"))
Return *[Preserve its reviewed revision](result.ok(value=False))*.
We **maintainer = [Retain the changelog's maintainer identity](re.find(text=`previous`, pattern="(?m)^ -- .+? "))**.
1. `maintainer` == None
Return *[Require an existing maintainer identity](result.error(code="release.debian_maintainer", message="no changelog maintainer line", operation="local.debian"))*.
We **now = [Read the actual release clock](datetime.now())** and
**local = [Use the release timezone](datetime.in_zone(dt=`now`, zone="Asia/Shanghai"))** and
**date = [Format the Debian timestamp](datetime.format(dt=`local`, style="%a, %d %b %Y %H:%M:%S %z"))** and
**stanza = "marqdo (" + version + "-1ppa1) noble; urgency=medium\n\n * Release " + version + "; see the reviewed upstream CHANGELOG.\n\n" + maintainer + date + "\n\n"**.
We **written = [Atomically prepend this packaging entry](fs.atomic_write(path="debian/changelog", text=`stanza` + previous))**.
Return *[Report the actual local metadata change](result.ok(value=True))*.
+162
View File
@@ -0,0 +1,162 @@
---
markup: occlusion
title: Release model and deliverable contract
import:
re: lib/re.mq.md
result: lib/result.mq.md
table: lib/table.mq.md
---
This is the pure release model: version choice belongs to the user, while artifact
names and stage requirements are derived here once. Calling plan never edits a
file, contacts a service, tags a commit or publishes a package. It is suitable
for an agent to inspect before requesting any effect grant.
Full releases unify CLI, WASM, extension pack and VSIX versions. CLI releases keep
the independently versioned extension pack. Ext releases publish source and both
native packs to GitHub and R2 without retagging the CLI or uploading an Ubuntu CLI.
A tag is a reference to an immutable source decision; an existing tag is not an
invitation to overwrite it. The transport enforces the no-force constraint too.
Use marqdo call skills/marqdo-release/model.mq.md plan 'version="2.6.0"' --json.
The example describes the already published version; it grants no authorization
to publish it again. Inspecting an existing release uses index.status instead.
## plan
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z; never infer the next release |
| mode | text | "full" | full, cli or ext; this selects required deliverables |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Derive required assets and stages from a confirmed version and release mode. |
Derive required assets and stages from a confirmed version and release mode.
Use `version` and `mode`="full". Stable versions have three nonnegative decimal
components without leading zeroes. Unknown modes and malformed versions return
release.input failures before any path or command can be constructed.
The result includes exact filenames; platform completeness is therefore a data
check rather than a model's recollection of what should have been uploaded.
We **valid = [Accept only stable X.Y.Z version input](re.is_match(text=`version`, pattern="^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"))**.
1. not `valid`
Return *[Report an invalid confirmed version](result.error(code="release.input", message="version must be stable X.Y.Z without leading zeroes", operation="plan"))*.
1. `mode` != "full" and `mode` != "cli" and `mode` != "ext"
Return *[Report an unsupported release mode](result.error(code="release.input", message="mode must be full, cli or ext", operation="plan"))*.
We **cdn = [Read the maintained cdn contract](cdn_names(version=`version`))**.
We **cli = [Read the maintained cli contract](cli_names(version=`version`))**.
1. `mode` == "ext"
We **required = cdn** and **tag = "ext-v" + version** for an independent pack.
2. `mode` == "cli"
We **required = cli** and **tag = "v" + version** for the interpreter.
3. *
We **required = [Require both CLI and cross-platform extension assets](table.concat(a=`cli`, b=`cdn`))** and **tag = "v" + version**.
We **stages = [Read the maintained stages contract](stages_names())**.
We **needs_ppa = [Select Ubuntu publication for CLI and full modes](mode != "ext")**.
`plan_data` =
| version | mode | tag | required | cdn | ppa | stages |
|---|---|---|---|---|---|---|
| `version` | `mode` | `tag` | `required` | `cdn` | `needs_ppa` | `stages` |
After establishing the contract, return *[The pure release plan](result.ok(value=`plan_data`))*.
## cdn_names
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable version already accepted by plan |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Exact cdn release asset names |
Exact cdn release asset names.
Source and native assets are three separate deliverables. The source ZIP contains
readable extension modules; each native ZIP contains platform-specific plugins.
Windows success cannot stand in for Linux support. Publishing uses all three
files from the same GitHub release and writes VERSION pointers only after uploads.
Use `version` for these filenames. This helper performs no IO.
`cdn` =
| filename |
|---|
| "marqdo-`version`-ext.zip" |
| "marqdo-`version`-native-x86_64-pc-windows-msvc.zip" |
| "marqdo-`version`-native-x86_64-unknown-linux-gnu.zip" |
We return *cdn* once this contract is assembled.
## cli_names
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | Stable version already accepted by plan |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Exact cli release asset names |
Exact cli release asset names.
The executable is convenient for an existing installation; each platform bundle
also carries readable libraries and the platform runtime dependencies. The
standard-library ZIP supports source inspection, the source ZIP identifies the
tagged repository, the VSIX is installed into the editor, and the public ZIP is
offline documentation. These roles remain distinct even when some content overlaps.
Use `version` for these filenames. This helper performs no IO.
`cli` =
| filename |
|---|
| "marqdo-`version`-x86_64-pc-windows-msvc.exe" |
| "marqdo-`version`-x86_64-pc-windows-msvc.zip" |
| "marqdo-`version`-x86_64-unknown-linux-gnu.zip" |
| "marqdo-`version`-stdlib.zip" |
| "marqdo-`version`-source.zip" |
| "marqdo-`version`.vsix" |
| "marqdo-`version`-public.zip" |
We return *cli* once this contract is assembled.
## stages_names
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Task routing for the release lifecycle |
Task routing for the release lifecycle.
The routing table is a map for the agent, not a shell script to rewrite.
Each task resolves to a callable heading in this package. Mode-specific work
is selected by plan.mode and plan.ppa; an ext release skips the CLI and Ubuntu
stages. Any external-state failure remains visible to the next invocation.
Review bilingual notes before the notes task, and retain the returned commit
and artifact hashes with the release record. The table orders responsibilities;
it never authorizes a version the user has not chosen.
CI waiting is observational and bounded by the caller, so asking for status does
not queue another release or repeat an upload.
`stages` =
| @ | task | responsibility |
|---|---|---|
| 1 | local.inspect / index.preflight | versions, branch, tree and tag checks |
| 2 | local.bump / local.docs | version files, reviewed notes and generated documentation |
| 3 | local.extension | VSIX source version on its own branch |
| 4 | local.commit / local.push / local.tag | reviewed commit, proxy push, immutable annotated tag |
| 5 | packs.ci / packs.attach_ci (ext); github.status / github.notes / assets.download | both-platform exact-tag builds, reviewed bilingual notes and verified GitHub assets |
| 6 | assets.publish / assets.status | exact same extension bytes on R2 and GitHub |
| 7 | ubuntu.ship / ubuntu.status | signed noble source upload, build and apt publication |
We return *stages* once this contract is assembled.
+159
View File
@@ -0,0 +1,159 @@
---
markup: occlusion
title: Ubuntu 源码包的原生文件处理
import:
fs: lib/fs.mq.md
json: lib/json.mq.md
table: lib/table.mq.md
text: lib/text.mq.md
re: lib/re.mq.md
result: lib/result.mq.md
toml: lib/toml.mq.md
---
本文件由已维护的 Debian 打包脚本调用。文件枚举、JSON 修订和 changelog 更新使用 Marqdo 固有库;cargo vendor、tar、debuild、GPG 和 dput 是已有工具的外联边界。任务失败应立即中止外层脚本,不能继续签名或上传不完整的源码包。
元数据读取任务使用仓库根目录和 fs.read;暂存修订任务要求把 --fs-root 指向实际暂存源码根目录,并授权 fs.write。它们不会选择版本、创建 Git 标签或上传文件。发布者必须先检查所需版本及打包修订号,已经被 Launchpad 接受的 orig 归档必须复用原字节。
## upstream
| 返回 | 类型 | 说明 |
|---|---|---|
| result | text | Current interpreter version read from Cargo package metadata |
Run this task at the checkout root with fs.read. It reads Cargo.toml through
the native filesystem and TOML parser, then selects package.version rather than
matching an arbitrary dependency version. The release preflight checks that this
actual version is the one the user requested; this helper never chooses a version.
Without --json, marqdo call prints this text on stdout. The maintained Debian
tool boundary captures that exact output; it does not run sed over the manifest
or regenerate a Python reader. Invalid files retain their native diagnostics.
No network, Git mutation, changelog edit or package upload occurs here.
We **manifest = [Read and decode the actual interpreter manifest](toml.parse(text=fs.read_text(path="Cargo.toml")))**.
Return *[The current Cargo package version](access(access(manifest, "package"), "version"))*.
## debian_version
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| series | text | "noble" | Ubuntu series appended to the existing packaging revision |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Full Debian version text, or failed Result for invalid input |
Use `series`="noble" at the checkout root. Read the current upstream version
and first Debian changelog header through native Marqdo file operations. Retain
the existing packaging revision, remove its old series suffix and append the
selected series. If the changelog has no revision, use 1ppa1, matching the
maintained packaging rule. This is a read-only projection, not a revision bump.
A missing marqdo header or invalid series returns a failed Result. The shell
boundary uses --require-ok, so that failure stops before a staging directory or
signature is created. A successful non-JSON call prints only the version text.
Use local.debian or an explicit reviewed changelog edit to choose a new packaging
revision; never silently increment one to bypass an existing upstream archive.
1. not [The Ubuntu series has the expected shape](re.is_match(text=`series`, pattern="^[a-z][a-z0-9]*$"))
Return *[Reject invalid packaging input](result.error(code="package.series", message=`series`, operation="debian_version"))*.
We **version = [Read the actual interpreter version](upstream())** and **source = [Read the existing Debian changelog](fs.read_text(path="debian/changelog"))** and
**header = [Require its first package declaration](re.find(text=`source`, pattern="^marqdo \\([^)]+\\)"))**.
1. `header` == None
Return *[Keep a missing changelog header visible](result.error(code="package.changelog", message="missing marqdo changelog header", operation="debian_version"))*.
We **observed = [Extract the declared package version](re.replace(text=`header`, pattern="^marqdo \\(([^)]+)\\)$", with="$1"))** and
**base = [Remove the previously selected series suffix](re.replace(text=`observed`, pattern="~.*$", with=""))** and **revision = "1ppa1"**.
1. [The existing version contains a packaging revision](re.is_match(text=`base`, pattern="-"))
We **revision = [Keep the reviewed revision after the upstream component](re.replace(text=`base`, pattern="^[^-]+-", with=""))**.
Return *[The packaging version for this upstream and Ubuntu series](version + "-" + revision + "~" + series)*.
## vendor_config
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing the natively written staging Cargo configuration |
Run after cargo vendor in a disposable source-package root. The explicit
configuration makes Cargo use that root's vendor directory when Launchpad builds
offline. Directory creation and UTF-8 writing use the native filesystem rather
than a shell heredoc. Grant fs.write and point --fs-root at the staged package.
The file is replaced atomically, as the prior packaging script did. This helper
is for the generated staging tree, not for silently changing a developer's
personal Cargo settings. It neither downloads crates nor changes vendor checksums;
sanitize_vendor remains a separate reviewed task. A write failure propagates and
the packaging boundary must stop before building or signing the source archive.
We **directory = [Prepare the staged Cargo configuration directory](fs.make_dirs(path=".cargo"))** and
**configuration = "[source.crates-io]\nreplace-with = \"vendored-sources\"\n\n[source.vendored-sources]\ndirectory = \"vendor\"\n"**.
We **saved = [Atomically write the explicit offline source configuration](fs.atomic_write(path=".cargo/config.toml", text=`configuration`))**.
Return *[The actual prepared path](result.ok(value=".cargo/config.toml"))*.
## sanitize_vendor
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:移除的备份文件数与修改的 checksum 文件数 |
cargo vendor 完成后执行此任务。Debian 的清理步骤会删除 .orig 和 .rej 文件;若 Cargo 的 vendor 清单仍引用这些文件,离线构建就会失败。因此先枚举每个 crate 的真实 checksum,删除对应条目及备份文件,再原子保存清单。普通源码文件和 package 校验值保持原样。
路径来自生成的清单,但仍需验证没有父目录跳转或绝对路径。一个 crate 完成后才处理下一个;发生错误时已完成的修订留在暂存目录供诊断,不能宣称整个目录修改具有事务性。重复运行不会继续增加计数,也不应引入 Python 作为备用写入器。
The package checksum and the individual file checksums serve different purposes.
Retain the upstream package digest and every ordinary source entry. Removing
only backup suffixes mirrors the existing Debian clean rule; it is not a general
vendor rewrite or permission to replace code inside third-party crates.
After this task, the packaging boundary must still run the normal offline
build checks. A successful count only records this local preparation step.
Review the resulting checksum changes when diagnosing a Launchpad failure,
and preserve the staged tree if any later signing or upload operation fails.
We **checksums = [枚举 vendor 的实际校验清单](fs.find(path="vendor", pattern="**/.cargo-checksum.json"))** and **removed = 0** and **changed = 0**。
- [逐个处理 crate 的校验清单](for checksums as relative)
We **path = "vendor/" + relative** and **source = [读取校验清单](fs.read_text(path=`path`))** and **data = [解码 JSON 边界文本](json.parse(text=`source`))** and **files = [取得文件散列映射](access(data, "files"))** and **dirty = False**。
We **keys = [保留遍历开始时的文件名](table.keys(map=`files`))** and **directory = [取得此清单所在目录](re.replace(text=`path`, pattern="/[^/]+$", with=""))**。
- [仅移除 Debian 清理器会删除的备份](for keys as name)
1. [该路径是备份或补丁拒绝文件](text.ends_with(text=`name`, suffix=".orig")) or [该路径是补丁拒绝文件](text.ends_with(text=`name`, suffix=".rej"))
1. [清单路径越出 crate 边界](re.is_match(text=`name`, pattern="(^/|(^|/)\\.\\.(/|$)|\\\\|:)"))
返回*[拒绝不可信的清单路径](result.error(code="package.vendor_path", message=`name`, operation="sanitize_vendor"))*。
We **target = directory + "/" + name**。
1. [备份文件实际存在](fs.exists(path=`target`))
We **deleted = [通过固有库删除备份文件](fs.remove_file(path=`target`))** and **removed = removed + 1**。
We **files = [从校验清单删除同名项](table.delete(map=`files`, key=`name`))** and **dirty = True**。
1. `dirty`
We **data = [保留其他元数据并替换文件表](table.put(in=`data`, at="files", value=`files`))** and **encoded = [序列化修改后的边界文本](json.stringify(value=`data`, indent=4))**。
We **written = [原子保存此 crate 的清单](fs.atomic_write(path=`path`, text=`encoded` + "\n"))** and **changed = changed + 1**。
`counts` =
| removed | changed |
|---|---|
| `removed` | `changed` |
处理结束后返回*[实际修改计数](result.ok(value=`counts`))*。
## changelog
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | 包含 Debian 修订号的完整源码包版本 |
| series | text | "noble" | 目标 Ubuntu series |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:保存后的第一行 |
以 `version` 和 `series`="noble" 修订暂存目录中的 Debian changelog。这里传入的是类似 2.6.0-1ppa1~noble 的完整打包版本,不能只传上游版本。任务只替换现有首行的包版本和发行系列,维护者、签名时间和旧条目由先前准备步骤保留。
实际调用的 version 需要保留完整修订号和发行系列后缀,例如 2.6.0-1ppa1~noble。
输入必须符合 Debian 版本和 series 的字符范围;缺少现有 marqdo 首行时返回错误,避免悄悄生成一份内容不足的 changelog。这里不递增打包修订,也不重建已经接收的 orig 归档。写入采用固有库原子替换,需要 fs.write。
1. not [打包版本只包含允许的字符](re.is_match(text=`version`, pattern="^[0-9][0-9A-Za-z.+:~_-]*$")) or not [发行系列合法](re.is_match(text=`series`, pattern="^[a-z][a-z0-9]*$"))
返回*[拒绝无效打包元数据](result.error(code="package.input", message="invalid Debian version or series", operation="changelog"))*。
We **source = [读取已准备的 changelog](fs.read_text(path="debian/changelog"))** and **first = [查找现有包声明](re.find(text=`source`, pattern="^marqdo \\([^)]+\\) [^;]+;"))**。
1. `first` == None
返回*[保留缺失首行的诊断](result.error(code="package.changelog", message="missing marqdo changelog header", operation="changelog"))*。
We **header = "marqdo (" + version + ") " + series + ";"** and **updated = [仅替换已确认的首行](text.replace(text=`source`, old=`first`, new=`header`, count=1))**。
We **saved = [原子保存暂存包元数据](fs.atomic_write(path="debian/changelog", text=`updated`))**。
完成后返回*[实际保存的包声明](result.ok(value=`header`))*。
+309
View File
@@ -0,0 +1,309 @@
---
markup: occlusion
title: Independent extension-pack build tasks
import:
model: ./model.mq.md
github: ./github.mq.md
fs: lib/fs.mq.md
path: lib/path.mq.md
sys: lib/sys.mq.md
text: lib/text.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
engineering: ext/engineering/index.mq.md
---
This leaf builds source and one platform's native extension archives for an authorized version. It does not publish, choose a version, create a tag or edit version files. The extension-release workflow runs the same tasks on Windows and Linux after local.tag pushes ext-vX.Y.Z. Its attach_ci task creates the exact tagged release through the native service boundary and attaches three assets with the existing gh upload tool; assets.publish subsequently verifies those exact bytes before R2 publication.
Build all six maintained native plugins first. The native_dir contract is a directory containing their platform library names, normally target/release. Source discovery and staging use native Marqdo filesystem operations. Only ZIP encoding uses the existing platform tool: Info-ZIP on Linux, the installed bsdtar on Windows. Compiler and format boundaries do not require Python or a generated shell program.
## libraries
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| platform | text | required | x86_64-pc-windows-msvc or x86_64-unknown-linux-gnu |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing the six exact native library filenames |
Use `platform` to select the format names rather than guessing suffixes from one local file. Both platform packs must contain web, agent, quantum, linalg, llm and engineering. This pure contract neither proves ABI compatibility nor substitutes for compiling on the selected platform. Unknown targets fail before a staging directory is created.
1. `platform` == "x86_64-pc-windows-msvc"
`names` =
| name |
|---|
| web.dll |
| agent.dll |
| quantum.dll |
| linalg.dll |
| llm.dll |
| engineering.dll |
Return *[The complete Windows native contract](result.ok(value=`names`))*.
1. `platform` == "x86_64-unknown-linux-gnu"
`names` =
| name |
|---|
| libweb.so |
| libagent.so |
| libquantum.so |
| liblinalg.so |
| libllm.so |
| libengineering.so |
Return *[The complete Linux native contract](result.ok(value=`names`))*.
Return *[Reject an unsupported native target](result.error(code="packs.platform", message=`platform`, operation="libraries"))*.
## _archive
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| stage | text | required | Owned staging root with one selected ext or native directory |
| entry | text | required | ext or native directory to encode |
| output | text | required | New ZIP path under the same filesystem root |
| platform | text | required | Already validated platform target |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Checked ZIP encoder result; an existing output is never replaced |
Use `stage`, `entry`, `output` and `platform` only after build preflight. Native resolution validates the stage and output paths first; the encoder receives individual arguments and one named staging subtree. It cannot expand a generated shell expression. A failed encoder can leave the selected incomplete archive for inspection; this task never reuses it as successful output or deletes unrelated files.
The Windows runner supplies bsdtar with ZIP format support; Linux supplies Info-ZIP. Format encoding is the only external operation here. Reads, directory creation, copies, hashes and final ZIP validation remain separate explicit native tasks. The caller removes only its owned temporary stage after the child exits. Existing archives require inspection or a different output directory, keeping reruns from silently replacing publication candidates.
1. [This output already belongs to an earlier attempt](fs.exists(path=`output`))
Return *[Preserve the existing archive](result.error(code="packs.output_exists", message=`output`, operation="_archive"))*.
We **destination = [Resolve the new archive inside the granted root](fs.resolve(path=`output`))**.
`argv` =
| argument |
|---|
| zip |
| "-q" |
| "-r" |
| `destination` |
| `entry` |
1. `platform` == "x86_64-pc-windows-msvc"
`argv` =
| argument |
|---|
| tar |
| "--format=zip" |
| "-cf" |
| `destination` |
| `entry` |
Return *[Encode only the explicitly staged format subtree](engineering.checked(argv=`argv`, cwd=`stage`, timeout_ms=300000, max_output=65536))*.
## _receipt
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| file | text | required | Completed archive selected by build |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with path, SHA256, size and validated archive entries |
Use `file` after the encoder exits successfully. Hash the resulting bytes through the native filesystem, then inspect ZIP contents with the maintained archive boundary. CRC, traversal, duplicate-path and expansion checks apply to actual archive bytes; a process exit alone does not establish a valid publication candidate. A later upload still rechecks this digest.
A receipt is local evidence, not a declaration that both platforms have been built. The format boundary reads the named archive without extracting it. Failure remains a failed Result with its original diagnostic. Keep completed archives and receipts for review; the build task cleans temporary staging, not its explicitly requested outputs.
We **sha256 = [Hash the actual encoded bytes](fs.file_hash(path=`file`))** and **metadata = [Read the native file size](fs.stat(path=`file`))** and **inspected = [Validate actual ZIP entries and CRCs](engineering.inspect_zip(path=`file`))**.
1. not access(`inspected`, "ok")
Return *inspected*.
We **size = [Retain the actual byte count](access(metadata, "size"))** and **archive = [Retain validated archive evidence](access(inspected, "value"))**.
`receipt` =
| path | sha256 | size | archive |
|---|---|---|---|
| `file` | `sha256` | `size` | `archive` |
Return *[Expose the verified local candidate](result.ok(value=`receipt`))*.
## _stage_sources
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| stage | text | required | Newly created temporary root owned by build |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | None after native source copies; filesystem failures remain diagnostics |
Use `stage` with fs.write on the checkout root. Discover source files under ext while excluding native binaries and generated caches. Each returned path stays relative to ext, preserving module organization, language mirrors and VERSION. Copies use the native root and symlink policy; this task does not call cp, PowerShell file commands or an archive tool to enumerate authoring data.
The stage is private to this invocation. No existing distribution tree is cleared, and no source file is edited. Parent directories are created only for selected copies. Keeping enumeration separate from ZIP encoding makes the source list visible in Marqdo rather than embedding repository policy in a shell script.
`excluded` =
| pattern |
|---|
| native/** |
| **/target/** |
| **/node_modules/** |
| **/.git/** |
We **files = [Find maintained extension source files](fs.find(path="ext", pattern="**", exclude=`excluded`))**.
- [Copy only the discovered source entries](for files as file)
We **target = stage + "/ext/" + file** and **parent = [Find the selected native destination parent](path.parent(path=`target`))**.
We **[Create that destination directory](fs.make_dirs(path=`parent`))** and **[Copy this exact source file](fs.copy_file(src="ext/" + file, dest=`target`))**.
Return *None* after all explicit source copies finish.
## build
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable extension version already present in ext/VERSION |
| platform | text | required | One supported native target compiled by this runner |
| directory | text | "dist/ext-release" | New output directory under the granted checkout root |
| native_dir | text | "target/release" | Existing directory containing all six compiled native libraries |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing source and current-platform native archive receipts |
Use `version`, `platform`, `directory`="dist/ext-release" and `native_dir`="target/release". Grant plugin and fs.write from the checkout root. Stable version, supported platform, ext/VERSION, all six library files and both absent destination names are checked before any stage is created. This task packages previously compiled libraries; it does not claim to cross-compile Windows from Linux.
The source archive contains the readable ext tree without native binaries. The platform archive contains six libraries under native. Every file copy and output digest uses native filesystem tools, with only ZIP encoding at the existing external-tool boundary. Stage cleanup happens after encoding returns; a native filesystem diagnostic may retain the owned stage for inspection. Existing output archives are preserved rather than overwritten on a retry.
We **plan = [Validate the confirmed independent-pack version](model.plan(version=`version`, mode="ext"))** and **selected = [Select the complete platform library contract](libraries(platform=`platform`))**.
1. not access(`plan`, "ok")
Return *plan*.
1. not access(`selected`, "ok")
Return *selected*.
1. [The actual extension version differs](text.str_trim(s=fs.read_text(path="ext/VERSION")) != `version`)
Return *[Require reviewed extension metadata first](result.error(code="packs.version", message="ext/VERSION differs from the requested pack", operation="build"))*.
We **names = [Read the six required library names](access(selected, "value"))**.
- [Preflight all actual native files before staging](for names as name)
1. not [The compiled library exists](fs.exists(path=(`native_dir` + "/" + `name`)))
Return *[Keep the missing native capability visible](result.error(code="packs.library", message=`name`, operation="build"))*.
We **source = directory + "/marqdo-" + version + "-ext.zip"** and **native = directory + "/marqdo-" + version + "-native-" + platform + ".zip"**.
1. [The source output already exists](fs.exists(path=`source`)) or [The native output already exists](fs.exists(path=`native`))
Return *[Preserve all existing output candidates](result.error(code="packs.output_exists", message="inspect existing archives or choose a new directory", operation="build"))*.
We **[Create the requested output directory](fs.make_dirs(path=`directory`))** and **stage = [Allocate an owned native staging directory](fs.temp_dir(prefix=".release-pack"))**.
We **[Copy readable extension sources](_stage_sources(stage=`stage`))** and **[Create the native library subtree](fs.make_dirs(path=stage + "/native"))**.
- [Copy each selected compiled library](for names as name)
We **[Retain the exact compiled bytes](fs.copy_file(src=native_dir + "/" + name, dest=stage + "/native/" + name))**.
We **packed = [Encode the source subtree](_archive(stage=`stage`, entry="ext", output=`source`, platform=`platform`))**.
1. access(`packed`, "ok")
We **packed = [Encode the platform native subtree](_archive(stage=`stage`, entry="native", output=`native`, platform=`platform`))**.
We **[Remove only this invocation's completed staging tree](fs.remove_tree(path=`stage`))**.
1. not access(`packed`, "ok")
Return *packed*.
We **source_receipt = [Validate the actual source archive](_receipt(file=`source`))** and **native_receipt = [Validate the actual platform archive](_receipt(file=`native`))**.
1. not access(`source_receipt`, "ok")
Return *source_receipt*.
1. not access(`native_receipt`, "ok")
Return *native_receipt*.
We **sources = [Keep source candidate evidence](access(source_receipt, "value"))** and **platform_pack = [Keep native candidate evidence](access(native_receipt, "value"))**.
`receipt` =
| version | platform | source | native |
|---|---|---|---|
| `version` | `platform` | `sources` | `platform_pack` |
Return *[Expose both verified local pack candidates](result.ok(value=`receipt`))*.
## ci
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result from building the current runner's user-tagged independent pack |
Run this task only in the extension-release workflow after its compiler steps. Grant environment.read, fs.write and plugin. The runner provides GITHUB_REF_NAME and RUNNER_OS; neither is interpolated into generated shell source. Require the ext-v prefix, validate its stable version through build, and map only the two known runner operating systems to their supported targets.
This entry does not create a remote release. The workflow's separate attach_ci task attaches the exact output names after local validation. Windows contributes the source and Windows native pack; Linux contributes its native pack. CI status must subsequently cover both jobs on the exact annotated-tag commit. A failed task stops the upload step through --require-ok; no stale package replaces it.
We **tag = [Read the actual pushed tag](sys.env_get(name="GITHUB_REF_NAME"))** and **runner = [Read the actual compilation runner](sys.env_get(name="RUNNER_OS"))**.
1. `tag` == None or not [The tag selects independent extension publication](text.starts_with(text=`tag`, prefix="ext-v"))
Return *[Reject an unrelated ref](result.error(code="packs.tag", message="expected ext-vX.Y.Z", operation="ci"))*.
We **version = [Read the tag's stable version component](text.replace(text=`tag`, old="ext-v", new="", count=1))** and **platform = ""**.
1. `runner` == "Windows"
We **platform = "x86_64-pc-windows-msvc"**.
1. `runner` == "Linux"
We **platform = "x86_64-unknown-linux-gnu"**.
We **built = [Build the exact runner and tag contract](build(version=`version`, platform=`platform`))**.
1. not access(`built`, "ok")
Return *built*.
We **[Create the receipt directory through native IO](fs.make_dirs(path=".marqdo/release"))** and **[Retain exact bytes for the separate upload step](fs.write_json(path=".marqdo/release/packs.json", value=access(built, "value")))**.
Return *built*.
## _unchanged
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| receipt | map | required | Local path/SHA256 evidence returned by this runner's build |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | bool | Whether the selected archive still has the recorded byte identity |
Use `receipt` before an upload mutation. Native filesystem hashing checks the exact file selected by the build rather than trusting its name, timestamp or successful encoder exit. A missing file remains a filesystem diagnostic. A changed digest returns False and prevents release creation as well as upload. This is a preflight drift check, not a lock against concurrent writers; CI owns its output directory during publication.
Return *[Recheck the recorded candidate's actual bytes](fs.file_hash(path=access(receipt, "path")) == access(receipt, "sha256"))*.
## attach_ci
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Checked result of attaching this runner's unchanged archives without replacement |
Run after ci in the independent extension workflow, with plugin, fs.read and environment.read. The GitHub runner supplies its existing GH_TOKEN privately to the installed gh tool; credentials never become arguments or journal values. Read the saved build receipt, pushed tag and source SHA first. Only the two supported runner names are accepted, and the receipt must match that runner and exact version.
Before any service mutation, rehash both local archives and read the reviewed notes at doc/releases/ext-X.Y.Z.md. The release source must commit those bilingual notes before its immutable tag is pushed. create_ext verifies that remote tag's commit equals GITHUB_SHA, creates a missing release once, and preserves an existing release. An uncertain creation remains failed for explicit observation, not automatic retry.
Windows attaches the source archive and Windows native archive. Linux attaches only its native archive. The existing gh release upload command is an explicit service-tool boundary; no --clobber flag is used, so rerunning cannot silently replace a prior asset. An already attached file requires inspection and byte comparison rather than deleting or overwriting it. Both platform CI jobs and later GitHub/R2 parity still must pass before finish can declare the release complete.
We **tag = [Read the actual pushed tag](sys.env_get(name="GITHUB_REF_NAME"))** and **runner = [Read the actual build runner](sys.env_get(name="RUNNER_OS"))** and **sha = [Read the runner's exact source commit](sys.env_get(name="GITHUB_SHA"))**.
1. `tag` == None or `sha` == None or not [The ref selects extension publication](text.starts_with(text=`tag`, prefix="ext-v"))
Return *[Require an explicit extension CI context](result.error(code="packs.ci_context", message="missing extension tag or commit", operation="attach_ci"))*.
We **version = [Read the selected stable version](text.replace(text=`tag`, old="ext-v", new="", count=1))** and **plan = [Validate that version before choosing paths](model.plan(version=`version`, mode="ext"))**.
1. not access(`plan`, "ok")
Return *plan*.
We **platform = ""**.
1. `runner` == "Windows"
We **platform = "x86_64-pc-windows-msvc"**.
1. `runner` == "Linux"
We **platform = "x86_64-unknown-linux-gnu"**.
We **supported = [Reject unsupported compilation runners](libraries(platform=`platform`))**.
1. not access(`supported`, "ok")
Return *supported*.
We **receipt = [Read this runner's actual native build receipt](fs.read_json(path=".marqdo/release/packs.json"))**.
1. access(`receipt`, "version") != `version` or access(`receipt`, "platform") != `platform`
Return *[Reject stale or foreign runner evidence](result.error(code="packs.receipt", message="receipt version/platform mismatch", operation="attach_ci"))*.
We **source = [Read the source archive identity](access(receipt, "source"))** and **native = [Read the platform archive identity](access(receipt, "native"))**.
1. access(`source`, "path") != ("dist/ext-release/marqdo-" + `version` + "-ext.zip") or access(`native`, "path") != ("dist/ext-release/marqdo-" + `version` + "-native-" + `platform` + ".zip")
Return *[Require the exact runner output names](result.error(code="packs.receipt_path", message="receipt paths differ from the selected outputs", operation="attach_ci"))*.
1. not [_unchanged source bytes](_unchanged(receipt=`source`)) or not [Unchanged native bytes](_unchanged(receipt=`native`))
Return *[Stop before publication when local bytes drift](result.error(code="packs.changed", message="archive changed after build", operation="attach_ci"))*.
We **published = [Create or observe the exact release from reviewed committed notes](github.create_ext(version=`version`, path="doc/releases/ext-" + version + ".md", sha=`sha`))**.
1. not access(`published`, "ok")
Return *published*.
`argv` =
| argument |
|---|
| gh |
| release |
| upload |
| `tag` |
| "--repo" |
| "cflmy/marqdo" |
1. `runner` == "Windows"
We **argv = [Attach the source pack from the Windows runner](table.append(list=`argv`, item=access(source, "path")))**.
We **argv = [Attach only this runner's native pack](table.append(list=`argv`, item=access(native, "path")))**.
Return *[Upload the verified candidates without replacing existing assets](engineering.checked(argv=`argv`, timeout_ms=300000, max_output=65536))*.
+22
View File
@@ -0,0 +1,22 @@
# Release task reference
Read [the executable release entry](index.mq.md). Version and mode come from the user; existing authorization is retained. Every task has its own input/return tables, effects, failure boundaries and recovery behavior.
| Need | Actual callable source |
|---|---|
| Inspect versions and checkout | local.mq.md inspect |
| Derive mode obligations | index.mq.md plan |
| Author local source/notes | ../marqdo-dev/files.mq.md read, patch, write or apply |
| Prepare versions/editor/docs | local.mq.md bump, extension and docs |
| Commit reviewed files/push refs | local.mq.md commit, push and tag |
| Observe exact-source CI/edit reviewed notes | github.mq.md status and notes |
| Verify GitHub bytes and package roles | assets.mq.md download |
| Publish verified R2 packs/check public parity | assets.mq.md publish and status |
| Build signed noble source/check actual apt | ubuntu.mq.md ship and status |
| Require every release obligation complete | index.mq.md finish |
A failed process, hook, HTTP response or pending CI remains visible. Inspect Result.ok before value. Use --require-ok when an external automation must stop on a failed Result; observational status may truthfully return complete=False. finish turns incomplete publication into a failed completion gate and retains its evidence.
Git retries use the documented proxy then direct route. A reviewed SSH/HK route can be supplied through MARQDO_RELEASE_GIT_REMOTE; no jump program or credential value belongs in a model argument. Existing tags and failed stages remain available for inspection. Do not force, retag or reset to make a check green. If sudo, GPG or dput needs human interaction, report the exact failure and give the concrete ubuntu.mq.md ship call for the already authorized version. An accepted orig archive must retain its original bytes.
Credentials stay in existing private stores. Do not publish from reading this note, deploy gh-pages without instruction, or call an asset list proof of green CI and apt publication.
+265
View File
@@ -0,0 +1,265 @@
---
markup: occlusion
title: Ubuntu publication: source, build and apt evidence
import:
net: lib/net.mq.md
json: lib/json.mq.md
text: lib/text.mq.md
table: lib/table.mq.md
re: lib/re.mq.md
result: lib/result.mq.md
engineering: ext/engineering/index.mq.md
local: ./local.mq.md
model: ./model.mq.md
---
Ubuntu 发布分为源码接收、构建成功和 apt 索引发布三个状态。这里用 Marqdo 固有网络库读取公开证据;gzip 格式交给工程拓展解码,不启动 Python。ship 是独立的外部写入任务,只有实际发版授权才能调用。status 只读,不会尝试重新上传已经存在的版本。
源包准备和文件修订在 package.mq.md;Debian 工具链、GPG 和 dput 通过维护中的系统脚本外联。sudo、签名口令或 Launchpad 拒绝都是真实失败,需要报告确切阶段与修复命令。已接收的 orig 归档不能改字节重传,打包修复只递增 Debian 修订号。
## read_json
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| url | text | required | Public Launchpad JSON URL |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing decoded response JSON |
Use `url` for an explicitly selected public metadata endpoint. Native net.get
returns an HTTP response separately from transport success. Require status 200
before decoding its body: a 404 HTML page must never become an empty publication
record. The helper reads at most one MiB with a bounded timeout and keeps the
original transport failure. No authentication, subprocess or temporary file is
needed for these public facts.
This helper does not guess whether an upstream version has shipped. Its caller
selects matching source publications and builds from the returned records.
A schema change remains visible to that caller. Reading a successful response
is evidence for that endpoint at this time, not permission to upload a new
package. Call with network.read; further gzip decoding is a separate capability.
We **fetched = [Read bounded public Launchpad JSON](net.get(url=`url`, timeout_ms=30000, max_bytes=1048576))**.
1. not access(`fetched`, "ok")
Return *fetched* with the transport diagnostic.
We **response = [Inspect the actual HTTP response](access(fetched, "value"))**.
1. access(`response`, "status") != 200
Return *[Retain the unsuccessful HTTP status](result.error(code="ubuntu.http", message=str(access(response, "status")), operation="read_json"))*.
We **body = [Decode the successful JSON body](json.parse(text=access(response, "body")))**.
Return *[The service's actual metadata](result.ok(value=`body`))*.
## source
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z |
| series | text | "noble" | Ubuntu series being observed |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing the newest matching published source or None |
Use `version` and `series`="noble" to locate a published upstream package.
The pure release model first validates the upstream version. Launchpad returns
publication history ordered by date; select the first entry with this upstream
version followed by a Debian revision and the exact target distro series.
A newer unrelated release or another Ubuntu series cannot satisfy this check.
None is a successful observation that this version is not currently published.
An HTTP failure remains a failed Result and must not be reported as absence.
A source publication alone does not establish successful binary compilation:
builds and apt are separate tasks below. This query is public and requires
network.read. It changes neither Launchpad state nor local version metadata,
and it never infers the user's next version from the newest remote package.
We **planned = [Validate the selected upstream version](model.plan(version=`version`))**.
1. not access(`planned`, "ok")
Return *planned*.
We **observed = [Read ordered publication history](read_json(url="https://api.launchpad.net/1.0/~cflmy/+archive/ubuntu/marqdo?ws.op=getPublishedSources&source_name=marqdo&exact_match=true&status=Published&order_by_date=true"))**.
1. not access(`observed`, "ok")
Return *observed*.
We **entries = [Read actual publication records](access(access(observed, "value"), "entries"))**.
- [Choose the exact upstream and distro series](for entries as entry)
1. [The Debian revision belongs to this upstream](text.starts_with(text=access(`entry`, "source_package_version"), prefix=`version` + "-")) and access(`entry`, "distro_series_link") == "https://api.launchpad.net/1.0/ubuntu/" + `series`
Return *[The matching source publication](result.ok(value=`entry`))*.
Return *[No matching publication exists](result.ok(value=None))*.
## builds
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| publication | any | required | Source publication returned by source, or None |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with complete and the selected source's actual builds |
Use `publication` from the source task, rather than a build number copied
from a previous release. Launchpad's source record supplies the build collection.
The required amd64 build must report Successfully built. Keep all returned build
records for diagnosis, including logs and a pending or failed status.
A missing source or an empty build collection remains incomplete. Do not treat
the successful metadata request as successful compilation. The task deliberately
does not retry or rescore Launchpad jobs; those are separate external mutations
that need a concrete packaging fix and release authorization. This read requires
network.read. Successful compilation still leaves the apt publication check:
the publisher may need time to expose the binary package in the repository
index after a build turns green.
We **entries = [Start with no invented build records](table.empty_list())** and **complete = False**.
1. `publication` != None
We **observed = [Read builds belonging to this source publication](read_json(url=access(publication, "self_link") + "?ws.op=getBuilds"))**.
1. not access(`observed`, "ok")
Return *observed*.
We **entries = [Keep the real build evidence](access(access(observed, "value"), "entries"))**.
- [Require the intended Linux architecture](for entries as build)
1. access(`build`, "arch_tag") == "amd64" and access(`build`, "buildstate") == "Successfully built"
We **complete = True** because this source's amd64 binary compiled.
`state` =
| complete | entries |
|---|---|
| `complete` | `entries` |
Return *[The actual source-specific build state](result.ok(value=`state`))*.
## apt
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z |
| series | text | "noble" | Ubuntu series being observed |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with complete, package_version and the public index URL |
Use `version` and `series`="noble" to inspect the actual public amd64 apt
index. Launchpad publishes Packages.gz; the uncompressed URL may return 404.
Native net.get reads portable bytes, then the engineering format boundary
validates gzip and decodes bounded UTF-8 text. No shell pipeline, local apt cache
or Python parser substitutes for the remote index.
Find the marqdo package stanza and its exact upstream prefix plus Debian revision.
A different package's Version line cannot satisfy this check. A successful build
may precede index publication, so complete=False is an honest intermediate state.
Transport, gzip and schema failures retain their diagnostics. The task needs
network.read and plugin and writes no file. It proves repository visibility at
this instant; installation on a particular user's machine additionally depends
on their configured source and apt refresh.
We **url = "https://ppa.launchpadcontent.net/cflmy/marqdo/ubuntu/dists/" + series + "/main/binary-amd64/Packages.gz"** and
**fetched = [Read the actual compressed apt index](net.get(url=`url`, response="bytes", max_bytes=16777216))**.
1. not access(`fetched`, "ok")
Return *fetched*.
We **response = [Inspect its HTTP status](access(fetched, "value"))**.
1. access(`response`, "status") != 200
Return *[Retain index unavailability](result.error(code="ubuntu.apt_http", message=str(access(response, "status")), operation="apt"))*.
We **decoded = [Validate and decode the gzip format](engineering.gzip_text(data=access(response, "body")))**.
1. not access(`decoded`, "ok")
Return *decoded*.
We **stanzas = [Keep package fields in their own records](text.str_split(s=access(decoded, "value"), sep="\n\n"))** and **complete = False** and **package_version = None**.
- [Inspect only the marqdo package's version](for stanzas as stanza)
1. [This is the marqdo package stanza](text.starts_with(text=`stanza`, prefix="Package: marqdo\n"))
We **line = [Read its Version field](re.find(text=`stanza`, pattern="(?m)^Version: [^\n]+"))**.
1. `line` != None
We **candidate = [Remove the field label](text.replace(text=`line`, old="Version: ", new="", count=1))**.
1. [This index contains the requested upstream](text.starts_with(text=`candidate`, prefix=`version` + "-"))
We **package_version = candidate** and **complete = True**.
`state` =
| complete | package_version | url |
|---|---|---|
| `complete` | `package_version` | `url` |
Return *[The observed apt publication state](result.ok(value=`state`))*.
## status
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z |
| series | text | "noble" | Ubuntu series being observed |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result combining source publication, build and apt completion |
Use `version` and `series`="noble" to verify an existing Ubuntu release.
Each observation remains separate in the returned record so the user can tell
whether upload, compilation or apt publication is pending. Completion requires
a published source, its successful amd64 build, and the matching apt package.
This is a read-only task requiring network.read and plugin. It does not invoke
sudo, GPG, debuild or dput. Repeating status observes newer external state without
creating another upload. If a service request fails, return its real failure
rather than manufacturing a pending state. An ext-only release has no Ubuntu
obligation; the top-level release handbook handles that mode explicitly. Keep
the version provided by the caller: querying status never selects a next release
or edits the local changelog.
We **published = [Locate this upstream's source publication](source(version=`version`, series=`series`))**.
1. not access(`published`, "ok")
Return *published*.
We **publication = [Retain its matching source record](access(published, "value"))** and
**built = [Check the source-specific amd64 build](builds(publication=`publication`))**.
1. not access(`built`, "ok")
Return *built*.
We **indexed = [Verify actual apt repository visibility](apt(version=`version`, series=`series`))**.
1. not access(`indexed`, "ok")
Return *indexed*.
We **build_state = [Keep build evidence](access(built, "value"))** and **apt_state = [Keep index evidence](access(indexed, "value"))** and
**complete = publication != None and access(build_state, "complete") and access(apt_state, "complete")**.
`state` =
| complete | publication | build | apt |
|---|---|---|---|
| `complete` | `publication` | `build_state` | `apt_state` |
Return *[The independently measured Ubuntu release state](result.ok(value=`state`))*.
## ship
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| version | text | required | User-confirmed stable X.Y.Z |
| series | text | "noble" | Ubuntu series being observed |
| root | text | "." | Checkout matching --fs-root |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result from the signed Ubuntu source publication boundary |
Use `version`, `series`="noble" and `root`="." only for an authorized
CLI/full release. Verify the checked-out interpreter has that exact upstream
version before invoking the maintained Debian tools. Their signatures, orig
archive rules and dput behavior remain the operating-system boundary. File
preparation in that script delegates to package.mq.md.
This task requires plugin and fs.read and may need interactive OS credentials.
A sudo, GPG or dput failure is incomplete publication. Report the exact failing
stage and give the concrete recovery call, rather than hiding it behind success
or inventing another version. After the command succeeds, run status: upload
acceptance alone does not establish green builds or apt availability. Never
rewrite an orig archive already accepted by Launchpad.
We **observed = [Require actual checkout version metadata](local.inspect(root=`root`))**.
1. not access(`observed`, "ok")
Return *observed*.
1. access(access(`observed`, "value"), "cli_version") != `version`
Return *[Refuse a different source version](result.error(code="ubuntu.version", message="checkout version differs from requested upstream", operation="ship"))*.
`argv` =
| argument |
|---|
| "bash" |
| "scripts/ppa-ship.sh" |
| `series` |
Return *[Build, sign and upload through the maintained Debian tools](local.command(argv=`argv`, timeout=3600, root=`root`))*.
+51 -270
View File
@@ -1,281 +1,62 @@
---
name: marqdo
description: >-
Author and edit Marqdo programs (.mq.md): Markdown markers are executable
syntax (functions, calls, statements, returns, control flow). Use when writing
or modifying .mq.md files, teaching Marqdo, generating Marqdo from prose,
importing lib/* or ext/web or ext/quantum, running marqdo CLI, building dynamic
sites with ext/web, quantum circuits with ext/quantum, or when the user
mentions Marqdo, mq.md, markup-as-syntax, code-as-documentation, web/网页, or
quantum/量子 extension (ZH under ext/quantum/量子/).
description: Author, run and review readable Marqdo programs, libraries and executable knowledge. Use for .mq.md, marqdo call, Document/Endpoint/Resource web projects and quantum tools; read the executable programming and development handbooks.
---
# Marqdo development
# Marqdo
Marqdo = **Markdown markers as syntax**. A `.mq.md` file is both documentation and a runnable program. Read this skill **before** inventing syntax from Markdown habits or Python.
<!-- CORE_SYNTAX_V2.1: keep this card within the first 1200 body characters -->
<!-- CORE_SYNTAX_V2.1: must stay at the top so skill_brief budgets never truncate it -->
## CORE SYNTAX
## CORE SYNTAX (v2.1 Occlusion — mandatory)
Occlusion is the current default. `**…**` executes a statement; `*…*` returns.
Use `[intent](actual code)` in an executable position: the label is prose and
only its payload executes. Empty parentheses are a pending None stub.
Read collections with `access(coll, key)`. Classic indexing is only for explicit
legacy sources and migration. Reading narrative references never runs effects.
These rules are the **current default**. Do **not** teach Classic `[key](map)` index or “bold is return of print”. Classic migration only: [migration-classic.md](migration-classic.md).
1. **File suffix** `.mq.md`. Print with `> print text=…` / `> 打印 内容=…` — never use `**…**` to print.
2. **`**…**` = statement** (assign / call / expression). `*…*` = return. Closing markers touch the last token (no trailing space).
3. **`[描述](payload)` = occlusion:** `[]` is prose (never executed); `()` is the only executed part. Empty `()` → `None` stub.
4. **Read collections with `access(coll, key)`** (aliases `取` / `取值`). **Never** use `[key](map)` as index under default Occlusion.
5. **Foreach:** `- [描述](遍历 coll 为 item)` (`遍历`/`for`, `为`/`as`/`in`). Prefer explicit traversal when generating new code.
6. **Import / call:** frontmatter `import:` / `导入:`; call `lib.member`. One language (EN or ZH) per file.
7. **Control flow:** `#` object/type, `##`+ function, prose params (legacy `+` remains parseable), `1.`/`2.` branches, `-` loops, `N. *` else. No invented `if`/`for`/`def`/`return` keywords.
8. **Prose vs code:** blank line separates comment paragraphs from executable lines.
9. **GFM tables** for data; prefer `table.put` over `json.set` chains. `ext/**` never calls `host_*`.
10. Body narrative `[描述](target)` is lazy (NarrativeRef) — reading does not execute side effects.
| Marker | Meaning (v2.1) |
|--------|----------------|
| `#` / `##`+ | Object/type · function/method |
| Marker | Meaning |
|---|---|
| `**…**` | Statement (assign / call / expression) |
| `*…*` | Return |
| `[描述](payload)` | Occlusion step (payload executes) |
| `[intent](payload)` | Readable intent with executable payload |
| `access(c, k)` | Collection read |
| `> fn …` | Call |
| GFM table | Collection literal |
Canonical: `doc/design/core-surface.md`, `doc/design/document-native-development-guide.md`. Deeper tables: [reference.md](reference.md). Patterns: [examples.md](examples.md). Authoring craft: [marqdo-dev](../marqdo-dev/SKILL.md). Release: [marqdo-release](../marqdo-release/SKILL.md).
Executable-knowledge gate: [`tests/executable_knowledge/`](../../tests/executable_knowledge/README.md).
## Hard rules (do not violate)
1. Obey **CORE SYNTAX** above — Occlusion is default; do not emit Classic index links.
2. **Identifiers:** declare library parameters in prose as `` input `name` `` (defaults follow `=`); inside `*…*` / `**…**` bare ids are variables. Quote text literals. Standalone `>` calls: backticks where bare would be text.
3. **Structure lines** (`#` `>` `+` `-` `|`) are not wrapped in italics.
4. **Paths:** bare `/` in expressions is division; in call args / table cells unspaced `a/b` is path text. Ratios as text need quotes (`"1/5"`).
5. End side-effect-only helpers with `*None*` / `*空*` / `**` / `****` when the outer function continues. Lone `---` is a thematic break, not function end.
6. **`ext/**` never calls `host_*`.** Prefer tables over `json.set` / `json.append`.
7. **One language per file.** Sandbox trial before promoting Agent-generated trees.
8. Browser: Marqdo on WASM + `lib/browser` tables; do not hand-write business JS.
## Call one function
```markdown
# 计算器
## 加法
计算两个数字`a`和`b`的和。
*[计算结果](a + b)*
```
```
marqdo call calculator.mq.md 计算器.加法 a=2 b=3
```
prints `5`. The same command works on any `.mq.md`; the file does not need a special skill name.
## Minimal program
```markdown
# main
> print text=Hello World!
```
Chinese builtins (same functions, no import):
```markdown
# main
> 打印 内容=你好
```
## Functions, calls, end-body
```markdown
# main
> greet who=Marqdo
## greet
+ `who`
> print text=Hello, `who`!
*None*
```
- Call: `> name key=value` or `> name value`.
- Nested helpers use deeper `#` (`##`, `###`, …).
- After a helper with only side effects, end with `*None*` / whole-line `**` / `****` when later lines must stay in the outer function. Lone `---` is only a thematic break (skipped).
- In bold assigns, prefer bare calls: `**摘要 = 结账摘要 …**` (omit `>`).
## Statements, returns, branches
```markdown
**x = 1**
**y = x + 2**
## add_one
+ `n`
*n + 1*
```
```markdown
*n = 0*
1. `n` > 0
> print text=positive
2. `n` < 0
> print text=negative
3. *
> print text=zero
```
## Frontmatter imports + stdlib
A standard library is normally one `lib/*.mq.md` file: read/import/call that file directly. It is its own manual and skill; no `index.mq.md` or module handbook directory is required. Each function puts parameter/default and return tables directly below its heading, explains purpose, failures and limits, and keeps narrative above 50%. Use prose parameters, not legacy `+` declarations. Describe opaque instructions with `[what it does](actual code)` inside statement/return markers; labels do not execute. Multi-file extensions use an index to organize their files. File tools require explicit `--effects fs.read` or `--effects fs.write` with `--fs-root`; real workflows live in `examples/stdlib-handbook`. Read the [executable authoring guide](../../doc/library-development.mq.md) for inline prose and complete runnable examples.
Imports use nested YAML `import:` (`导入` equivalent): file (`.mq.md`) or short name (`lib.member`). Members are **not** flattened into the caller. Call with a bare dotted path:
```markdown
---
title: example
import:
text: lib/text.mq.md
clock: lib/time.mq.md
---
# main
**xs = > text.split value="a,b,c" sep=","**
> print text=`xs`
**t = > clock.now_unix**
```
- Import **English** or **Chinese** library file; call that file’s API names via `lib.member` (do not mix languages).
- Instance methods stay `` > `obj`.method `` (backticks on the receiver only).
- `lib/…` resolves via `MARQDO_LIB`, cwd `lib/`, or `lib/` next to the `marqdo` binary.
- Design: [module-namespace.md](../../doc/design/module-namespace.md).
- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; **`ext/agent`** — document-driven agents (see **ext/agent** below); **`ext/web`** — dynamic sites (see below); **`ext/quantum`** — circuits + Q7/Q8 (see below).
- Native plugins: `lib/plugin` — `## load` / `unload` / `list`. C ABI: `include/marqdo_abi.h`.
- Prefer `table.put` / `表.改` for list/map element updates; keep `json` for parse/stringify/quote (see `doc/design/stdlib-table.md`).
- Builtins (no import): `print`/`打印`, `input`/`输入`, `len`/`长度`, `str`/`文本`, `int`/`整数`; literals `True`/`真`, `False`/`假`, `None`/`空`; logic `and`/`且`, `or`/`或`, `not`/`非`.
Stdlib map: [reference.md](reference.md).
## Official extension: `ext/agent` (document-driven)
Install: `marqdo ext add agent` (ZH: `智能体`). Native: `cargo build --release -p marqdo_plugin_agent`.
**Constitution (do not dilute):**
1. **Code is documentation** — the runbook `.mq.md` is the model’s ground truth, not a hidden system prompt bag.
2. **Call site is first-class** — `build_step_context` injects path/function/line so the model knows where it is in the program.
3. **Document is the knowledge base (OKF)** — writeback → promote/solidify → reuse / `llm_free`; MCP/corpus are evidence only.
APIs: `# agent` / `# 智能体` → `## step` / `## plan`. Context: standing + task + **call site** + tools + budgeted source/skill + act protocol (`CALL:` / `READ:`).
Examples: [agent-pong](../../examples/agent-pong/) · [agent-okf-flywheel](../../examples/agent-okf-flywheel/) · [agent-sandbox-okf](../../examples/agent-sandbox-okf/). Harness: `scripts/agent-harness.sh`. Design: [ext-agent.md](../../doc/design/ext-agent.md) · optimize O1–O5: [ext-ai-optimize.md](../../doc/roadmap/ext-ai-optimize.md). Dev LLM: copy [.env.example](../../.env.example) → `.env` (gitignored).
**Sandbox (O1):** `import sandbox:ext/ai/sandbox.mq.md` · `agent.trial` / `智能体.试跑` · `run`/`step` take `sandbox=` / `沙盒=` (default `False`). Profile caps are tables via `sandbox.profile`. Gold: `tests/ext/agent-sandbox-optin.mq.md`.
## Official extension: `ext/web` (Document / Endpoint / Resource)
Install: `marqdo ext add web` (ZH id: `网页`). See ADR 0007 · [ext-web-artifact.md](../../doc/design/ext-web-artifact.md).
**Do not degrade:** Document/Endpoint metadata; facade `web.page|route|serve|render|inspect`; View `|type|slot|value|attrs|style|` only; no `compose_*` / `configure` / author `ensure_plugin`. DB → `ext/data`; auth → `ext/security`; net → `ext/net`.
- **Root skill (agents first):** [`ext/web/index.mq.md`](../../ext/web/index.mq.md) · ZH [`ext/web/网页/索引.mq.md`](../../ext/web/网页/索引.mq.md)(作者门面仍为 `网页.mq.md`)
- **Layout law (in-package):** file-partition pages (nav/sidebar/footer/…) until simple; no HTML/CSS injection as default — [`ext/web/layout/index.mq.md`](../../ext/web/layout/index.mq.md) · [ext-web-layout-paradigm.md](../../doc/design/ext-web-layout-paradigm.md)
- **Recursive practice:** home → nav/main/footer → footer brand/links → links docs/community; continue until a leaf is plain Markdown. Parents import children and declare one relationship. Use `component.markdown`, `component.wrap`, `layout.stack`, and `layout.columns`; merge alone gives siblings, not columns.
- **Runnable reference:** [web-layout-handbook](../../examples/web-layout-handbook/index.mq.md) and [Chinese reference](../../examples/web-layout-handbook-zh/index.mq.md). A composed Document declares `view: main` and returns node rows at startup; ordinary Documents keep their Markdown/data-source path. Use `inspect root=...` for disk routes, and `run` for a live server.
- EN author facade: `import web:ext/web/web.mq.md`
- Agent: `marqdo call ext/web/layout/index.mq.md rules --json` then facade tools with `--effects plugin`
Design: [ext-web-artifact.md](../../doc/design/ext-web-artifact.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/).
## Official extension: `ext/quantum` (circuits + Q7/Q8)
Install: `marqdo ext add quantum` (ZH id: `量子`). Build: `cargo build --release -p marqdo_plugin_quantum`, then **`marqdo ext add quantum` again** so view loads the new `libquantum.so` (stale plugin = old black/white circuits).
- **Root skill (read first):** [`ext/quantum/index.mq.md`](../../ext/quantum/index.mq.md) — explains every module and exact `marqdo call` commands for agents with no other context.
- **Ext paradigm:** [`doc/design/ext-skill-tools-paradigm.md`](../../doc/design/ext-skill-tools-paradigm.md) — code=doc=skill=tools; checklist for new packs.
- **Modules:** `circuit/` · `gate/` · `simulate/` · `state/` · `density/` · `viz/` · `_capability/` (each has `index.mq.md`). ZH package: `ext/quantum/量子/`(根 `索引.mq.md`,模块同名中文目录).
- **Agent:** `marqdo call ext/quantum/<module>/index.mq.md <fn> … --effects plugin` (`--toget` / `$name`). Narration: `marqdo check --narrative-ratio FILE`.
- **Author import example:** `circuit: ext/quantum/circuit/index.mq.md` then `circuit.circuit` / method chain.
**Hard rules:** `ext/**` never calls `host_*`; hot path is ABI plugin; ≤12 qubits for statevector; density-matrix ops ≤6 qubits; one language file per program; quote draw string args (`kind="…"`, `theme="…"`).
**Core:** domain skills above (`# circuit` / `# gate` / `# density` on module files) — table `steps=` or method chain; `simulate` / `probabilities` / `run` / `draw`.
**Q7 linear algebra:** `density`, `partial_trace`, `eig`, `expect` (Pauli string, left=high bit), `purity`, `kron`, `schmidt`, `fidelity`.
**Draw kinds:** `circuit|probs|bloch|hinton|city|density|paulivec|qsphere|multibloch`.
**Q8 themes (circuit / probs / bloch):** `theme="dark"|"light"|"bw"` (ZH `主题=`; **default `dark`** — slate lab look, gate-family colors, label chips so wires never cross `q0` text). View plot chrome follows `data-theme` on the SVG. Advanced kinds (hinton/…) still Q8c pending full re-skin.
```markdown
**_ = > `qc`.draw kind="circuit" theme="dark"**
**_ = > `qc`.draw kind="probs" theme="light"**
```
Design: [ext-quantum.md](../../doc/design/ext-quantum.md) · Q7: [ext-quantum-q7.md](../../doc/design/ext-quantum-q7.md) · Q8 viz: [ext-quantum-viz-style.md](../../doc/design/ext-quantum-viz-style.md) · examples: [quantum-bell](../../examples/quantum-bell/) · [quantum-entanglement](../../examples/quantum-entanglement/).
## Foreign kernels (v1.5.0)
`lib/foreign` is now a full foreign-kernel surface, not only `run`:
- `invoke` returns a record (`ok`, `code`, `stdout`, `stderr`, `ms`, `timed_out`, `truncated`, `result`); pass `input` for JSON stdin and `output="json"` for a parsed result.
- `call` is JSON-in / JSON-out; `call_many` fans out one program over a list with ordered results.
- `session_open` starts a persistent Python/Node kernel; `session_eval` evaluates source; `session_set` / `session_get` bridge values explicitly as JSON. Close it with `session_close`.
- A view document opts into kernel state with `会话 = > foreign.session kernels=... cells=...`; the table names are free. `view` consumes only the `会话` handle and never scans source lines or reserved table names. Without `会话`, cells are stateless one-shot runs; no kernel is created. Clearing outputs calls `/api/session/clear` and keeps persistent kernel state. There is no separate notebook CLI mode or command, and no new Markdown marker exists.
- The same source remains the authority; state crossing kernels is explicit, never implicitly mirrored.
## AI authoring workflow
1. Decide language surface (English builtins + `lib/text.mq.md`, or Chinese + `lib/文本.mq.md`).
2. Write `.mq.md` with `# main`, blank lines around prose, correct markers.
3. Run: `marqdo run path/to/file.mq.md` (cwd = project root so `lib/` resolves).
4. On `path:line:col: message`, fix that span; re-run until exit 0.
5. Optional: `marqdo view .` / `marqdo debug .` for structure and breakpoints.
## Anti-patterns (common model mistakes)
| Wrong | Right |
|-------|-------|
| `**Hello**` to print | `> print text=Hello` |
| `# main` then prose then code with no blank line | Blank line before code |
| `if x > 0:` | `1. `x` > 0` |
| `* > print text=hi *` | `> print text=hi` |
| `` *`a` = 1 * `` (trailing space + backticks) | `**a = 1**` — bare bind, no trailing space before `*` / `**` |
| `*xs = > text.split value=a,b sep=,*` (italic is return, and bare text args) | `**xs = > text.split value="a,b" sep=","**` — statement; quote text literals |
| Forgetting empty return after nested `##` helper when outer continues | Add `*None*` / `**` / `****` (not `---`) |
| Import `lib/text` then call bare `split` | `> text.split …` (qualified) |
| Import `lib/text` then call `拆分` | Match file language (`text.split`, not 文本) |
| `json.set` / `json.append` to build maps or lists | GFM tables; sparse `table.put`; named helpers (`browser.*`, `web.*`) |
| `json.set` / `compose_*` page parts | `type: web` Document + View table / `web.render` / `web.serve` |
| Import `json` for every browser handler | `import browser:lib/browser.mq.md` + tables ([marqdo-dev](../marqdo-dev/SKILL.md)) |
| Mix `web.page` and `网页.页面` in one file | One import language per `.mq.md` |
| Call `host_web_*` from `ext/web` | Use `# app` / `# db` methods; plugin ABI only |
| Call `host_*` from `ext/quantum` | Use `# circuit` / `# density` methods; plugin ABI only |
| Bare `kind=hinton` inside `*…*` | `kind="hinton"` — quote text literals |
| Bare `theme=dark` inside `*…*` | `theme="dark"` — quote; ZH `主题="dark"` |
| Rebuild plugin but skip `ext add` | `cargo build -p marqdo_plugin_quantum` then `marqdo ext add quantum` (or set `MARQDO_QUANTUM_PLUGIN`) |
## Checklist before finishing
- [ ] File ends with `.mq.md`
- [ ] Print via `print` / `打印`, not bold
- [ ] Blank lines separate comment paragraphs from code
- [ ] `# main` exists when the file is an entry program
- [ ] Nested side-effect helpers ended with `*None*` / `**` / `****` when the outer function continues
- [ ] Imports and call names share the same language file
- [ ] Data shaped as **GFM tables** (or short helpers) — no `json.set` / `json.append` glue
- [ ] Web sites: tables + web classes only (no JSON glue); `data/` gitignored
- [ ] Browser client: `lib/browser` + tables when returning effects
- [ ] Quantum draw: quote `kind=` / `theme=`; rebuild plugin → `ext add quantum` before view
- [ ] `marqdo run` succeeds (or errors addressed)
| `- [intent](for items as item)` | Explicit traversal |
| `1.` / `2.` | Branches; numbered * is else |
| GFM table | Data: one column list, one row record, @ row records |
Read [the executable programming guide](../../doc/library-development.mq.md)
before authoring. Its actual callable examples demonstrate inline computation,
structured results, defaults and recoverable native file reads. Use
[the development entry](../marqdo-dev/index.mq.md) and its file tools for source
work, and [the release entry](../marqdo-release/index.mq.md) for an authorized
release. These mq.md files are the working instructions and tools; do not rebuild
a parallel command playbook in SKILL.md.
Call the actual file and heading with `marqdo call`. In a source checkout use
the built `target/debug/marqdo`; prepare its engineering plugin through the
development entry. Large structured inputs use --args-json FILE or stdin;
JSON strings stay literal during call-session replay. --require-ok makes failed
Results stop external automation while preserving their returned evidence.
Read each function's parameter/return tables and effect contract before calling.
Author programs as readable explanations: useful narrative exceeds half of
each callable unit; parameter and return tables immediately follow its heading;
inline assignments, actions and returns explain their purpose. Standard libraries
remain single-file handbooks. Multi-file projects and extensions use index.mq.md.
GFM describes data, public helpers describe operations, and components recursively
split web layouts until their content leaves are ordinary Markdown.
Native Marqdo capabilities handle file reading/writing, tables, parsing, hashing
and network reads. Add an extension for a reusable capability gap or call an
explicit existing external tool with argument arrays. Keep decisions, retries
and the execution flow in mq.md. Do not generate Python or shell programs for
already available native operations. OS processes and plugins retain their OS
authority; an fs-root does not sandbox their own access.
Use the current [web entry](../../ext/web/index.mq.md) for Document, Endpoint and
Resource artifacts, or [quantum entry](../../ext/quantum/index.mq.md) for circuit
workflows. Do not restore removed compose_* or app.configure APIs. Preserve
intentional fixtures and [classic migration context](migration-classic.md).
Validate the real calls and error paths; a narrative ratio or uploaded asset
alone is never functional evidence.
+3 -326
View File
@@ -1,328 +1,5 @@
# Marqdo examples (AI)
# Marqdo executable examples
## 1. Hello (English)
The maintained programming rules and runnable examples live in [the executable programming guide](../../doc/library-development.mq.md). Read its parameter and return contracts, then call the actual source heading. [The development entry](../marqdo-dev/index.mq.md) provides native file operations and verification tasks; [the release entry](../marqdo-release/index.mq.md) provides publication workflows.
```markdown
# main
> print text=Hello World!
```
## 2. Hello (Chinese builtins)
```markdown
# main
> 打印 内容=你好,世界!
```
## 3. Function + named call + body end
```markdown
# main
Greeting via a nested function:
> greet who=Marqdo
## greet
+ `who`
> print text=Hello, `who`!
---
```
## 4. Bindings and return
```markdown
# main
*a = 2*
*b = > add_one n=`a`*
> print text=`b`
## add_one
+ `n`
**n + 1**
```
## 5. Branch with else
```markdown
# main
*n = 0*
1. `n` > 0
> print text=positive
2. `n` < 0
> print text=negative
3. *
> print text=zero
```
## 6. Foreach loop
```markdown
# main
`篮子` =
| 果 |
|----|
| 苹果 |
- [果](篮子)
> print text=`果`
```
## 6b. Map table + footnote get
```markdown
# main
`分类` =
| 苹果 | 黄瓜 |
|------|------|
| 水果 | 蔬菜 |
*种 = 分类[^苹果]*
> print text=`种`
*第一 = 篮子[^1]*
```
One column → list; ≥2 columns + one data row → map; ≥2 columns + many rows → map of lists. Data cells are expressions (same as call-arg values): bare words, numbers, `` `var` ``, quoted strings; URLs and `gpt-4o-mini` stay text via path/hyphen folding. Footnotes: lists use 1-based digit indices; maps use key text (including digit keys like `[^00]`). Foreach on a map walks **keys**.
Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of maps (marker column excluded):
```markdown
`订单` =
| 行 | 品名 | 数量 |
|----|------|------|
| 1 | 苹果 | 2 |
*名 = 订单[^1][^品名]*
```
## 6c. Browser effects — tables + lib/browser (not json.set)
```markdown
---
import:
browser: lib/browser.mq.md
---
# main
`wire` =
| @ | 选择器 | 事件 | 调用 |
|---|--------|------|------|
| 1 | "#bump" | click | bump |
**`wire`**
## bump
*`count` = count + 1*
*`label` = > str count*
**> browser.set_text sel="#count" text=label**
```
Do **not** build effect maps with `json.set` chains. See [marqdo-dev](../marqdo-dev/SKILL.md).
## 7. Import text stdlib
```markdown
---
title: split demo
import:
text: lib/text.mq.md
---
# main
*parts = > split value=a,b,c sep=,*
> print text=`parts`
```
## 8. Comment paragraphs (blank-line rule)
```markdown
# main
This whole paragraph is a comment, including lines that look like code:
*not_executed = 1*
> print text=also still comment
After a blank line, code runs:
> print text=this runs
```
## 9. Frontmatter import only
```markdown
---
description: loads math
import:
math: lib/math.mq.md
---
# main
*t = > num value=3.5*
> print text=`t`
```
## 10. Object handle + method
See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` constructs a map with `_type`; methods use `` > `obj`.method `` and read `self` / `自`.
## 10b. Object inheritance
```markdown
# Greeter
## hello
+ `who`
*msg = "Hello, `who`!"*
**msg**
# Loud = > Greeter
## hello
+ `who`
*msg = "HELLO, `who`!"*
**msg**
```
`_type` stays the most specific name (`Loud`). Methods walk the base chain; same-name `##` on the child overrides. **No implicit super** — if the child needs parent fields, call the parent explicitly:
```markdown
# Child = > Parent
+ `name`
*self = > Parent name=`name`*
*self = > json.set map=`self` key=extra value=1*
**self**
```
## 11. Agent layout (ABI)
```markdown
---
import:
agent: ext/agent.mq.md
---
# main
> load_native
*ws = > agent*
*n = > `ws`.ensure_layout*
> print text=`n`
```
Requires `MARQDO_AGENT_PLUGIN` pointing at the built `agent` shared library (see `doc/design/ext-agent.md`).
## 12. What not to emit
```markdown
# BAD — bold is return, not print
**Hello**
# BAD — Python control keywords
if x > 0:
print(x)
# BAD — wrapping a call in italics
*> print text=hi*
# BAD — old branch syntax (removed)
+ `x` > 0
# GOOD — ordered list arms
1. `x` > 0
> print text=pos
2. *
> print text=other
# GOOD — another independent branch (restart at 1.)
1. `y` > 0
> print text=y-pos
2. *
> print text=y-other
```
## 13. Dynamic site (Web Artifact, minimal)
`index.mq.md`:
```markdown
---
type: web
title: Hello
route: /
method: GET
---
# Hello
Executable document as a page.
```
`serve.mq.md`:
```markdown
---
import:
web: ext/web/web.mq.md
---
# main
> web.serve root="." host="127.0.0.1" port=8080
```
- Import `ext/web/web.mq.md` **or** `ext/web/网页.mq.md` — not both.
- Full Artifact blog: `examples/marqdo-blog/` (`pages/` · `api/` · `db/` · `data_source`).
- Design: `doc/design/ext-web-artifact.md` · ADR 0007. No `compose_*` / `configure`.
## 14. Quantum entanglement lab (ext/quantum Q7/Q8)
```markdown
---
import:
quantum: ext/quantum/circuit/index.mq.md
---
# main
`steps` =
| step | gate | qubits |
|------|------|--------|
| 1 | H | 0 |
| 2 | CX | 0,1 |
*qc = > quantum.circuit qubits=2 steps=`steps`*
*rho = > `qc`.density*
*red = > `rho`.partial_trace keep=0*
*sch = > `qc`.schmidt cut=1*
*_ = > `qc`.draw kind="circuit" theme="dark"*
*_ = > `qc`.draw kind="hinton"*
> print text=`red`
```
- Full lab: `examples/quantum-entanglement/`. Bell-only: `examples/quantum-bell/`.
- `theme="dark"|"light"|"bw"` (default dark) on `circuit` / `probs` / `bloch`. Quote `kind=` / `theme=`.
- After rebuilding the plugin: `marqdo ext add quantum` so view loads the new native lib.
Use [the recursive Markdown web example](../../examples/web-layout-handbook/index.mq.md) and [the quantum workflow](../../examples/quantum-entanglement/index.mq.md) for domain development. Their real source is the manual. [Classic migration context](migration-classic.md) remains for explicitly historical syntax; new programs use readable occlusion and access(collection, key). Do not copy a second fenced program from this discovery note.
+3 -189
View File
@@ -1,191 +1,5 @@
# Marqdo reference (AI)
# Marqdo executable reference
Load this when you need stdlib names, CLI, or edge cases. Core rules stay in [SKILL.md](SKILL.md).
The maintained programming rules and runnable examples live in [the executable programming guide](../../doc/library-development.mq.md). Read its parameter and return contracts, then call the actual source heading. [The development entry](../marqdo-dev/index.mq.md) provides native file operations and verification tasks; [the release entry](../marqdo-release/index.mq.md) provides publication workflows.
## CLI
```text
marqdo --version
marqdo run FILE.mq.md
marqdo run FILE.mq.md --backend bytecode
marqdo view PATH # docs browser, default port 7429
marqdo debug PATH # debugger UI, default port 7430
marqdo catalog PATH -o .marqdo
marqdo ext list
marqdo ext add llm|agent|web|quantum
marqdo ext remove llm|agent|web|quantum
```
Diagnostics look like `path:line:col: message` (1-based line/col).
**v0.2 surface:** parameters `` + `name` ``; branches `` 1. `cond` `` / `` 2. * `` (same-indent restart at `1.` = **new** branch statement); loops `` - [item](coll) `` or `` - [`item`](`coll`) ``; identifiers in backticks (foreach header may omit ticks). See `doc/design/markdown-mapping.md`.
Stdlib search order for `lib/…` imports: `MARQDO_LIB`, `./lib`, directory of the `marqdo` executable (and a few parents). Prefer the **bundle zip** (`marqdo.exe` + `lib/`) over a bare exe.
官方扩展(`ext/…`,非 stdlib):`marqdo ext add` 装到 `MARQDO_EXT` 或 `~/.marqdo/ext`;导入仍写 `import llm:ext/llm.mq.md`。解析还含 cwd `ext/`、二进制旁 `ext/`。对象:`doc/design/objects.md`。Agent:`doc/design/ext-agent.md` · 安装器:`doc/design/ext-cli.md`。
## Builtins (no import)
| EN | ZH | Role |
|----|----|------|
| `print` | `打印` | stdout; arg `text` / `内容` |
| `input` | `输入` | one line; arg `prompt` / `提示` |
| `len` | `长度` | length; arg `value` / `值` |
| `str` | `文本` | to text; arg `value` / `值` |
| `int` | `整数` | to int; arg `value` / `值` |
Keywords (not variable names): `True`/`真`, `False`/`假`, `None`/`空`, `and`/`且`, `or`/`或`, `not`/`非`.
## Standard library files
Import one file; use **that** file’s function names.
| EN import | ZH import | Typical APIs (EN / ZH) |
|-----------|-----------|-------------------------|
| `lib/text.mq.md` | `lib/文本.mq.md` | text helpers / 去空白·拆分·拼接… |
| `lib/table.mq.md` | `lib/表.mq.md` | `put`/`改` + list/map(见 `doc/design/stdlib-table.md`) |
| `lib/browser.mq.md` | `lib/浏览器.mq.md` | WASM client effect helpers(GFM + `set_text`/`canvas`/…;见 marqdo-dev) |
| `lib/fs.mq.md` | `lib/文件.mq.md` | filesystem |
| `lib/sys.mq.md` | `lib/系统.mq.md` | process / cwd / load_dotenv |
| `lib/plugin.mq.md` | `lib/插件.mq.md` | load native ABI plugins (`doc/design/ext-abi.md`) |
| `lib/time.mq.md` | `lib/时间.mq.md` | time/format |
| `lib/net.mq.md` | `lib/网络.mq.md` | HTTP(S) helpers (+ optional headers) |
| `lib/json.mq.md` | (see design) | **parse / stringify / quote only** — not a dict builder |
| `lib/math.mq.md` | `lib/数学.mq.md` | num, trig, random, formula, plot |
| `lib/foreign.mq.md` | `lib/外联.mq.md` | run foreign fenced blocks |
| `ext/llm.mq.md` | `ext/大模型.mq.md` | `# llm` / `# 大模型` object + chat methods |
| `ext/agent.mq.md` | `ext/智能体.mq.md` | document-driven **step** / **plan** + OKF;示例 `examples/agent-pong` · `agent-okf-flywheel`;Wave B:[agent-framework-2026-09.md](../../doc/research/agent-framework-2026-09.md) |
| `ext/web/index.mq.md` · `web.mq.md` | `ext/web/网页/索引.mq.md` · `网页.mq.md` | dynamic sites — see **ext/web** section below |
| `ext/quantum/index.mq.md` + modules | `ext/quantum/量子/索引.mq.md` + modules | circuits + Q7 density/viz + Q8 themes — see **ext/quantum** below |
Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names and parameters. Gold tests: `tests/lib/`, `tests/structure/`, `tests/ext/`.
## ext/web (Artifact sites · ADR 0007)
Install: `marqdo ext add web` (`网页`). Native: `bash scripts/build-web-plugin.sh`.
Layout practice: split home into nav/main/footer; split footer into brand/links,
then links into docs/community until content leaves are ordinary Markdown.
Use `component.markdown|wrap`, `layout.stack|columns`, and @ record lists.
A parent value holds child rows of the same five-column View schema.
Explicit `view: main` Documents assemble once at startup; `inspect root=...`
scans disk declarations. See the Web root handbook and reference layout site.
| EN import | ZH import | Surface |
|-----------|-----------|---------|
| `ext/web/web.mq.md` | `ext/web/网页.mq.md` | facade: `page` · `route` · `serve` · `render` · `inspect` · `use` |
| Kind | Metadata | Notes |
|------|----------|-------|
| Document | `type: web` / `类型: 网页` | `route` · `data_source` · `data_order` · `data_where` |
| Endpoint | `type: endpoint` / `类型: 端点` | `path` · `method` · `# main` handler · `request`/`response` |
| View | `|type|slot|value|attrs|style|` | `web.render nodes=` |
| Resource | `ext/data` · `ext/security` · `ext/net` | db/cache/storage · auth/rbac/oidc · websocket |
Do **not** use `compose_*` / `app.configure` / author `ensure_plugin`.
Example: `examples/marqdo-blog/`. Design: `doc/design/ext-web-artifact.md`. Historical matrix: `doc/design/web-net-capabilities.md`.
## ext/quantum (circuits + Q7/Q8)
Install: `marqdo ext add quantum` (`量子`). Native: `cargo build --release -p marqdo_plugin_quantum`, then re-run `ext add` so view picks up the new `.so`.
| EN import | ZH import | Core types |
|-----------|-----------|------------|
| `ext/quantum/circuit/index.mq.md` (etc.) | `ext/quantum/量子/电路/索引.mq.md` (etc.) | `# circuit` / `# 电路` · `# gate` / `# 门` · `# density` / `# 密度` + call tools |
| Area | EN APIs | Notes |
|------|---------|-------|
| Circuit | `h`/`cx`/…, `simulate`, `probabilities`, `run`, `draw`, `noise` | `steps=` GFM table; ≤12 qubits |
| Gate | `matrix`, `matches_matrix`, `draw` | named or `matrix=` custom unitary |
| Density (Q7) | `purity`, `partial_trace`, `eig`, `expect`, `draw` | ≤6 qubits for dense ρ |
| Free (Q7) | `kron`, `schmidt`, `fidelity` | top-level on import bind |
| Draw kinds | `circuit\|probs\|bloch\|hinton\|city\|density\|paulivec\|qsphere\|multibloch` | quote `kind="…"` |
| Themes (Q8) | `theme="dark"\|"light"\|"bw"` (ZH `主题=`) | default **dark**; circuit/probs/bloch themed; SVG `data-theme` |
Examples: `examples/quantum-bell/`, `examples/quantum-entanglement/`. Design: `doc/design/ext-quantum.md` · Q7: `doc/design/ext-quantum-q7.md` · Q8: `doc/design/ext-quantum-viz-style.md`.
## Formula + plot (math)
```markdown
---
import:
math: lib/math.mq.md
---
# main
`f` =
$$
x^2 - 2
$$
*_svg = > plot formula=`f` var=x min=-3 max=3*
```
Empty RHS assignment + following `$$…$$` binds a formula value. Narrative-only `$$` without binding is display, not assignment.
## Foreign (Python example)
```markdown
---
import:
foreign: lib/foreign.mq.md
---
# main
`hi` =
```python
print("hello-from-python")
```
```
Lines starting with `` ` `` can be code (binding). Keep a blank line before/after fences per comment rules.
## Function-end details
| Form | Effect |
|------|--------|
| Lone `---` or `***` (≥3 same chars) at function body top level | End function; no return value |
| `****` or empty bold | Return `None` and end body |
| `**expr**` | Return `expr`; does **not** by itself cut off later sibling statements — still use HR or shallower heading |
File-leading paired `---` is frontmatter only; body `---` is not frontmatter.
## Call arguments
- Named: `> greet who=World`
- Positional: `> greet World`
- Spaces in values: allowed in named forms as in docs (`who=marqdo user`)
- Inline call in statement: `` *`n` = > len value=`s`* ``
See `doc/design/call-arguments.md`.
## Identifiers
- Variables: `` `name` ``
- Comparisons: `==` `>` `<` `>=` `<=`
- Do not use keyword tokens as names
## Design docs (repo)
| Doc | Topic |
|-----|--------|
| `doc/design/markdown-mapping.md` | Syntax constitution |
| `doc/design/objects.md` | `#` objects / `##` methods |
| `doc/design/keywords.md` | Builtins / keywords |
| `doc/design/return-hr-and-code-surface.md` | Function end / surfaces |
| `doc/design/stdlib-i18n.md` | EN/ZH lib files |
| `doc/design/stdlib-modules.md` | L1 modules including plugin |
| `doc/design/ext-abi.md` | Native C ABI v1 |
| `doc/design/ext-llm.md` | `ext/llm` |
| `doc/design/ext-agent.md` | `ext/agent` agent **framework** (layout shipped; LLM orchestration roadmap) |
| `doc/design/ext-cli.md` | `marqdo ext list/add/remove` |
| `doc/design/ext-web.md` | `ext/web` dynamic sites (author API) |
| `doc/design/web-net-capabilities.md` | ext/web capability matrix (W0–W7 + P3) |
| `doc/design/ext-quantum.md` | `ext/quantum` circuits |
| `doc/design/ext-quantum-q7.md` | Q7 density linear algebra + advanced SVG |
| `doc/design/ext-quantum-viz-style.md` | Q8 themed SVG (`dark`/`light`/`bw`; circuit/probs/bloch) |
| `doc/design/view-debug.md` | view / debug hosts |
Use [the recursive Markdown web example](../../examples/web-layout-handbook/index.mq.md) and [the quantum workflow](../../examples/quantum-entanglement/index.mq.md) for domain development. Their real source is the manual. [Classic migration context](migration-classic.md) remains for explicitly historical syntax; new programs use readable occlusion and access(collection, key). Do not copy a second fenced program from this discovery note.