lean-pkg 0.25.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lean_pkg/__init__.py +3 -0
- lean_pkg/adapters/__init__.py +148 -0
- lean_pkg/adapters/github.py +65 -0
- lean_pkg/adapters/leansearch.py +68 -0
- lean_pkg/adapters/loogle.py +45 -0
- lean_pkg/adapters/palomar.py +170 -0
- lean_pkg/adapters/reservoir.py +127 -0
- lean_pkg/anchor.py +678 -0
- lean_pkg/audit.py +716 -0
- lean_pkg/binding_file.py +446 -0
- lean_pkg/blueprint.py +213 -0
- lean_pkg/build_scope.py +282 -0
- lean_pkg/ci_github.py +917 -0
- lean_pkg/claim_axioms.py +421 -0
- lean_pkg/claims.py +1155 -0
- lean_pkg/claims_mark.py +197 -0
- lean_pkg/cli.py +5208 -0
- lean_pkg/cli_parser.py +768 -0
- lean_pkg/command_tree.py +615 -0
- lean_pkg/comparator_config.py +990 -0
- lean_pkg/comparator_contracts.py +382 -0
- lean_pkg/comparator_receipt.py +2854 -0
- lean_pkg/comparator_stage.py +623 -0
- lean_pkg/comparator_types.py +830 -0
- lean_pkg/container.py +172 -0
- lean_pkg/core.py +1570 -0
- lean_pkg/coverage.py +1278 -0
- lean_pkg/data/stacks/lts-2026.10.yaml +73 -0
- lean_pkg/data/toolchain-advisories.yaml +77 -0
- lean_pkg/data/upgrade-breaking.yaml +20 -0
- lean_pkg/data/verify-workflow-pins.yaml +14 -0
- lean_pkg/deps_closure.py +512 -0
- lean_pkg/deps_fill.py +445 -0
- lean_pkg/dup_constants.py +448 -0
- lean_pkg/exercise.py +828 -0
- lean_pkg/exercise_forbid.py +288 -0
- lean_pkg/export_paths.py +77 -0
- lean_pkg/extract.py +1172 -0
- lean_pkg/extract_decls.py +501 -0
- lean_pkg/extract_ledger.py +1408 -0
- lean_pkg/extract_summary.py +132 -0
- lean_pkg/extract_types.py +502 -0
- lean_pkg/extract_write.py +138 -0
- lean_pkg/formalization.py +1078 -0
- lean_pkg/formalization_kept.py +182 -0
- lean_pkg/fresh_repo.py +709 -0
- lean_pkg/gate.py +2141 -0
- lean_pkg/headline.py +211 -0
- lean_pkg/help_topics.py +442 -0
- lean_pkg/holes.py +289 -0
- lean_pkg/host_routes.py +376 -0
- lean_pkg/hypotheses.py +788 -0
- lean_pkg/index.py +1749 -0
- lean_pkg/json_stdout.py +48 -0
- lean_pkg/lake_hygiene.py +289 -0
- lean_pkg/lean_diag.py +280 -0
- lean_pkg/lean_scan.py +1300 -0
- lean_pkg/ledger.py +582 -0
- lean_pkg/next_step.py +510 -0
- lean_pkg/page.py +1831 -0
- lean_pkg/page_html.py +153 -0
- lean_pkg/palomar.py +316 -0
- lean_pkg/palomar_check.py +1027 -0
- lean_pkg/port_modules.py +677 -0
- lean_pkg/prior_art.py +286 -0
- lean_pkg/producer.py +212 -0
- lean_pkg/producer_skew.py +208 -0
- lean_pkg/public_safety.py +1487 -0
- lean_pkg/publish.py +402 -0
- lean_pkg/rebase.py +984 -0
- lean_pkg/receipt.py +2385 -0
- lean_pkg/receipt_check.py +1064 -0
- lean_pkg/receipt_ci.py +660 -0
- lean_pkg/receipt_systemd.py +890 -0
- lean_pkg/recommended.py +232 -0
- lean_pkg/report.py +727 -0
- lean_pkg/reservoir.py +203 -0
- lean_pkg/scaffold.py +588 -0
- lean_pkg/schemas/formalization-0.4.schema.json +344 -0
- lean_pkg/schemas/formalization-0.4.schema.source.txt +15 -0
- lean_pkg/scripts/ClaimAxioms.lean +47 -0
- lean_pkg/scripts/ContractsOnly.lean +300 -0
- lean_pkg/scripts/DupConstants.lean +149 -0
- lean_pkg/scripts/HypProbe.lean +257 -0
- lean_pkg/scripts/comparator-check.sh +396 -0
- lean_pkg/scripts/verify-comparator.sh +135 -0
- lean_pkg/seal_bundle.py +647 -0
- lean_pkg/search.py +865 -0
- lean_pkg/site_profiles/easley.yaml +10 -0
- lean_pkg/site_profiles/github-actions.yaml +12 -0
- lean_pkg/sites.py +225 -0
- lean_pkg/stacks.py +373 -0
- lean_pkg/statements_module.py +217 -0
- lean_pkg/templates/Apache-2.0.txt +202 -0
- lean_pkg/toolchain_advisories.py +225 -0
- lean_pkg/upgrade.py +706 -0
- lean_pkg/verify.py +495 -0
- lean_pkg-0.25.0.dist-info/METADATA +93 -0
- lean_pkg-0.25.0.dist-info/RECORD +103 -0
- lean_pkg-0.25.0.dist-info/WHEEL +5 -0
- lean_pkg-0.25.0.dist-info/entry_points.txt +5 -0
- lean_pkg-0.25.0.dist-info/licenses/LICENSE +202 -0
- lean_pkg-0.25.0.dist-info/top_level.txt +1 -0
lean_pkg/cli_parser.py
ADDED
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
# lean-pkg -- the argument parser
|
|
2
|
+
"""The `lean-pkg` argparse tree: build_parser() builds it exactly as main() parses it, and _Parser (the
|
|
3
|
+
UsageError JSON contract, the old-spelling rewrite of lean_pkg.command_tree) with the helpers that copy
|
|
4
|
+
options between forms of a command (_hidden_copies, _defaults_except).
|
|
5
|
+
|
|
6
|
+
Moved verbatim out of cli.py's main() (#317, stage 3); main() calls build_parser(), and cli.py re-exports
|
|
7
|
+
the names defined here for at least one release. The tree binds the command handlers, most of which are
|
|
8
|
+
cli.py's, so build_parser imports them from cli.py when called (cli.py imports this module); gate.py and
|
|
9
|
+
audit.py are imported at the top level.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
from .core import (
|
|
18
|
+
BULK_FIELDS, DEFAULT_REGISTRY_NAME, DEFAULT_TTL_HOURS, EVENTS_NAME, EVIDENCE_EVENTS, LEASE_CONTACT_MAX,
|
|
19
|
+
MAX_TTL_HOURS, print_json, REGISTER_STATUSES, REGISTRY_ENV, RETRACT_EVENT, SNAPSHOT_ENV, STATUSES, TRACKS,
|
|
20
|
+
UPSTREAM_TARGETS, VISIBILITIES,
|
|
21
|
+
)
|
|
22
|
+
from .audit import cmd_audit, cmd_validate, DEFAULT_TOOLCHAIN_FLOOR, TOOLCHAIN_FLOOR_ENV
|
|
23
|
+
from .gate import cmd_gate
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _Parser(argparse.ArgumentParser):
|
|
27
|
+
"""argparse with the UsageError JSON contract (#21.7): when --json is on the command line, an
|
|
28
|
+
argparse-level error (unknown flag, bad choice, missing argument) also prints
|
|
29
|
+
{ok: false, error, usage: true} on stdout; the stderr usage text and exit 2 are unchanged.
|
|
30
|
+
Subparsers inherit the class."""
|
|
31
|
+
json_requested = False
|
|
32
|
+
alias_root = False # the root parser: rewrite old spellings to canonical ones first (command_tree)
|
|
33
|
+
alias_hits: list = []
|
|
34
|
+
|
|
35
|
+
def parse_known_args(self, args=None, namespace=None):
|
|
36
|
+
if self.alias_root:
|
|
37
|
+
from . import command_tree
|
|
38
|
+
args, self.alias_hits = command_tree.rewrite_argv(list(sys.argv[1:] if args is None else args))
|
|
39
|
+
self.command_argv = list(args) # the canonical argv (receipt comparator's resume command repeats it)
|
|
40
|
+
return super().parse_known_args(args, namespace)
|
|
41
|
+
|
|
42
|
+
def format_help(self):
|
|
43
|
+
if self.alias_root: # the root --help: commands in tiers (command_tree.root_help)
|
|
44
|
+
from . import command_tree
|
|
45
|
+
return command_tree.root_help(self)
|
|
46
|
+
return super().format_help()
|
|
47
|
+
|
|
48
|
+
def error(self, message):
|
|
49
|
+
if _Parser.json_requested:
|
|
50
|
+
print_json({"ok": False, "error": f"{self.prog}: {message}", "usage": True})
|
|
51
|
+
super().error(message)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _hidden_copies(target, *sources) -> None:
|
|
55
|
+
"""Give target every option of sources it lacks, hidden from its help (help=SUPPRESS). A form split out
|
|
56
|
+
of one parser (`comparator config`, `formalization anchor`) then parses any old argv exactly as before:
|
|
57
|
+
a flag of another form still reaches the command, which refuses it with the message naming the right
|
|
58
|
+
form, as it always did."""
|
|
59
|
+
import copy
|
|
60
|
+
for src in sources:
|
|
61
|
+
for a in src._actions:
|
|
62
|
+
if not a.option_strings or isinstance(a, argparse._HelpAction):
|
|
63
|
+
continue
|
|
64
|
+
if any(o in target._option_string_actions for o in a.option_strings) \
|
|
65
|
+
or any(b.dest == a.dest for b in target._actions):
|
|
66
|
+
continue
|
|
67
|
+
b = copy.copy(a)
|
|
68
|
+
b.option_strings = list(a.option_strings)
|
|
69
|
+
b.help = argparse.SUPPRESS
|
|
70
|
+
target._add_action(b)
|
|
71
|
+
target.set_defaults(**{k: v for k, v in _defaults_except(src, target).items()})
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _defaults_except(source, target) -> dict:
|
|
75
|
+
"""source's argument defaults for every dest target does not define: a form split out of a command parses
|
|
76
|
+
to the namespace that command produced (`repo move` = `update --path`, `comparator config` = the old
|
|
77
|
+
keyword form)."""
|
|
78
|
+
own = {a.dest for a in target._actions}
|
|
79
|
+
out = {}
|
|
80
|
+
for a in source._actions:
|
|
81
|
+
if a.dest in own or a.dest in out or a.default is argparse.SUPPRESS or isinstance(a, argparse._HelpAction):
|
|
82
|
+
continue
|
|
83
|
+
out[a.dest] = a.default
|
|
84
|
+
return out
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def build_parser():
|
|
88
|
+
"""The whole `lean-pkg` argparse tree, as main() parses it: every command and alias, the commit-flag
|
|
89
|
+
split of the help (show_commit_flags_on_writes), then the command tree's flag aliases, tiers and root
|
|
90
|
+
help (lean_pkg.command_tree), in that order. Built fresh on each call: help texts read the environment
|
|
91
|
+
when the parser is built."""
|
|
92
|
+
from .cli import ( # the command handlers bound below are cli.py's, and cli.py imports this module
|
|
93
|
+
add_commit_flags, cmd_board, cmd_claim, cmd_comparator, cmd_doctor, cmd_help, cmd_init, cmd_leases,
|
|
94
|
+
cmd_list, cmd_llms, cmd_migrate, cmd_record, cmd_register, cmd_release, cmd_renew, cmd_status,
|
|
95
|
+
cmd_update, cmd_wiki, COMMIT_ENV, CONFIG_CMD, HOST_CHECK, nonneg_hours, package_fields_help,
|
|
96
|
+
PAPER_STATUSES, PUSH_ENV, show_commit_flags_on_writes,
|
|
97
|
+
)
|
|
98
|
+
ap = _Parser(
|
|
99
|
+
prog="lean-pkg",
|
|
100
|
+
description="lean-pkg: a registry and trust gate for Lean 4 formalization packages: receipts, the gate, "
|
|
101
|
+
"the verification page, publication.",
|
|
102
|
+
epilog="New here? `lean-pkg help start`: the five verbs (new, verify, status, page, publish) and the two "
|
|
103
|
+
"product tracks. `lean-pkg <command> -h`: one command's flags. Old spellings (claim, init, promote, "
|
|
104
|
+
"comparator-receipt, ...) keep working: `lean-pkg help aliases`.")
|
|
105
|
+
ap.add_argument("--registry", default=None,
|
|
106
|
+
help=f"registry yaml (default: ${REGISTRY_ENV}, else "
|
|
107
|
+
f"~/.lean-pkg/registry, else ./{DEFAULT_REGISTRY_NAME})")
|
|
108
|
+
ap.add_argument("--events", default=None,
|
|
109
|
+
help=f"event log jsonl (default: {EVENTS_NAME} next to the "
|
|
110
|
+
f"registry)")
|
|
111
|
+
ap.add_argument("--json", dest="json_out", action="store_true",
|
|
112
|
+
help="machine-readable JSON on stdout (exit codes unchanged)")
|
|
113
|
+
ap.add_argument("--commit", action="store_true",
|
|
114
|
+
help=f"write commands: pull --ff-only first, then commit the registry and event log "
|
|
115
|
+
f"together (default: ${COMMIT_ENV}=1)")
|
|
116
|
+
ap.add_argument("--push", action="store_true",
|
|
117
|
+
help=f"--commit, then push to origin (default: ${PUSH_ENV}=1)")
|
|
118
|
+
ap.add_argument("--no-commit", action="store_true",
|
|
119
|
+
help=f"never commit or push, overriding ${COMMIT_ENV} and ${PUSH_ENV}")
|
|
120
|
+
ap.add_argument("--registry-snapshot", metavar="COMMIT", default=None,
|
|
121
|
+
help=f"read-only: read the registry file (and its event log) as of COMMIT of the git "
|
|
122
|
+
f"repository holding it (env ${SNAPSHOT_ENV}); every write exits 2; --json adds "
|
|
123
|
+
f"registry_snapshot")
|
|
124
|
+
from . import __version__
|
|
125
|
+
ap.add_argument("--version", dest="show_version", action="store_true",
|
|
126
|
+
help=f"print lean-pkg {__version__} and the build that runs: short commit (+dirty) and "
|
|
127
|
+
f"checkout of an editable install, else the installed package directory; local "
|
|
128
|
+
f"only (no fetch); with --json: {{ok, version, commit, dirty, install, path}}")
|
|
129
|
+
sub = ap.add_subparsers(dest="cmd", metavar="COMMAND")
|
|
130
|
+
|
|
131
|
+
def add_json(s):
|
|
132
|
+
# Repeat --json on every subparser so BOTH `lean-pkg --json list` and
|
|
133
|
+
# `lean-pkg list --json` work. SUPPRESS keeps the global value when
|
|
134
|
+
# the flag is absent after the subcommand.
|
|
135
|
+
s.add_argument("--json", dest="json_out", action="store_true",
|
|
136
|
+
default=argparse.SUPPRESS,
|
|
137
|
+
help="machine-readable JSON on stdout")
|
|
138
|
+
add_commit_flags(s)
|
|
139
|
+
|
|
140
|
+
only_help = ("filters PACKAGES, never fields: only these packages (comma-separated names), each with its "
|
|
141
|
+
"full record (cached claims included: --no-claims or --fields shrink it); the same table or --json shape, restricted; an unknown "
|
|
142
|
+
"name exits 1")
|
|
143
|
+
list_fields_help = ("trims FIELDS, never packages: each package record cut to these keys, comma-separated; "
|
|
144
|
+
"the same validation, dotted paths and aliases as `status --fields` (gate.receipt, "
|
|
145
|
+
"lease.agent, lease.expires_at; the table columns as aliases: pin, vis, reaudit, expires; an "
|
|
146
|
+
"unknown field exits 2 listing the valid keys); --json keeps the dump's shape plus a "
|
|
147
|
+
"`fields` list, text prints the selected keys of each package as YAML")
|
|
148
|
+
no_claims_help = ("drop the bulk cached arrays (" + ", ".join(BULK_FIELDS) + "; the [bulk] keys below) from "
|
|
149
|
+
"each package record; every other key unchanged; --json adds an `omitted` list")
|
|
150
|
+
# 1.0 command tree (docs/design/1.0-command-tree.md): coordination and maintenance commands live under
|
|
151
|
+
# nouns; each keeps its pre-1.0 `cmd` (set_defaults) so every predicate below is unchanged, and its old
|
|
152
|
+
# top-level spelling is a permanent alias (command_tree.COMMAND_ALIASES).
|
|
153
|
+
s = sub.add_parser("registry", help="the registry file itself: init, migrate, validate, audit, board, recommend, "
|
|
154
|
+
"wiki "
|
|
155
|
+
"(the old top-level spellings keep working)")
|
|
156
|
+
registry_sub = s.add_subparsers(dest="registry_cmd", required=True,
|
|
157
|
+
metavar="{board,init,migrate,validate,audit,recommend,wiki}")
|
|
158
|
+
s = registry_sub.add_parser("board", help="curses TUI on a tty; static table otherwise",
|
|
159
|
+
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=package_fields_help())
|
|
160
|
+
s.add_argument("--only", metavar="NAME[,NAME]", default=None,
|
|
161
|
+
help=only_help + "; never opens the TUI")
|
|
162
|
+
s.add_argument("--fields", metavar="a,b,c", default=None, help=list_fields_help + "; never opens the TUI")
|
|
163
|
+
s.add_argument("--no-claims", dest="no_claims", action="store_true",
|
|
164
|
+
help=no_claims_help + "; never opens the TUI")
|
|
165
|
+
add_json(s)
|
|
166
|
+
s.set_defaults(fn=cmd_board, cmd="board")
|
|
167
|
+
s = sub.add_parser("list", help="static table, pipe-friendly",
|
|
168
|
+
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=package_fields_help())
|
|
169
|
+
s.add_argument("--only", metavar="NAME[,NAME]", default=None, help=only_help)
|
|
170
|
+
s.add_argument("--fields", metavar="a,b,c", default=None, help=list_fields_help)
|
|
171
|
+
s.add_argument("--no-claims", dest="no_claims", action="store_true", help=no_claims_help)
|
|
172
|
+
add_json(s)
|
|
173
|
+
s.set_defaults(fn=cmd_list)
|
|
174
|
+
|
|
175
|
+
s = sub.add_parser("status", help="full record + last 5 history entries + scope (gated commit, privacy, "
|
|
176
|
+
"the exact comparator-covered declarations)",
|
|
177
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
178
|
+
epilog=package_fields_help())
|
|
179
|
+
s.add_argument("name")
|
|
180
|
+
s.add_argument("--fields", metavar="a,b,c", default=None,
|
|
181
|
+
help="trims FIELDS: only these keys of the package record, comma-separated; dotted paths "
|
|
182
|
+
"reach into mappings (gate.receipt, lease.agent, the derived lease.expires_at); aliases "
|
|
183
|
+
"pin (=mathlib_pin), vis (=visibility), reaudit (=reaudit_after), expires and lease.expires "
|
|
184
|
+
"(=lease.expires_at), lease.claimed (=lease.claimed_at), output keeps the record key; "
|
|
185
|
+
"--json keeps the nesting, text prints YAML; an unknown field exits 2 listing the valid keys")
|
|
186
|
+
s.add_argument("--no-claims", dest="no_claims", action="store_true", help=no_claims_help)
|
|
187
|
+
add_json(s)
|
|
188
|
+
s.set_defaults(fn=cmd_status)
|
|
189
|
+
|
|
190
|
+
from . import scaffold as scaffold_mod # `new`: placed beside `init`, the other way to start
|
|
191
|
+
scaffold_mod.add_parsers(sub, add_json)
|
|
192
|
+
|
|
193
|
+
s = registry_sub.add_parser("init", help="bootstrap an empty registry and its event log")
|
|
194
|
+
s.add_argument("--force", action="store_true",
|
|
195
|
+
help="re-create only if the existing registry is empty")
|
|
196
|
+
add_json(s)
|
|
197
|
+
s.set_defaults(fn=cmd_init, cmd="init")
|
|
198
|
+
|
|
199
|
+
s = registry_sub.add_parser("migrate", help="upgrade the registry schema in place (additive; idempotent)")
|
|
200
|
+
s.add_argument("--dry-run", action="store_true", help="print the changes; write nothing")
|
|
201
|
+
add_json(s)
|
|
202
|
+
s.set_defaults(fn=cmd_migrate, cmd="migrate")
|
|
203
|
+
|
|
204
|
+
s = sub.add_parser("record", help="record a publication evidence event (consent, Palomar, DOI, Reservoir, Mathlib PR)")
|
|
205
|
+
s.add_argument("name")
|
|
206
|
+
s.add_argument("event", help="one of: " + ", ".join(EVIDENCE_EVENTS) + f", or {RETRACT_EVENT} "
|
|
207
|
+
"(--field event=E --field ts=T --reason TEXT: mark an evidence entry retracted)")
|
|
208
|
+
s.add_argument("--field", action="append", metavar="KEY=VALUE",
|
|
209
|
+
help="event field (repeatable); required keys per event are listed by `lean-pkg llms`")
|
|
210
|
+
s.add_argument("--reason", default="", help="free-text reason stored with the event")
|
|
211
|
+
s.add_argument("--doi-track", dest="track", choices=TRACKS, default=None,
|
|
212
|
+
help="doi-minted only: the DOI track for this event (default: the record's track, else palomar); "
|
|
213
|
+
"doi-only skips rule doi-in-palomar for a public package")
|
|
214
|
+
s.add_argument("--agent", default=None,
|
|
215
|
+
help="the agent acting (recorded as the event's actor); another agent's live lease then refuses")
|
|
216
|
+
add_json(s)
|
|
217
|
+
s.set_defaults(fn=cmd_record)
|
|
218
|
+
|
|
219
|
+
s = sub.add_parser("register", help="the ONLY write path for new packages: "
|
|
220
|
+
"validated, deduping, auto-detecting")
|
|
221
|
+
s.add_argument("name")
|
|
222
|
+
s.add_argument("--url", dest="repo", metavar="URL", default=None,
|
|
223
|
+
help="git URL (or local bare path); required unless --like gives it")
|
|
224
|
+
s.add_argument("--path", required=True,
|
|
225
|
+
help="local checkout path, $HOME-relative")
|
|
226
|
+
s.add_argument("--like", default=None, metavar="OTHER",
|
|
227
|
+
help="a sibling of registered package OTHER: copy its repo, owner-project, upstream-target "
|
|
228
|
+
"and automation (flags given here win; visibility is never copied, default private), "
|
|
229
|
+
"and report whether the toolchain and Mathlib pin match OTHER's")
|
|
230
|
+
s.add_argument("--owner-project", default=None)
|
|
231
|
+
s.add_argument("--license-spdx", dest="license_spdx", metavar="SPDX", default=None,
|
|
232
|
+
help="the package's license, an SPDX identifier or expression (Apache-2.0, MIT OR Apache-2.0); "
|
|
233
|
+
"the page, the publish checklist and formalization.yaml read it (later: update "
|
|
234
|
+
"--license-spdx)")
|
|
235
|
+
s.add_argument("--visibility", choices=VISIBILITIES, default="private")
|
|
236
|
+
s.add_argument("--status", choices=REGISTER_STATUSES, default="active",
|
|
237
|
+
help="public only with --visibility public and --reason (an already-public repo)")
|
|
238
|
+
s.add_argument("--upstream-target", choices=UPSTREAM_TARGETS, default=None, help="default none")
|
|
239
|
+
s.add_argument("--automation", default=None)
|
|
240
|
+
s.add_argument("--notes", default="")
|
|
241
|
+
s.add_argument("--reason", default="", help="required with --status public")
|
|
242
|
+
s.add_argument("--workspace", default=None,
|
|
243
|
+
help="metadata only; does NOT claim")
|
|
244
|
+
s.add_argument("--agent", default=None, help="metadata only; does NOT claim")
|
|
245
|
+
s.add_argument("--ttl", type=int, default=None,
|
|
246
|
+
help="accepted and ignored (register never claims; claim separately with "
|
|
247
|
+
"`lean-pkg lease claim NAME --ttl H`)")
|
|
248
|
+
s.add_argument("--dry-run", action="store_true",
|
|
249
|
+
help="print the would-be entry as YAML without writing")
|
|
250
|
+
add_json(s)
|
|
251
|
+
s.set_defaults(fn=cmd_register)
|
|
252
|
+
|
|
253
|
+
s = sub.add_parser("lease", help="leases for agents sharing a registry: claim, renew, release, list (the old "
|
|
254
|
+
"spellings claim, renew, release, leases keep working)")
|
|
255
|
+
lease_sub = s.add_subparsers(dest="lease_cmd", required=True, metavar="{claim,renew,release,list}")
|
|
256
|
+
s = lease_sub.add_parser("claim", help="CAS lease on a package (24h default TTL)")
|
|
257
|
+
s.add_argument("name")
|
|
258
|
+
s.add_argument("--workspace", required=True)
|
|
259
|
+
s.add_argument("--agent", required=True)
|
|
260
|
+
s.add_argument("--ttl", type=int, default=None, metavar="HOURS",
|
|
261
|
+
help=f"lease TTL, 1..{MAX_TTL_HOURS} (default: {DEFAULT_TTL_HOURS} for a new claim; a holder's "
|
|
262
|
+
f"re-claim keeps the lease's current ttl_hours; above {MAX_TTL_HOURS}: exit 2)")
|
|
263
|
+
s.add_argument("--reason", default="")
|
|
264
|
+
s.add_argument("--contact", default=None, metavar="TEXT",
|
|
265
|
+
help=f"address of the holding session (e.g. a session address such as alice-laptop/paper-1, "
|
|
266
|
+
f"or a channel such as @proof-team), stored in the lease and shown by leases/status; one line, at most "
|
|
267
|
+
f"{LEASE_CONTACT_MAX} characters; a holder's re-claim without it keeps the lease's")
|
|
268
|
+
s.add_argument("--force", action="store_true",
|
|
269
|
+
help="override a live lease; requires --reason")
|
|
270
|
+
add_json(s)
|
|
271
|
+
s.set_defaults(fn=cmd_claim, cmd="claim")
|
|
272
|
+
|
|
273
|
+
s = lease_sub.add_parser("release", help="release a lease (holder-only unless --force); exporting or adopting a "
|
|
274
|
+
"repository is `repo export` / `repo adopt`")
|
|
275
|
+
s.add_argument("name")
|
|
276
|
+
s.add_argument("--agent", default=None,
|
|
277
|
+
help="the holder; with --force, the acting agent recorded as released_by")
|
|
278
|
+
s.add_argument("--force", action="store_true", help="release another agent's lease; requires --reason")
|
|
279
|
+
s.add_argument("--reason", default="", help="free-text reason stored with the event")
|
|
280
|
+
add_json(s)
|
|
281
|
+
s.set_defaults(fn=cmd_release, cmd="release")
|
|
282
|
+
lease_release = s
|
|
283
|
+
|
|
284
|
+
s = lease_sub.add_parser("renew", help="restart your own live lease from now (holder-only; refuses once it "
|
|
285
|
+
"has lapsed: claim again)")
|
|
286
|
+
s.add_argument("name")
|
|
287
|
+
s.add_argument("--agent", required=True)
|
|
288
|
+
s.add_argument("--ttl", type=int, default=None, metavar="HOURS",
|
|
289
|
+
help=f"new TTL, 1..{MAX_TTL_HOURS} (default: the lease's current ttl_hours; above "
|
|
290
|
+
f"{MAX_TTL_HOURS}: exit 2)")
|
|
291
|
+
s.add_argument("--workspace", default=None, help="move the lease to this workspace")
|
|
292
|
+
s.add_argument("--reason", default="")
|
|
293
|
+
s.add_argument("--contact", default=None, metavar="TEXT",
|
|
294
|
+
help=f"set or replace the lease's contact (address of the holding session; one line, at most "
|
|
295
|
+
f"{LEASE_CONTACT_MAX} characters); without it the lease keeps its contact")
|
|
296
|
+
s.add_argument("--no-contact", action="store_true",
|
|
297
|
+
help="clear the lease's contact while renewing (not with --contact)")
|
|
298
|
+
add_json(s)
|
|
299
|
+
s.set_defaults(fn=cmd_renew, cmd="renew")
|
|
300
|
+
|
|
301
|
+
s = lease_sub.add_parser("list", help="held leases, soonest expiry first; read-only")
|
|
302
|
+
s.add_argument("--agent", default=None, help="only leases held by this agent")
|
|
303
|
+
s.add_argument("--expiring", type=nonneg_hours, default=None, metavar="HOURS",
|
|
304
|
+
help="only leases that lapse within HOURS (or have already lapsed)")
|
|
305
|
+
add_json(s)
|
|
306
|
+
s.set_defaults(fn=cmd_leases, cmd="leases")
|
|
307
|
+
|
|
308
|
+
s = sub.add_parser("update", help="set fields of an already-registered "
|
|
309
|
+
"package (register is for NEW ones)")
|
|
310
|
+
s.add_argument("name")
|
|
311
|
+
s.add_argument("--automation", help="AI-disclosure note; required by mathlib "
|
|
312
|
+
"when upstream_target is mathlib")
|
|
313
|
+
s.add_argument("--notes", metavar="TEXT",
|
|
314
|
+
help="set the notes; refused when notes exist unless --replace-notes (use --append-note)")
|
|
315
|
+
s.add_argument("--replace-notes", dest="replace_notes", action="store_true",
|
|
316
|
+
help="with --notes: replace non-empty notes (the old text stays in history as notes_from)")
|
|
317
|
+
s.add_argument("--upstream-target", dest="upstream_target",
|
|
318
|
+
choices=UPSTREAM_TARGETS)
|
|
319
|
+
s.add_argument("--doi-track", dest="track", choices=TRACKS, default=None,
|
|
320
|
+
help="the DOI track (needs --reason): doi-only lets a public package record doi-minted "
|
|
321
|
+
"without a palomar-* event; palomar (the default when absent) keeps rule doi-in-palomar")
|
|
322
|
+
g = s.add_mutually_exclusive_group()
|
|
323
|
+
g.add_argument("--accept-docs-descendants", dest="docs_descendants", action="store_const", const=True,
|
|
324
|
+
default=None,
|
|
325
|
+
help="deprecated (WARN; removed no earlier than 1.0.0): the registry route of the docs-only "
|
|
326
|
+
"opt-in, replaced by a committed lean-pkg-binding.yaml (--write-binding-file). "
|
|
327
|
+
"Opt in (needs --reason): a receipt bound to commit C is also accepted at a descendant "
|
|
328
|
+
"of C where no build input under the package directory changed (*.lean, lakefile.*, "
|
|
329
|
+
"lake-manifest.json, lean-toolchain, --build-inputs globs, the checker's files; never a "
|
|
330
|
+
"symlink/gitlink change, .gitattributes, .gitmodules, .lfsconfig, claims.yaml, nor those "
|
|
331
|
+
"attribute files in a directory above a subdirectory package); the gated commit "
|
|
332
|
+
"stays C (docs/receipts.md); --dry-run supported")
|
|
333
|
+
g.add_argument("--no-accept-docs-descendants", dest="docs_descendants", action="store_const", const=False,
|
|
334
|
+
help="opt out again (needs --reason): only the evidence-only rule applies")
|
|
335
|
+
s.add_argument("--build-inputs", dest="build_inputs", metavar="GLOB,GLOB",
|
|
336
|
+
help="extra build inputs for the docs-only rule (needs --reason): comma-separated "
|
|
337
|
+
"package-relative fnmatch globs (`*` crosses /; a glob without / also matches a "
|
|
338
|
+
"basename), replacing the recorded list; '' clears it")
|
|
339
|
+
s.add_argument("--write-binding-file", dest="write_binding_file", action="store_true",
|
|
340
|
+
help="write lean-pkg-binding.yaml (schema lean-pkg-binding/1) into the package directory from "
|
|
341
|
+
"the record's docs_descendants: true and build_inputs, the migration off the deprecated "
|
|
342
|
+
"registry route; writes nothing (exit 0) when the record does not opt in; an identical "
|
|
343
|
+
"file is a no-op, a different file or a symlink is refused (exit 1); never staged or "
|
|
344
|
+
"committed, and the registry is not written. On its own (no field, --status or --path); "
|
|
345
|
+
"--dry-run prints the file")
|
|
346
|
+
s.add_argument("--reaudit-after", dest="reaudit_after", metavar="ISO8601")
|
|
347
|
+
s.add_argument("--owner-project", dest="owner_project")
|
|
348
|
+
s.add_argument("--url", dest="repo", metavar="URL", help="remote URL (e.g. after publishing a private dep)")
|
|
349
|
+
s.add_argument("--license-spdx", dest="license_spdx", metavar="SPDX",
|
|
350
|
+
help="the package's license as an SPDX id or expression, e.g. 'MIT OR Apache-2.0' (what the index and Reservoir expect)")
|
|
351
|
+
s.add_argument("--formalization-yaml", dest="formalization_yaml", metavar="REL",
|
|
352
|
+
help="repository-relative path of the package's formalization.yaml")
|
|
353
|
+
s.add_argument("--headline-config", dest="headline_config", metavar="REL",
|
|
354
|
+
help="repository-relative path of the headline comparator configuration (the paper's main "
|
|
355
|
+
"results, fed to formalization.yaml status.main_results); '' clears it (then "
|
|
356
|
+
"comparator.headline.json applies when tracked)")
|
|
357
|
+
s.add_argument("--paper-arxiv", dest="paper_arxiv", metavar="ID",
|
|
358
|
+
help="arXiv id of the paper this package verifies (sets paper.arxiv; status defaults to "
|
|
359
|
+
"preprint)")
|
|
360
|
+
s.add_argument("--paper-status", dest="paper_status", choices=PAPER_STATUSES,
|
|
361
|
+
help="the verified paper's status; promote refuses while unpublished without an arXiv id")
|
|
362
|
+
s.add_argument("--source-paper-title", dest="source_paper_title", metavar="TITLE",
|
|
363
|
+
help="title of the formalized paper (source_paper.title; rendered into formalization.yaml "
|
|
364
|
+
"acknowledgements, #22.6)")
|
|
365
|
+
s.add_argument("--source-paper-author", dest="source_paper_author", action="append", metavar="NAME",
|
|
366
|
+
help="an author of the formalized paper (repeatable; the list replaces the recorded one). "
|
|
367
|
+
"Credited in acknowledgements, never in project.authors; no consent needed")
|
|
368
|
+
s.add_argument("--source-paper-arxiv", dest="source_paper_arxiv", metavar="ID",
|
|
369
|
+
help="arXiv id of the formalized paper (source_paper.arxiv)")
|
|
370
|
+
s.add_argument("--source-paper-doi", dest="source_paper_doi", metavar="DOI",
|
|
371
|
+
help="DOI of the formalized paper (source_paper.doi)")
|
|
372
|
+
s.add_argument("--ai-tool", dest="ai_tool", action="append", metavar="TOOL",
|
|
373
|
+
help="an AI tool used (repeatable; the list replaces the recorded one; ai_assistance.tools)")
|
|
374
|
+
s.add_argument("--ai-role", dest="ai_role", action="append", metavar="ROLE",
|
|
375
|
+
help="what the AI tools did (repeatable; replaces; ai_assistance.roles)")
|
|
376
|
+
s.add_argument("--append-note", dest="append_note", metavar="TEXT",
|
|
377
|
+
help="append a line `YYYY-MM-DD (AGENT): TEXT` (UTC date, --agent) to notes, keeping what is "
|
|
378
|
+
"there; --notes replaces instead")
|
|
379
|
+
s.add_argument("--namespace-note", dest="namespace_note", metavar="TEXT",
|
|
380
|
+
help="record why this package shares a Lean root namespace with another (namespace_notes); "
|
|
381
|
+
"audit's duplicate-namespace is info once both packages carry a note for it")
|
|
382
|
+
s.add_argument("--namespace", action="append", metavar="NS",
|
|
383
|
+
help="with --namespace-note: the namespace (repeatable); default every root namespace this "
|
|
384
|
+
"checkout shares with another registered package")
|
|
385
|
+
s.add_argument("--status", choices=STATUSES,
|
|
386
|
+
help="manual transitions only; verified-private is gate's "
|
|
387
|
+
"and public is promote's")
|
|
388
|
+
s.add_argument("--reason", default="", help="required for --status and --force")
|
|
389
|
+
s.add_argument("--redetect", action="store_true",
|
|
390
|
+
help="re-read lean_toolchain and mathlib_pin from the repo")
|
|
391
|
+
s.add_argument("--agent", default=None, help="lease holder, if one is live")
|
|
392
|
+
s.add_argument("--force", action="store_true",
|
|
393
|
+
help="override a live lease held by another agent; needs --reason")
|
|
394
|
+
s.add_argument("--path", default=None, metavar="HOME-RELATIVE",
|
|
395
|
+
help="relocate: move local_path to another checkout, keeping name, history "
|
|
396
|
+
"and claims (needs --reason; event relocated; commit-bound evidence "
|
|
397
|
+
"not bound to the new HEAD is cleared)")
|
|
398
|
+
g = s.add_mutually_exclusive_group()
|
|
399
|
+
g.add_argument("--withdraw-publication", dest="withdraw_publication", action="store_true",
|
|
400
|
+
help="the owner made a promoted (public) repository private again: record it (needs --reason; "
|
|
401
|
+
"refused while gh still reports it public). status public -> verified-private (active when "
|
|
402
|
+
"never gated), visibility private, publication_hold {reason, at, by}; promotion history "
|
|
403
|
+
"kept; promote refuses while held; gate/regate keep the hold; --dry-run supported")
|
|
404
|
+
g.add_argument("--release-publication-hold", dest="release_hold", action="store_true",
|
|
405
|
+
help="lift a publication hold (needs --reason); status and visibility unchanged; a later "
|
|
406
|
+
"public flip still goes through promote")
|
|
407
|
+
s.add_argument("--dry-run", dest="dry_run", action="store_true",
|
|
408
|
+
help="with --path, --withdraw-publication or --release-publication-hold: print the would-be "
|
|
409
|
+
"changes, write nothing; with --write-binding-file: print the file")
|
|
410
|
+
add_json(s)
|
|
411
|
+
s.set_defaults(fn=cmd_update)
|
|
412
|
+
update_parser = s
|
|
413
|
+
|
|
414
|
+
s = sub.add_parser("repo", help="the package's checkout: move (relocate the record), export (a new single-commit "
|
|
415
|
+
"public repository), adopt (an existing one)")
|
|
416
|
+
repo_sub = s.add_subparsers(dest="repo_cmd", required=True, metavar="{move,export,adopt}")
|
|
417
|
+
s = repo_sub.add_parser("move", help="relocate: point the record at another checkout, keeping name, history "
|
|
418
|
+
"and claims (the same as `update NAME --path PATH`)")
|
|
419
|
+
s.add_argument("name")
|
|
420
|
+
s.add_argument("path", metavar="HOME-RELATIVE",
|
|
421
|
+
help="the new checkout (event relocated; commit-bound evidence not bound to the new HEAD is "
|
|
422
|
+
"cleared)")
|
|
423
|
+
s.add_argument("--reason", default="", help="required")
|
|
424
|
+
s.add_argument("--agent", default=None, help="lease holder, if one is live")
|
|
425
|
+
s.add_argument("--force", action="store_true",
|
|
426
|
+
help="override a live lease held by another agent; needs --reason")
|
|
427
|
+
s.add_argument("--dry-run", dest="dry_run", action="store_true",
|
|
428
|
+
help="print the would-be changes, write nothing")
|
|
429
|
+
add_json(s)
|
|
430
|
+
s.set_defaults(**_defaults_except(update_parser, s), fn=cmd_update, cmd="update")
|
|
431
|
+
|
|
432
|
+
# `repo export|adopt` were `release NAME --fresh-repo|--adopt-repo DIR` before 1.0 (command_tree.MODE_ALIASES
|
|
433
|
+
# rewrites the old argv). Each keeps release's `cmd` and the other forms' flags hidden, so cmd_release sees the
|
|
434
|
+
# namespace it always saw and refuses a flag of another form as it always did.
|
|
435
|
+
s = repo_sub.add_parser("export", help="export the gate-bound commit's tree (or --from-tree SRCDIR) as a NEW "
|
|
436
|
+
"single-commit repository at DIR, then move the package there "
|
|
437
|
+
"(`release NAME --fresh-repo DIR` is the same)")
|
|
438
|
+
s.add_argument("name")
|
|
439
|
+
s.add_argument("fresh_repo", metavar="DIR",
|
|
440
|
+
help="the new repository (must not exist, or be empty): internal files and the patterns file "
|
|
441
|
+
"dropped, public-safety scanned; then the package is relocated there (repo move): "
|
|
442
|
+
"evidence cleared, provenance note added")
|
|
443
|
+
s.add_argument("--remote", metavar="URL", default=None,
|
|
444
|
+
help="git remote add origin URL, and set the record's repo")
|
|
445
|
+
s.add_argument("--keep-receipts", action="store_true",
|
|
446
|
+
help="copy .lean-receipts/ from the source HEAD (they do not bind to the new commit)")
|
|
447
|
+
s.add_argument("--source-commit", metavar="SHA", default=None,
|
|
448
|
+
help="export this commit instead of the gate-bound one")
|
|
449
|
+
s.add_argument("--from-tree", metavar="SRCDIR", default=None,
|
|
450
|
+
help="export the working tree at SRCDIR (a hand-cleaned tree, not a commit; .gitignore "
|
|
451
|
+
"honoured in a checkout) instead of the gate-bound commit")
|
|
452
|
+
s.add_argument("--author", metavar="IDENTITY", default=None,
|
|
453
|
+
help="'NAME <EMAIL>': author and committer of the export commit (default: user.name and "
|
|
454
|
+
"user.email of the source repository's local git config; the global identity is never "
|
|
455
|
+
"used)")
|
|
456
|
+
s.add_argument("--allow-author-email", action="store_true",
|
|
457
|
+
help="accept an identity email that is not a GitHub noreply address (it enters public history)")
|
|
458
|
+
s.add_argument("--agent", default=None, help="lease holder, if one is live")
|
|
459
|
+
s.add_argument("--reason", default="", help="free-text reason stored with the event")
|
|
460
|
+
s.add_argument("--dry-run", action="store_true",
|
|
461
|
+
help="stage and scan, print the plan; nothing written")
|
|
462
|
+
add_json(s)
|
|
463
|
+
export = s
|
|
464
|
+
s = repo_sub.add_parser("adopt", help="adopt the existing repository at DIR as the public history, then move "
|
|
465
|
+
"the package there (`release NAME --adopt-repo DIR` is the same)")
|
|
466
|
+
s.add_argument("name")
|
|
467
|
+
s.add_argument("adopt_repo", metavar="DIR",
|
|
468
|
+
help="the repository: exactly one commit unless --allow-history; tree and history "
|
|
469
|
+
"public-safety scanned; no new commit")
|
|
470
|
+
s.add_argument("--remote", metavar="URL", default=None,
|
|
471
|
+
help="git remote add origin URL, and set the record's repo")
|
|
472
|
+
s.add_argument("--allow-history", action="store_true",
|
|
473
|
+
help="accept a repository with more than one commit")
|
|
474
|
+
s.add_argument("--agent", default=None, help="lease holder, if one is live")
|
|
475
|
+
s.add_argument("--reason", default="", help="free-text reason stored with the event")
|
|
476
|
+
s.add_argument("--dry-run", action="store_true",
|
|
477
|
+
help="scan, print the plan; nothing written")
|
|
478
|
+
add_json(s)
|
|
479
|
+
adopt = s
|
|
480
|
+
# an old argv naming both modes reaches cmd_release, which refuses it as before (adopt is checked first)
|
|
481
|
+
export.add_argument("--adopt-repo", dest="adopt_repo", default=None, help=argparse.SUPPRESS)
|
|
482
|
+
adopt.add_argument("--fresh-repo", dest="fresh_repo", default=None, help=argparse.SUPPRESS)
|
|
483
|
+
for p in (lease_release, export, adopt):
|
|
484
|
+
_hidden_copies(p, *(q for q in (lease_release, export, adopt) if q is not p))
|
|
485
|
+
p.set_defaults(fn=cmd_release, cmd="release")
|
|
486
|
+
|
|
487
|
+
s = sub.add_parser("gate", help="validate a lower-tier receipt; "
|
|
488
|
+
"gate-pending -> verified-private; records the receipt's "
|
|
489
|
+
"lean_toolchain and mathlib_rev as the package's pins")
|
|
490
|
+
s.add_argument("name")
|
|
491
|
+
s.add_argument("--receipt", required=True, help="path to receipt JSON")
|
|
492
|
+
s.add_argument("--comparator", default=None, metavar="PATH",
|
|
493
|
+
help="optional comparator receipt JSON; "
|
|
494
|
+
"required later by promote")
|
|
495
|
+
s.add_argument("--refuse-private", action="store_true",
|
|
496
|
+
help="refuse (exit 1, nothing copied) when a receipt holds private strings; "
|
|
497
|
+
"default is a WARN line and the receipt is kept")
|
|
498
|
+
s.add_argument("--refuse-dirty", action="store_true",
|
|
499
|
+
help="refuse when tracked files are modified in the checkout; default is a WARN "
|
|
500
|
+
"line (receipts are always checked against the bound commit)")
|
|
501
|
+
s.add_argument("--refresh-formalization", action="store_true",
|
|
502
|
+
help="after the gate, regenerate the package's formalization.yaml (derived keys, "
|
|
503
|
+
"including status.evidence; kept keys survive) and set its registry pointer; "
|
|
504
|
+
"refuses when nothing would change")
|
|
505
|
+
s.add_argument("--agent", default=None,
|
|
506
|
+
help="the agent acting (recorded as the event's actor); another agent's live lease then "
|
|
507
|
+
"refuses; with --refresh-formalization: the live lease holder (the file write needs it); "
|
|
508
|
+
"with --check: not used (a stderr note), carried into the printed next: command")
|
|
509
|
+
s.add_argument("--check", action="store_true",
|
|
510
|
+
help="validate only, against HEAD (with --comparator: both tiers); write nothing, record "
|
|
511
|
+
"nothing (works at any status), like `comparator --check`; when it passes, prints the "
|
|
512
|
+
"writing gate to run next (next:, JSON next_command)")
|
|
513
|
+
s.add_argument("--regate", action="store_true",
|
|
514
|
+
help="re-gate a verified-private (or public) package on a new receipt in one step: event "
|
|
515
|
+
"regated {previous_commit, commit, job_id, reason}, status unchanged; the receipt's "
|
|
516
|
+
"commit must descend from the gated commit unless --reason is given")
|
|
517
|
+
s.add_argument("--reason", default=None, metavar="TEXT",
|
|
518
|
+
help="with --regate: accept a receipt commit that does not descend from the gated commit "
|
|
519
|
+
"(recorded with non_descendant: true)")
|
|
520
|
+
s.add_argument("--repo", default=None, metavar="DIR",
|
|
521
|
+
help="with --check only: validate against the checkout DIR instead of the registered "
|
|
522
|
+
"local_path, for this call (never saved; JSON repo_override). DIR must be a git work "
|
|
523
|
+
"tree, and when it has remotes one must be the package's repo. A writing gate refuses "
|
|
524
|
+
"it: it binds the registered checkout (drop --repo, or move that with `update --path`)")
|
|
525
|
+
add_json(s)
|
|
526
|
+
s.set_defaults(fn=cmd_gate)
|
|
527
|
+
|
|
528
|
+
# `comparator attach|check|config|coverage|migrate-signoff|host-check`: real subparsers, each with only its
|
|
529
|
+
# flags (config and host-check were values of a positional before 1.0; check, coverage and migrate-signoff were
|
|
530
|
+
# flags: command_tree.MODE_ALIASES rewrites the old argv). Each sets `name` as the positional did and the other
|
|
531
|
+
# forms' flags to their defaults, hidden, so cmd_comparator sees the namespace it always saw and refuses a flag
|
|
532
|
+
# of another form as it always did; `comparator NAME ...` is `comparator attach NAME ...`
|
|
533
|
+
# (command_tree.IMPLIED_VERBS).
|
|
534
|
+
s = sub.add_parser("comparator", help="comparator receipts: attach one to a gated package, or check it; "
|
|
535
|
+
"config (write a configuration from claims), coverage, migrate-signoff; "
|
|
536
|
+
"host-check")
|
|
537
|
+
comparator_sub = s.add_subparsers(dest="comparator_cmd", required=True,
|
|
538
|
+
metavar="{attach,check,config,coverage,migrate-signoff,host-check}")
|
|
539
|
+
s = comparator_sub.add_parser("attach", help="attach a comparator receipt to a gated package; no status change "
|
|
540
|
+
"(`comparator NAME --receipt R` is the same)")
|
|
541
|
+
s.add_argument("name")
|
|
542
|
+
s.add_argument("--receipt", default=None, help="path to comparator receipt JSON (required)")
|
|
543
|
+
s.add_argument("--refuse-private", action="store_true",
|
|
544
|
+
help="refuse (exit 1, nothing copied) when the receipt holds private strings; "
|
|
545
|
+
"default is a WARN line and the receipt is kept")
|
|
546
|
+
s.add_argument("--refuse-dirty", action="store_true",
|
|
547
|
+
help="refuse when tracked files are modified in the checkout; default is a WARN line")
|
|
548
|
+
s.add_argument("--replace", action="store_true",
|
|
549
|
+
help="when .lean-receipts/ already holds a different comparator receipt for the same commit: "
|
|
550
|
+
"keep it as <c12>-comparator.replaced-<UTC stamp>.json, attach the new one, record "
|
|
551
|
+
"comparator-replaced")
|
|
552
|
+
s.add_argument("--agent", default=None, help="the agent acting (recorded as the event's actor; another "
|
|
553
|
+
"agent's live lease then refuses)")
|
|
554
|
+
add_json(s)
|
|
555
|
+
attach = s
|
|
556
|
+
s = comparator_sub.add_parser("check", help="validate a comparator receipt against the package; read-only, "
|
|
557
|
+
"records nothing, works at any status (`comparator NAME --receipt R "
|
|
558
|
+
"--check` is the same)")
|
|
559
|
+
s.add_argument("name")
|
|
560
|
+
s.add_argument("--receipt", default=None, help="path to comparator receipt JSON (required)")
|
|
561
|
+
s.add_argument("--refuse-private", action="store_true",
|
|
562
|
+
help="refuse (exit 1) when the receipt holds private strings; default is a WARN line")
|
|
563
|
+
s.add_argument("--refuse-dirty", action="store_true",
|
|
564
|
+
help="refuse when tracked files are modified in the checkout; default is a WARN line")
|
|
565
|
+
s.add_argument("--repo", default=None, metavar="DIR",
|
|
566
|
+
help="validate against the checkout DIR instead of the registered local_path, for this call "
|
|
567
|
+
"(never saved; JSON repo_override). DIR must be a git work tree, and when it has remotes "
|
|
568
|
+
"one must be the package's repo")
|
|
569
|
+
s.add_argument("--contracts-only", action="store_true",
|
|
570
|
+
help="no receipt: a read-only diagnostic of the compare step of every comparator configuration "
|
|
571
|
+
"in the checkout (Lake's own compareAt and checkAxioms on one shared export per module); "
|
|
572
|
+
"per failing configuration the first differing ConstantInfo field and the breadcrumb "
|
|
573
|
+
"from the target; no kernel runs, nothing is written, never acceptance")
|
|
574
|
+
s.add_argument("--config", dest="contracts_configs", action="append", default=[], metavar="PATH",
|
|
575
|
+
help="with --contracts-only: only this configuration (relative to the checkout; repeatable; "
|
|
576
|
+
"default: comparator*.json and comparator/config*.json)")
|
|
577
|
+
s.add_argument("--export", dest="contracts_exports", action="append", default=[], metavar="MODULE=FILE",
|
|
578
|
+
help="with --contracts-only: read this existing leanexport file for MODULE instead of "
|
|
579
|
+
"exporting it (repeatable; you answer for its freshness)")
|
|
580
|
+
s.add_argument("--no-sandbox", dest="contracts_no_sandbox", action="store_true",
|
|
581
|
+
help="with --contracts-only: run leanexport and the compare helper without bwrap")
|
|
582
|
+
add_json(s)
|
|
583
|
+
check = s
|
|
584
|
+
s = comparator_sub.add_parser("config", help="write a comparator configuration from claims (--from-claims); "
|
|
585
|
+
"coverage and migrate-signoff are verbs of their own")
|
|
586
|
+
s.add_argument("--from-claims", default=None, metavar="NAME",
|
|
587
|
+
help="add a TODO theorem_names entry per synced claim (theorem/lemma) no comparator "
|
|
588
|
+
"configuration covers yet; never overwrites")
|
|
589
|
+
s.add_argument("--out", default=None, help="the configuration to extend or create (default comparator.json)")
|
|
590
|
+
s.add_argument("--dry-run", action="store_true", help="print the would-be JSON; write nothing")
|
|
591
|
+
s.add_argument("--challenge-namespace", default=None,
|
|
592
|
+
help="namespace of the new Challenge names (default <Package>Audit)")
|
|
593
|
+
s.add_argument("--agent", default=None, help="lease holder, if one is live")
|
|
594
|
+
s.add_argument("--challenge-from-type", action="store_true",
|
|
595
|
+
help="pre-fill each new Challenge/Solution from the declaration's elaborated "
|
|
596
|
+
"type (runs `lake env lean` in the checkout)")
|
|
597
|
+
s.add_argument("--emit-script", default=None, metavar="F",
|
|
598
|
+
help="write the type driver to F (run it elsewhere: cd CHECKOUT && bash F OUT.json); "
|
|
599
|
+
"no Lean runs here")
|
|
600
|
+
s.add_argument("--from-output", default=None, metavar="F",
|
|
601
|
+
help="fill the scaffold from the driver's comparator-types/1 JSON F")
|
|
602
|
+
s.add_argument("--repo", dest="checkout", default=None, metavar="DIR",
|
|
603
|
+
help="with --from-claims: use this package checkout instead of the registry's "
|
|
604
|
+
"local_path (HEAD must be the claims-synced commit or an evidence-only descendant)")
|
|
605
|
+
s.add_argument("--claims-file", dest="claims_file", default=None, metavar="PATH",
|
|
606
|
+
help="with --from-claims: read the claims from this working-copy claims.yaml instead of "
|
|
607
|
+
"the registry's synced cache (no `claims sync` needed); schema-checked exactly like "
|
|
608
|
+
"`claims check --file`; never written to the registry; the output names the file and "
|
|
609
|
+
"its sha256")
|
|
610
|
+
s.add_argument("--no-registry", action="store_true",
|
|
611
|
+
help="with --from-output/--challenge-from-type and --out FILE: scratch mode; write "
|
|
612
|
+
"the merged config to FILE outside the checkout, lease not consulted")
|
|
613
|
+
s.add_argument("--allow-partial", action="store_true",
|
|
614
|
+
help="with --from-output/--challenge-from-type: ingest a run with extraction failures "
|
|
615
|
+
"(the failed entries keep TODO, restatement_reason extraction_failed)")
|
|
616
|
+
s.add_argument("--lake-env", default=None, metavar="DIR",
|
|
617
|
+
help="with the type flags: Lake directory inside the checkout (default: the checkout)")
|
|
618
|
+
s.add_argument("--jobs", type=int, default=None, help="with the type flags: parallel Lean processes (default 2, at most the CPUs; halved and retried on too many open files)")
|
|
619
|
+
s.add_argument("--timeout", type=int, default=None,
|
|
620
|
+
help="with the type flags: seconds per declaration (default 120)")
|
|
621
|
+
# the old mode flags, hidden: spread to the other forms below, so an old argv mixing modes reaches
|
|
622
|
+
# cmd_comparator and is refused as before
|
|
623
|
+
s.add_argument("--coverage", default=None, help=argparse.SUPPRESS)
|
|
624
|
+
s.add_argument("--migrate-signoff", dest="migrate_signoff", default=None, help=argparse.SUPPRESS)
|
|
625
|
+
add_json(s)
|
|
626
|
+
config = s
|
|
627
|
+
s = comparator_sub.add_parser("coverage", help="read-only: the claims covered by the comparator configuration "
|
|
628
|
+
"tracked at the gate-bound commit, and why a changed one needs a "
|
|
629
|
+
"new gate (`comparator config --coverage NAME` is the same)")
|
|
630
|
+
s.add_argument("coverage", metavar="NAME")
|
|
631
|
+
add_json(s)
|
|
632
|
+
coverage = s
|
|
633
|
+
s = comparator_sub.add_parser("migrate-signoff", help="move the deprecated inline judged_as / lean_pkg_scaffold "
|
|
634
|
+
"keys of a configuration into lean-pkg-signoff.json; dry "
|
|
635
|
+
"run unless --write (`comparator config --migrate-signoff "
|
|
636
|
+
"PATH` is the same)")
|
|
637
|
+
s.add_argument("migrate_signoff", metavar="PATH",
|
|
638
|
+
help="the configuration; its Palomar keys are unchanged, its bytes (and so its receipt hash) "
|
|
639
|
+
"change")
|
|
640
|
+
s.add_argument("--write", action="store_true", help="write both files")
|
|
641
|
+
add_json(s)
|
|
642
|
+
signoff = s
|
|
643
|
+
s = comparator_sub.add_parser("host-check", help="can this host run the comparator; read-only")
|
|
644
|
+
s.add_argument("--routes", action="store_true",
|
|
645
|
+
help="per route (judge = `lake comparator` in bwrap, prepare = setup "
|
|
646
|
+
"stages, transfer = build here, judge elsewhere) supported yes/no with the reason, "
|
|
647
|
+
"executables (type -P), locale, open-file limits, CPUs, cgroup memory and a command "
|
|
648
|
+
"line per supported route; read-only; exit 0 when any route is supported")
|
|
649
|
+
add_json(s)
|
|
650
|
+
host = s
|
|
651
|
+
forms = ((attach, None), (check, None), (config, CONFIG_CMD), (coverage, CONFIG_CMD), (signoff, CONFIG_CMD),
|
|
652
|
+
(host, HOST_CHECK))
|
|
653
|
+
for p, _name in forms: # `--check` (hidden): the check form's mark, on every form as the old flag was
|
|
654
|
+
p.add_argument("--check", action="store_true", default=p is check, help=argparse.SUPPRESS)
|
|
655
|
+
for p, name in forms:
|
|
656
|
+
_hidden_copies(p, *(q for q, _ in forms if q is not p))
|
|
657
|
+
p.set_defaults(fn=cmd_comparator, **({"name": name} if name else {}))
|
|
658
|
+
|
|
659
|
+
s = registry_sub.add_parser("audit", help="report expired leases, gh visibility, drift; read-only without --write")
|
|
660
|
+
s.add_argument("--write", dest="fix", action="store_true",
|
|
661
|
+
help="clear expired leases and update visibility/archive state from gh")
|
|
662
|
+
s.add_argument("--toolchain-floor", default=None, metavar="VERSION",
|
|
663
|
+
help=f"oldest acceptable lean_toolchain (default: ${TOOLCHAIN_FLOOR_ENV}, "
|
|
664
|
+
f"else {DEFAULT_TOOLCHAIN_FLOOR})")
|
|
665
|
+
s.add_argument("--promotion", action="store_true",
|
|
666
|
+
help="judge every package against the toolchain floor as for promote (warn, not info)")
|
|
667
|
+
s.add_argument("--no-gh", action="store_true",
|
|
668
|
+
help="skip the GitHub (gh) checks: visibility and archived state are not compared")
|
|
669
|
+
s.add_argument("--quiet", action="store_true",
|
|
670
|
+
help="only the count line (\"N finding(s): W warn, I info\", or \"no findings\"); no "
|
|
671
|
+
"per-finding line (--json is unchanged)")
|
|
672
|
+
add_json(s)
|
|
673
|
+
s.set_defaults(fn=cmd_audit, cmd="audit")
|
|
674
|
+
|
|
675
|
+
s = registry_sub.add_parser("validate", help="schema + enum + history sanity; exit 0/1")
|
|
676
|
+
add_json(s)
|
|
677
|
+
s.set_defaults(fn=cmd_validate, cmd="validate")
|
|
678
|
+
|
|
679
|
+
from . import recommended as recommended_mod
|
|
680
|
+
recommended_mod.add_parser(registry_sub, add_json)
|
|
681
|
+
|
|
682
|
+
s = sub.add_parser("doctor", help="installation, registry, index and tool diagnostics; "
|
|
683
|
+
"exit 1 when the registry is unreadable or its schema "
|
|
684
|
+
"version is unsupported")
|
|
685
|
+
s.add_argument("name", nargs="?", default=None, metavar="NAME",
|
|
686
|
+
help="also check this package's committed lean-toolchain, Mathlib commit (lake-manifest.json) and "
|
|
687
|
+
"recorded comparator receipt's tool digests against the LTS stack its coverage.yaml declares "
|
|
688
|
+
"(`stack: NAME`; docs/stacks/): a warn line on a mismatch or a stack past its window, never "
|
|
689
|
+
"an exit 1")
|
|
690
|
+
s.add_argument("--fetch", action="store_true",
|
|
691
|
+
help="git fetch origin in the tool checkout and the registry repo before comparing "
|
|
692
|
+
"(default: local refs)")
|
|
693
|
+
s.add_argument("--package", dest="skew_package", default=None, metavar="NAME",
|
|
694
|
+
help="also compare the lean-pkg that wrote each gate receipt of package NAME (the receipt's "
|
|
695
|
+
"producer.lean_pkg) with the running one: a `producer <role>` warn line on a skew across "
|
|
696
|
+
"a breaking change to receipts, gate or claims, naming the upgrade-record entries and "
|
|
697
|
+
"the `doctor --upgrade-from` command, or on a newer producer; never an exit 1. --json "
|
|
698
|
+
"adds producer_skew")
|
|
699
|
+
from . import upgrade as upgrade_mod
|
|
700
|
+
upgrade_mod.add_arguments(s)
|
|
701
|
+
add_json(s)
|
|
702
|
+
s.set_defaults(fn=cmd_doctor)
|
|
703
|
+
|
|
704
|
+
s = sub.add_parser("llms", help="print the agent-oriented usage contract")
|
|
705
|
+
s.add_argument("--short", action="store_true",
|
|
706
|
+
help="a compact contract (~40 lines) cut from the full one: PURPOSE, STANDING RULES and the first "
|
|
707
|
+
"line of each subcommand; no flag details, schemas or examples")
|
|
708
|
+
add_json(s)
|
|
709
|
+
s.set_defaults(fn=cmd_llms)
|
|
710
|
+
|
|
711
|
+
s = sub.add_parser("help", help="help topics (exit-codes, environment, formatting) or a command's --help",
|
|
712
|
+
description="Without an argument: the commands and help topics. With a topic "
|
|
713
|
+
"(exit-codes, environment, formatting): that topic. With a command "
|
|
714
|
+
"(`help status`, `help index add`): exactly its --help. Reads no registry.")
|
|
715
|
+
s.add_argument("words", nargs="*", metavar="TOPIC|COMMAND")
|
|
716
|
+
add_json(s)
|
|
717
|
+
s.set_defaults(fn=cmd_help, help_root=ap)
|
|
718
|
+
|
|
719
|
+
s = registry_sub.add_parser("wiki", help="render a Markdown status page")
|
|
720
|
+
s.add_argument("--out", default=None,
|
|
721
|
+
help="write the Markdown here instead of stdout")
|
|
722
|
+
s.add_argument("--candidates", default=None,
|
|
723
|
+
help="adoption ledger path (default: lean-adoption-candidates.yaml "
|
|
724
|
+
"next to the registry)")
|
|
725
|
+
add_json(s)
|
|
726
|
+
s.set_defaults(fn=cmd_wiki, cmd="wiki")
|
|
727
|
+
|
|
728
|
+
from . import index as index_mod
|
|
729
|
+
index_mod.add_parsers(sub, add_json)
|
|
730
|
+
from . import claims as claims_mod
|
|
731
|
+
claims_mod.add_parsers(sub, add_json)
|
|
732
|
+
from . import search as search_mod
|
|
733
|
+
search_mod.add_parsers(sub, add_json)
|
|
734
|
+
from . import formalization as formalization_mod
|
|
735
|
+
formalization_mod.add_parsers(sub, add_json)
|
|
736
|
+
from . import publish as publish_mod
|
|
737
|
+
publish_mod.add_parsers(sub, add_json)
|
|
738
|
+
from . import coverage as coverage_mod
|
|
739
|
+
coverage_mod.add_parsers(sub, add_json)
|
|
740
|
+
from . import page as page_mod
|
|
741
|
+
page_mod.add_parsers(sub, add_json)
|
|
742
|
+
from . import reservoir as reservoir_mod
|
|
743
|
+
reservoir_mod.add_parsers(sub, add_json)
|
|
744
|
+
from . import blueprint as blueprint_mod
|
|
745
|
+
blueprint_mod.add_parsers(sub, add_json)
|
|
746
|
+
from . import public_safety as public_safety_mod
|
|
747
|
+
public_safety_mod.add_parsers(sub, add_json)
|
|
748
|
+
from . import palomar as palomar_mod
|
|
749
|
+
palomar_mod.add_parsers(sub, add_json)
|
|
750
|
+
from . import next_step as next_mod
|
|
751
|
+
next_mod.add_parsers(sub, add_json)
|
|
752
|
+
from . import report as report_mod
|
|
753
|
+
report_mod.add_parsers(sub, add_json)
|
|
754
|
+
from . import receipt as receipt_mod
|
|
755
|
+
receipt_mod.add_parsers(sub, add_json)
|
|
756
|
+
from . import verify as verify_mod
|
|
757
|
+
verify_mod.add_parsers(sub, add_json)
|
|
758
|
+
from . import seal_bundle as seal_bundle_mod
|
|
759
|
+
seal_bundle_mod.add_parsers(sub, add_json)
|
|
760
|
+
|
|
761
|
+
from . import command_tree
|
|
762
|
+
show_commit_flags_on_writes(ap) # before the flag aliases: they annotate the help texts left shown
|
|
763
|
+
command_tree.apply_flag_aliases(ap)
|
|
764
|
+
command_tree.apply_tiers(ap)
|
|
765
|
+
command_tree.register_root(ap)
|
|
766
|
+
ap.alias_root = True # old spellings are rewritten to canonical ones before parsing
|
|
767
|
+
ap.set_defaults(fn=cmd_board)
|
|
768
|
+
return ap
|