Release 2.7.0: executable handbooks and native user-site workflows
This commit is contained in:
1 parent
aa0c4d0f55
commit
d9aef957f7
562 files changed
+21064
-20387
No files matched your search
@@ -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.
|
||||
@@ -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*.
|
||||
@@ -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`))*.
|
||||
@@ -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*.
|
||||
@@ -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))*。
|
||||
@@ -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.
|
||||
@@ -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`))*.
|
||||
Reference in new issue
Block a user