@orbit-build/cli 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
6
6
  "keywords": [
@@ -206,7 +206,9 @@ the outcome. Record explicit upstream artifact contracts between subproblems.
206
206
  the necessary allowances in
207
207
  `paper/contest-profile.json.result_artifacts.fixed_schema_exceptions` so the
208
208
  finalizer can distinguish a contest requirement from an accidental English
209
- artifact. Internal convenience and cross-question code contracts are not
209
+ artifact. The finalizer requires every waived field to match that cited
210
+ source; citation without schema congruence is rejected. Internal convenience
211
+ and cross-question code contracts are not
210
212
  exceptions; use a Chinese persisted schema and validate it explicitly.
211
213
  - In a compact handoff, place only explicitly required submission artifacts
212
214
  (final PDFs and required filled Excel/Word files) at project root. Keep
@@ -3,5 +3,5 @@
3
3
  比赛期间每次使用后立即追加,不要在交稿前凭记忆补写。
4
4
 
5
5
  | 日期时间 | 工具、版本与提供方 | 使用目的 | 关键提示词/输入 | 输出摘要 | 采纳内容与人工修改 | 核验方式 |
6
- | --- | --- | --- | --- | --- | --- | --- |
7
- | TODO | TODO | TODO | TODO | TODO | TODO | TODO |
6
+ | -------- | ------------------ | -------- | --------------- | -------- | ------------------ | -------- |
7
+ | TODO | TODO | TODO | TODO | TODO | TODO | TODO |
@@ -2,6 +2,7 @@
2
2
  "schema_version": 1,
3
3
  "profile": "cumcm-2026",
4
4
  "rules_checked_at": "2026-08-12",
5
+ "rules_expires_at": "2026-09-30",
5
6
  "paper": {
6
7
  "max_pdf_mb": 20,
7
8
  "max_body_pages": 30,
@@ -111,7 +111,10 @@ Allowed exception scopes are `filename`, `headers`, `sheet_names`, and
111
111
  `encoding`. Grant only what the official requirement fixes. A code-facing
112
112
  English schema, a library default, or personal convenience is not an exception;
113
113
  persist a Chinese schema and adapt internal variables at the read/write
114
- boundary. Never write outputs into `question/`.
114
+ boundary. The finalizer compares every waived field against the cited source;
115
+ the source path alone is not evidence. Preserve filename, column order,
116
+ worksheet names, and encoding markers exactly where they are waived. Never
117
+ write outputs into `question/`.
115
118
 
116
119
  ## Figures
117
120
 
@@ -77,6 +77,17 @@ def write_freeze(root: Path) -> Path:
77
77
  "schema_version": 1,
78
78
  "state": "frozen",
79
79
  "created_at": datetime.now(timezone.utc).isoformat(),
80
+ "verifier": {
81
+ "name": "cumcm-draft-finalizer",
82
+ "scripts_sha256": {
83
+ name: sha256(Path(__file__).resolve().parent / name)
84
+ for name in (
85
+ "evidence_freeze.py",
86
+ "finalize_project.py",
87
+ "validate_project.py",
88
+ )
89
+ },
90
+ },
80
91
  "files": snapshot_evidence(root),
81
92
  }
82
93
  temporary = target.with_name(f"{target.name}.tmp")
@@ -10,6 +10,7 @@ import re
10
10
  import subprocess
11
11
  import sys
12
12
  import zipfile
13
+ from datetime import date
13
14
  from pathlib import Path, PurePosixPath
14
15
  from typing import Any
15
16
  from xml.etree import ElementTree
@@ -168,7 +169,45 @@ def delimited_header(
168
169
 
169
170
 
170
171
  def xlsx_sheet_headers(path: Path) -> list[tuple[str, list[str]]]:
171
- """Read worksheet names and first non-empty rows without optional packages."""
172
+ """Read worksheet names and semantic header rows with an OOXML fallback."""
173
+ try:
174
+ import openpyxl
175
+ except ImportError:
176
+ pass
177
+ else:
178
+ try:
179
+ workbook = openpyxl.load_workbook(
180
+ path, read_only=False, data_only=False, keep_links=False
181
+ )
182
+ except (KeyError, OSError, ValueError, zipfile.BadZipFile):
183
+ workbook = None
184
+ if workbook is not None:
185
+ sheets: list[tuple[str, list[str]]] = []
186
+ try:
187
+ for worksheet in workbook.worksheets:
188
+ candidate_rows: list[list[str]] = []
189
+ for row in worksheet.iter_rows(max_row=min(20, worksheet.max_row)):
190
+ values = [
191
+ "" if cell.value is None else str(cell.value).strip()
192
+ for cell in row
193
+ ]
194
+ if any(values):
195
+ candidate_rows.append(values)
196
+ if sum(bool(value) for value in values) >= 2:
197
+ break
198
+ headers = next(
199
+ (
200
+ values
201
+ for values in candidate_rows
202
+ if sum(bool(value) for value in values) >= 2
203
+ ),
204
+ candidate_rows[0] if candidate_rows else [],
205
+ )
206
+ sheets.append((worksheet.title.strip(), headers))
207
+ finally:
208
+ workbook.close()
209
+ return sheets
210
+
172
211
  with zipfile.ZipFile(path) as workbook:
173
212
  shared_strings: list[str] = []
174
213
  if "xl/sharedStrings.xml" in workbook.namelist():
@@ -201,7 +240,7 @@ def xlsx_sheet_headers(path: Path) -> list[tuple[str, list[str]]]:
201
240
  if member.startswith("../") or not member.startswith("xl/"):
202
241
  raise ValueError(f"unsafe worksheet path in workbook: {target}")
203
242
  sheet_root = ElementTree.fromstring(workbook.read(member))
204
- headers: list[str] = []
243
+ candidate_rows: list[list[str]] = []
205
244
  for row in sheet_root.iter(f"{SPREADSHEET_NS}row"):
206
245
  values: list[str] = []
207
246
  for cell in row.findall(f"{SPREADSHEET_NS}c"):
@@ -224,8 +263,19 @@ def xlsx_sheet_headers(path: Path) -> list[tuple[str, list[str]]]:
224
263
  value = raw_value
225
264
  values.append(value.strip())
226
265
  if any(values):
227
- headers = values
266
+ candidate_rows.append(values)
267
+ if sum(bool(value) for value in values) >= 2:
268
+ break
269
+ if len(candidate_rows) >= 20:
228
270
  break
271
+ headers = next(
272
+ (
273
+ values
274
+ for values in candidate_rows
275
+ if sum(bool(value) for value in values) >= 2
276
+ ),
277
+ candidate_rows[0] if candidate_rows else [],
278
+ )
229
279
  sheets.append((name, headers))
230
280
  return sheets
231
281
 
@@ -256,7 +306,7 @@ def result_artifact_contract_errors(
256
306
  if not isinstance(raw_exceptions, list):
257
307
  errors.append("result_artifacts.fixed_schema_exceptions must be a list")
258
308
  raw_exceptions = []
259
- exceptions: dict[str, set[str]] = {}
309
+ exceptions: dict[str, tuple[set[str], Path]] = {}
260
310
  for index, item in enumerate(raw_exceptions, start=1):
261
311
  location = f"result_artifacts.fixed_schema_exceptions[{index}]"
262
312
  if not isinstance(item, dict):
@@ -332,7 +382,12 @@ def result_artifact_contract_errors(
332
382
  if key in exceptions:
333
383
  errors.append(f"duplicate fixed-schema exception path: {path_value}")
334
384
  else:
335
- exceptions[key] = allowed_scopes
385
+ assert isinstance(source_value, str)
386
+ source_relative = normalized_relative_path(source_value)
387
+ exceptions[key] = (
388
+ allowed_scopes,
389
+ root.joinpath(*source_relative.parts),
390
+ )
336
391
 
337
392
  roots = (root / "results", root / "produce" / "results")
338
393
  for base in roots:
@@ -351,7 +406,9 @@ def result_artifact_contract_errors(
351
406
  if not path.is_file():
352
407
  errors.append(f"tabular result must be a regular file: {relative}")
353
408
  continue
354
- allowances = exceptions.get(relative.casefold(), set())
409
+ exception = exceptions.get(relative.casefold())
410
+ allowances = exception[0] if exception else set()
411
+ prescribed_source = exception[1] if exception else None
355
412
  suffix = path.suffix.lower()
356
413
  if flags["require_chinese_filenames"] and "filename" not in allowances:
357
414
  if not has_chinese(path.stem):
@@ -448,6 +505,87 @@ def result_artifact_contract_errors(
448
505
  f"legacy XLS result cannot be inspected safely; generate XLSX or register the prescribed schema scopes for {relative}: "
449
506
  + ", ".join(missing_scopes)
450
507
  )
508
+ if prescribed_source is not None:
509
+ errors.extend(
510
+ fixed_schema_congruence_errors(
511
+ path, prescribed_source, allowances, relative
512
+ )
513
+ )
514
+ return errors
515
+
516
+
517
+ def fixed_schema_congruence_errors(
518
+ target: Path, source: Path, allowances: set[str], relative: str
519
+ ) -> list[str]:
520
+ """Prove that every waived presentation field matches the cited source."""
521
+ errors: list[str] = []
522
+ target_suffix = target.suffix.lower()
523
+ source_suffix = source.suffix.lower()
524
+ if target_suffix != source_suffix:
525
+ return [
526
+ f"fixed-schema exception format differs from its source for {relative}: "
527
+ f"{target_suffix} != {source_suffix}"
528
+ ]
529
+ # A problem attachment often prescribes an upload filename in its prose
530
+ # rather than by the attachment's own basename. Provenance therefore
531
+ # proves a filename waiver; structural fields below can be compared
532
+ # byte-for-byte against the cited template.
533
+ if target_suffix in {".csv", ".tsv"}:
534
+ delimiter = "\t" if target_suffix == ".tsv" else ","
535
+ try:
536
+ target_bom, target_headers = delimited_header(
537
+ target, delimiter, allow_prescribed_encoding=True
538
+ )
539
+ source_bom, source_headers = delimited_header(
540
+ source, delimiter, allow_prescribed_encoding=True
541
+ )
542
+ except (OSError, UnicodeDecodeError, csv.Error) as error:
543
+ return [f"could not compare fixed schema for {relative}: {error}"]
544
+ if "headers" in allowances and target_headers != source_headers:
545
+ errors.append(
546
+ f"fixed-schema headers differ from the cited source for {relative}"
547
+ )
548
+ if "encoding" in allowances and target_bom != source_bom:
549
+ errors.append(
550
+ f"fixed-schema BOM/encoding marker differs from the cited source for {relative}"
551
+ )
552
+ elif target_suffix == ".xlsx":
553
+ try:
554
+ target_sheets = xlsx_sheet_headers(target)
555
+ source_sheets = xlsx_sheet_headers(source)
556
+ except (KeyError, OSError, ValueError, zipfile.BadZipFile, ElementTree.ParseError) as error:
557
+ return [f"could not compare fixed XLSX schema for {relative}: {error}"]
558
+ if "sheet_names" in allowances and [name for name, _ in target_sheets] != [
559
+ name for name, _ in source_sheets
560
+ ]:
561
+ errors.append(
562
+ f"fixed-schema worksheet names differ from the cited source for {relative}"
563
+ )
564
+ if "headers" in allowances and [headers for _, headers in target_sheets] != [
565
+ headers for _, headers in source_sheets
566
+ ]:
567
+ errors.append(
568
+ f"fixed-schema worksheet headers differ from the cited source for {relative}"
569
+ )
570
+ return errors
571
+
572
+
573
+ def rules_freshness_errors(profile: dict[str, object]) -> list[str]:
574
+ try:
575
+ checked_date = date.fromisoformat(str(profile.get("rules_checked_at")))
576
+ expires_date = date.fromisoformat(str(profile.get("rules_expires_at")))
577
+ except ValueError:
578
+ return ["contest profile must contain ISO rules_checked_at and rules_expires_at dates"]
579
+ errors: list[str] = []
580
+ today = date.today()
581
+ if checked_date > today:
582
+ errors.append("contest rules_checked_at must not be in the future")
583
+ if expires_date < today:
584
+ errors.append(
585
+ f"contest rule snapshot expired on {expires_date.isoformat()}; recheck official sources before finalization"
586
+ )
587
+ if expires_date < checked_date:
588
+ errors.append("contest rules_expires_at must not precede rules_checked_at")
451
589
  return errors
452
590
 
453
591
 
@@ -762,6 +900,8 @@ def main() -> None:
762
900
  warnings.extend(delivery_hygiene_warnings(root))
763
901
  if result_artifact_profile is not None:
764
902
  errors.extend(result_artifact_contract_errors(root, result_artifact_profile))
903
+ if profile:
904
+ errors.extend(rules_freshness_errors(profile))
765
905
  validate_evidence(root, count, errors, warnings)
766
906
  try:
767
907
  frozen_differences = evidence_differences(root)