9.0 KiB
9.0 KiB
Maintainer Notes
This document captures the project decisions that are easy to lose between implementation rounds. Treat it as the quick orientation page for future workers before changing Mercury Toolbox internals.
Project Direction
- Mercury Toolbox is not trying to replace every Unix utility. It adds a high-signal layer for local inspection, structure extraction, diagnostics, and AI/model handoff.
- Default text output should stay compact and human-scannable. Use structured output only when the next consumer benefits from it.
- The priority order for JSON-family and code-reading work is capability first, then speed, then memory/CPU footprint, then binary size. All four matter, but do not shrink a tool by removing useful behavior.
- Windows PowerShell UX is a first-class target. Prefer stdin, path streams, clear examples, and failure messages that tell the user what to try next.
Code Shape Family
codeindexis the shared AST/indexing engine.outline,codeshape,defsnip, andrefsshould reuse it instead of growing separate parsers.- Tree-sitter support exists to make language coverage better, not just faster. When improving outline-like behavior, prefer AST-backed extraction over regex-only expansion.
- If a language has weak output, add tests that demonstrate the missing constructs before tuning presentation. Java feedback was the first strong signal, but the goal is broad polyglot usefulness.
- Keep
outlineshort and readable by default. Usecodeshape,defsnip,refs,snip, andctxpackfor deeper or wider context.
JSON-Family Tools
common::formats::{toon, ison, zon, tonl}is the shared home for compact JSON-family logic. Binaries should be thin CLIs around shared Rust implementations.- Do not introduce Node, npm, TypeScript, Python, or Go runtime dependencies for these formats. Official repositories/specs/fixtures are comparison sources only.
- Every JSON-capable Mercury tool should route structured output through the shared renderer and support
--json,--toon, and--format text|json|toon. --jsonstays for compatibility.--toonis the AI-friendly shortcut.MERCURY_OUTPUT=json|toon|textis the session-wide default when no explicit format flag is provided.- The standalone
toonbinary remains useful for external JSON producers. For Mercury tools, prefer native--toon; for path streams, prefer simple pipelines such asfd ... | fileprobe --input-format lines --toon. toonauto-detects JSON input and emits TOON by default. Avoid documenting long forms like--json | toon --from json --to toonunless a specific conversion direction truly needs to be explicit.- Shared TOON decoding must preserve quoted literal keys, reject strict dotted-path conflicts, and round-trip what the shared encoder emits, including root arrays and root primitives.
tonlis more than a converter. Preserve query, validate, index, streaming query, and ETL behavior when refactoring.
Jade Is Mandatory
- Jade has no optional safety tier. Miri, fuzzing, sanitizers, no-panic scanning, and Loom are part of the main gate.
scripts/check-jade.ps1is the authoritative full gate. If a worker only runs a focused loop such asjust fuzzorjust loom, they have not run Jade.- Exemptions are allowed only through explicit
-Exempt*flags with non-empty reviewed reasons. Missing tools, awkward platforms, or slow checks are failures by default. - The independent
fuzz/workspace is intentional. Keep itsCargo.lockcommitted, keepfuzz/.gitignorepreventing corpus/artifact leaks, and keep root Jade auditing fuzz dependencies withudeps, locked metadata, andcargo deny. - The no-panic gate scans JSON-family production paths for
panic!,.unwrap(), and.expect(). Prefer fallible propagation. If a panic surface is truly unavoidable, use the strict adjacent comment form// jade: allow-panic because: <reason>. - Sanitizer setup is platform-sensitive. Windows needs ASan runtime discovery; non-Windows must not fail because a Windows DLL is absent.
- Loom tests should model production-like concurrency patterns, not unrelated toy examples. Keep the runtime capture model tied to join/publish behavior.
Documentation And Generated Assets
README.mdis the user-facing map.docs/jade-discipline.mdis the safety/verification contract. This file is maintainer orientation.- Generated AI prompt and skill assets must be changed through
scripts/generate-ai-prompt.ps1andscripts/generate-ai-skill.ps1; do not hand-edit generated output unless the generator changes in the same patch. - For docs, script, justfile, template, or generated-check hygiene,
just periphery-checkis the focused local proof. It is not a substitute forjust jadewhen Rust behavior or release readiness is in scope. - For docs-only maintenance, prefer a small proof ladder:
just --summary,just ai-checkwhen generated asset references are touched, andjust periphery-checkbefore handoff if PowerShell scripts, just recipes, or generated-check expectations are mentioned. - When a pass receives a numeric candidate quota, record the reviewed count and the skipped classes in
.codex-progress\quality-security-backlog.md; do not create low-value edits just to hit the number. - Help examples should teach the happy path and the AI-friendly path. Favor examples like
--toonor--json | toononly when they shorten the real user workflow. - If a tool accepts path input, keep PowerShell wildcard behavior in mind. Native glob expansion is not guaranteed, so either support globs deliberately or give
fd ... | tool --input-format linesguidance. - The vendored
tree-sittercrate is intentionally pinned through[patch.crates-io]; followvendor/tree-sitter/README.mdbefore updating or re-vendoring it.
CI And Runner Handoff
- The hosted Gitea CI lane uses the dedicated
windowsrunner label, records a toolchain snapshot, runsjust workspace-check, then performs explicitcargo nextest, strict Clippy, andjust ecosystem-faststeps. - Treat the toolchain snapshot as runner drift evidence. If
cargo nextest --version,cargo llvm-cov --version,just --version, orpwsh --versionis missing or surprising, fix the runner/tooling before changing repository gates. - The release workflow is tag-driven and expects the tag to match
[workspace.package].version; do not document a release as published until the package exists and the Gitea release upload has actually succeeded. scripts\setup-gitea-runner.ps1creates local runner state and.runnercredentials on the host. Treat those files and anyGITEA_TOKEN/GITEA_API_TOKENvalues as secret material that must stay out of docs, screenshots, package archives, and commits.- Before and after authenticated Gitea work, use secret-residue checks such as
git remote -v,.git\config, and targetedrgscans forAuthorization,GITEA_TOKEN, and token-bearing URLs. Report only the fact that the check passed, not token values. - When CI behavior changes, update the README workflow overview, this maintainer note, and the daily backlog together so future workers know whether a failing step is expected duplication, runner drift, or a new regression.
Moving Or Relocating The Repo
- Scripts should be path-independent and derive the workspace root from
$PSScriptRootwhere possible. - Do not hardcode local worktree paths in documentation or scripts.
- This repository may be moved between drives. After moving a Git worktree layout manually, verify both the main worktree and linked worktrees with
git status --short.
Gitea HTTPS Credential Fallback
- Symptom: Git for Windows can show a
git-remote-https.exeapplication error while a push, fetch, or ls-remote operation is resolving HTTPS credentials. In the observed failure, direct authenticated API checks still worked, and a one-shot Git command with a Basic auth header worked, so the failure belonged to the local Git HTTPS credential path rather than repository contents. - First repair the machine when possible: update Git for Windows, update Git Credential Manager, and check whether the host certificate chain is trusted by the active Git TLS backend. Those changes belong on the affected machine, not in this repository.
- Repo-safe fallback: use
scripts\invoke-gitea-git.ps1for Gitea Git commands that need authentication. It setscredential.helper=for that invocation, useshttp.sslBackend=openssl, injects anhttp.extraHeaderBasic auth header, disables terminal prompts, clears Git curl tracing while the header is in scope, and filters libcurl trace lines from captured Git stderr. - Pass a token with
-ApiTokenor setGITEA_API_TOKEN/GITEA_TOKENonly in the current shell. The helper deliberately does not fall back to Git Credential Manager; if no token is provided, it fails closed instead of re-entering the crash path. - Keep TLS verification on by default. Use
-InsecureSkipTlsVerifyonly as a temporary test-host workaround, then remove it once the certificate chain is fixed. - After any emergency authenticated push, verify that
git remote -vand.git\configcontain no token, noAuthorizationheader, and no credential-bearing URL.