lightcone-cli 0.6.0rc2__tar.gz → 0.6.0rc3__tar.gz

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.
Files changed (61) hide show
  1. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/PKG-INFO +5 -4
  2. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/README.md +2 -1
  3. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/pyproject.toml +3 -7
  4. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/cli/commands.py +90 -38
  5. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/runtime.py +15 -1
  6. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/container.py +109 -16
  7. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/content.py +97 -5
  8. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/dataset.py +444 -124
  9. lightcone_cli-0.6.0rc3/src/lightcone/engine/environments.py +122 -0
  10. lightcone_cli-0.6.0rc3/src/lightcone/engine/fetch.py +195 -0
  11. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/materialize.py +281 -605
  12. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/plan.py +309 -144
  13. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/project.py +74 -46
  14. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/publish.py +335 -104
  15. lightcone_cli-0.6.0rc3/src/lightcone/engine/register.py +419 -0
  16. lightcone_cli-0.6.0rc3/src/lightcone/engine/run.py +288 -0
  17. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/model.py +1 -1
  18. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/oci.py +17 -1
  19. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/policy.py +22 -14
  20. lightcone_cli-0.6.0rc3/src/lightcone/engine/sources.py +458 -0
  21. lightcone_cli-0.6.0rc3/src/lightcone/engine/staging.py +490 -0
  22. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/gitattributes.tmpl +9 -2
  23. lightcone_cli-0.6.0rc3/src/lightcone/engine/templates/files/results-README.md.tmpl +21 -0
  24. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/worker.py +90 -49
  25. lightcone_cli-0.6.0rc2/src/lightcone/engine/commits.py +0 -119
  26. lightcone_cli-0.6.0rc2/src/lightcone/engine/run.py +0 -134
  27. lightcone_cli-0.6.0rc2/src/lightcone/engine/templates/files/results-README.md.tmpl +0 -8
  28. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/.gitignore +0 -0
  29. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/LICENSE +0 -0
  30. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/_sandbox_exec.py +0 -0
  31. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/cli/__init__.py +0 -0
  32. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/cli/compute.py +0 -0
  33. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/__init__.py +0 -0
  34. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/__init__.py +0 -0
  35. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/catalog.py +0 -0
  36. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/local.py +0 -0
  37. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/local_runtime.py +0 -0
  38. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/model.py +0 -0
  39. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/output.py +0 -0
  40. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/slurm.py +0 -0
  41. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/compute/slurm_bootstrap.py +0 -0
  42. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/execution_resources.py +0 -0
  43. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/github.py +0 -0
  44. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/identity.py +0 -0
  45. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/image.py +0 -0
  46. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/__init__.py +0 -0
  47. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/boundary.py +0 -0
  48. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/denial.py +0 -0
  49. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/landlock.py +0 -0
  50. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/profiles/base.sbpl +0 -0
  51. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/profiles/network.sbpl +0 -0
  52. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/profiles/platform-defaults.sbpl +0 -0
  53. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/sandbox/seatbelt.py +0 -0
  54. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/__init__.py +0 -0
  55. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/data-README.md.tmpl +0 -0
  56. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/datalad-config.tmpl +0 -0
  57. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/gitignore.tmpl +0 -0
  58. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/index.md.tmpl +0 -0
  59. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/myst.yml.tmpl +0 -0
  60. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/templates/files/pyproject.toml.tmpl +0 -0
  61. {lightcone_cli-0.6.0rc2 → lightcone_cli-0.6.0rc3}/src/lightcone/engine/units.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lightcone-cli
3
- Version: 0.6.0rc2
3
+ Version: 0.6.0rc3
4
4
  Summary: Lightcone Research's agentic execution layer
5
5
  Project-URL: Repository, https://github.com/LightconeResearch/lightcone-cli
6
6
  Author: Lightcone Research
@@ -19,8 +19,8 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Topic :: Scientific/Engineering
21
21
  Requires-Python: >=3.11
22
- Requires-Dist: astra-spec<0.2,>=0.1.0rc1
23
- Requires-Dist: astra-tools>=0.3.0rc4
22
+ Requires-Dist: astra-spec==0.1.0rc3
23
+ Requires-Dist: astra-tools==0.3.0rc5
24
24
  Requires-Dist: click>=8.0
25
25
  Requires-Dist: cryptography>=44
26
26
  Requires-Dist: distributed>=2026.7
@@ -77,7 +77,8 @@ drafted with any AI coding assistant.
77
77
  ## Capabilities
78
78
 
79
79
  - **Multiverse analysis** — declare methodological decisions with multiple defensible options; `lc` materializes your analysis across every universe you define
80
- - **Provenance by construction** — every result is committed to git together with its ASTRA provenance record and a re-runnable run record; git-annex carries the bytes, so results travel with the repository
80
+ - **Provenance by construction** — every result is committed to git together with its ASTRA provenance record and a re-runnable run record; figures, metrics, tables and reports are committed to git itself and git-annex carries the data, so results travel with the repository
81
+ - **External data** — `lc register` pins a mounted file, a versioned HTTPS download, or a file in another annex. Workers can read verified inputs in place. `lc publish` checks their read routes and sends generated outputs to the project’s store.
81
82
  - **Locked, isolated execution** — a project's environment is `pyproject.toml` + `uv.lock`; recipes run in it under a sandbox (Landlock on Linux, Seatbelt on macOS) that keeps undeclared files out and stray writes contained
82
83
  - **Containers and HPC** — declare `[tool.lightcone.image]` and recipes run in a content-addressed image archived in the repository itself; allocate local or Slurm Dask clusters explicitly with `lc compute`, then pass the cluster name or full ID to `run` or `materialize`
83
84
 
@@ -44,7 +44,8 @@ drafted with any AI coding assistant.
44
44
  ## Capabilities
45
45
 
46
46
  - **Multiverse analysis** — declare methodological decisions with multiple defensible options; `lc` materializes your analysis across every universe you define
47
- - **Provenance by construction** — every result is committed to git together with its ASTRA provenance record and a re-runnable run record; git-annex carries the bytes, so results travel with the repository
47
+ - **Provenance by construction** — every result is committed to git together with its ASTRA provenance record and a re-runnable run record; figures, metrics, tables and reports are committed to git itself and git-annex carries the data, so results travel with the repository
48
+ - **External data** — `lc register` pins a mounted file, a versioned HTTPS download, or a file in another annex. Workers can read verified inputs in place. `lc publish` checks their read routes and sends generated outputs to the project’s store.
48
49
  - **Locked, isolated execution** — a project's environment is `pyproject.toml` + `uv.lock`; recipes run in it under a sandbox (Landlock on Linux, Seatbelt on macOS) that keeps undeclared files out and stray writes contained
49
50
  - **Containers and HPC** — declare `[tool.lightcone.image]` and recipes run in a content-addressed image archived in the repository itself; allocate local or Slurm Dask clusters explicitly with `lc compute`, then pass the cluster name or full ID to `run` or `materialize`
50
51
 
@@ -23,14 +23,10 @@ classifiers = [
23
23
  "Topic :: Scientific/Engineering",
24
24
  ]
25
25
 
26
- # astra-tools 0.3 is the first release with `astra.api`, the one surface lc
27
- # reads an analysis through, and 0.3.0rc4 the first whose `resolve` takes
28
- # where a run gives another commit's files. astra-spec is a direct
29
- # dependency only for its specifier: 0.1 is a release candidate, which a
30
- # resolver takes for a package it is asked for by such a version.
26
+ # Pin the runner API and matching specification for wheel installs and DataLad reruns.
31
27
  dependencies = [
32
- "astra-tools>=0.3.0rc4",
33
- "astra-spec>=0.1.0rc1,<0.2",
28
+ "astra-tools==0.3.0rc5",
29
+ "astra-spec==0.1.0rc3",
34
30
  "click>=8.0",
35
31
  "rich>=13.0",
36
32
  # 10.20261026 is the first git-annex that sends nothing to a store this
@@ -231,10 +231,15 @@ def run(cluster_id: str, command: tuple[str, ...]) -> None:
231
231
  """Run COMMAND on CLUSTER in the project's sandboxed environment.
232
232
 
233
233
  Use `lc run CLUSTER -- COMMAND...` with a cluster name or ID; the allocation
234
- remains available after the command finishes.
234
+ remains available after the command finishes. The command sees the project
235
+ as it stands, uncommitted edits included, and needs no commit. It downloads
236
+ no data: a file whose bytes this clone lacks is read where a repository on
237
+ this machine holds them. Files the command makes in results/ return to the
238
+ project when it finishes, and one it removes there stays in the project. A
239
+ result committed to the annex is read-only: remove it to write it again.
235
240
  """
236
241
  from lightcone.engine import run as engine_run
237
- from lightcone.engine.project import current_project
242
+ from lightcone.engine.project import declared_project
238
243
 
239
244
  _require_cluster_id(cluster_id)
240
245
  if command and command[0] == "--":
@@ -242,7 +247,7 @@ def run(cluster_id: str, command: tuple[str, ...]) -> None:
242
247
  if not command:
243
248
  raise click.UsageError("A command is required; no interactive shell is opened.")
244
249
  try:
245
- outcome = engine_run.probe(current_project(), command, cluster_id=cluster_id)
250
+ outcome = engine_run.probe(declared_project(), command, cluster_id=cluster_id)
246
251
  except KeyboardInterrupt:
247
252
  _interrupted(cluster_id, "the remote command may still be running")
248
253
  raise
@@ -373,7 +378,7 @@ def build(as_json: bool) -> None:
373
378
  def materialize(
374
379
  targets: tuple[str, ...], check_only: bool, refresh: bool, as_json: bool
375
380
  ) -> None:
376
- """Make the analysis's results on CLUSTER, committing each as it lands.
381
+ """Make results on CLUSTER, then collect and commit them in dependency order.
377
382
 
378
383
  Execution requires a cluster name or ID as its first positional argument.
379
384
  With --check, all positional arguments are targets and no cluster is used.
@@ -402,7 +407,7 @@ def materialize(
402
407
  """
403
408
  from lightcone.engine import container as engine_container
404
409
  from lightcone.engine import materialize as engine
405
- from lightcone.engine.project import current_project
410
+ from lightcone.engine.project import declared_project
406
411
 
407
412
  cluster_id = ""
408
413
  if check_only:
@@ -422,7 +427,7 @@ def materialize(
422
427
  cluster_id, *remaining = targets
423
428
  _require_cluster_id(cluster_id)
424
429
  targets = tuple(remaining)
425
- root = current_project()
430
+ root = declared_project()
426
431
  if not check_only and not as_json:
427
432
  # The engine never prints, and the build it may be about to run
428
433
  # can take minutes — so the one place that owns the console says
@@ -442,8 +447,11 @@ def materialize(
442
447
  report = engine.materialize(root, targets, cluster_id=cluster_id, refresh=refresh)
443
448
  except KeyboardInterrupt:
444
449
  _interrupted(
445
- cluster_id, "remote recipes may still be writing results",
446
- " and confirm they have stopped before cleaning results/",
450
+ cluster_id,
451
+ "results committed so far are kept, and remote recipes may still be "
452
+ "writing others",
453
+ " and confirm they have stopped before removing retained "
454
+ ".lightcone/runs/ checkouts",
447
455
  )
448
456
  raise
449
457
 
@@ -458,6 +466,29 @@ def materialize(
458
466
  sys.exit(1)
459
467
 
460
468
 
469
+ # =============================================================================
470
+ # lc register
471
+ # =============================================================================
472
+
473
+
474
+ @main.command()
475
+ @click.argument("source")
476
+ @click.argument("project_path")
477
+ @click.option("--ssh", default="", metavar="HOST[:/PATH]", help="Advertise an SSH read address.")
478
+ @click.option("--sha256", default="", metavar="HEX", help="Trusted digest of this HTTPS version.")
479
+ def register(source: str, project_path: str, ssh: str, sha256: str) -> None:
480
+ """Stage an external file at PROJECT_PATH for recipes or independent use.
481
+
482
+ SOURCE may be a mounted file, a direct HTTPS download URL, or an annexed file
483
+ in a producer checkout. Repeat a registration to add a read address to the same pin.
484
+ Review the staged pointer and commit it with Git.
485
+ """
486
+ from lightcone.engine.project import declared_project
487
+ from lightcone.engine.register import register as pin
488
+
489
+ click.echo(pin(declared_project(), source, project_path, ssh=ssh, sha256=sha256))
490
+
491
+
461
492
  # =============================================================================
462
493
  # lc status
463
494
  # =============================================================================
@@ -470,7 +501,9 @@ def materialize(
470
501
  is_flag=True,
471
502
  help="Emit the report as JSON on stdout.",
472
503
  )
473
- def status(as_json: bool) -> None:
504
+ @click.option("--files", is_flag=True, help="Show file pins, read routes and local availability.")
505
+ @click.argument("paths", nargs=-1, metavar="[PROJECT_PATH...]")
506
+ def status(as_json: bool, files: bool, paths: tuple[str, ...]) -> None:
474
507
  """Report where each of the analysis's results stands.
475
508
 
476
509
  For every result the analysis plans: ok; behind, where it is ok but
@@ -497,8 +530,25 @@ def status(as_json: bool) -> None:
497
530
  Use `lc materialize --check` for a gate that exits nonzero.
498
531
  """
499
532
  from lightcone.engine import materialize as engine
500
- from lightcone.engine.project import current_project
533
+ from lightcone.engine.project import current_project, declared_project
534
+
535
+ if files:
536
+ from lightcone.engine.sources import file_status
501
537
 
538
+ facts = file_status(declared_project(), paths)
539
+ if as_json:
540
+ click.echo(json.dumps({"files": facts}, indent=2))
541
+ else:
542
+ for file in facts:
543
+ click.echo(f"{file['path']} {file['availability']} ({file['verification']})")
544
+ for field in ("ids", "key", "git_blob", "sources", "mounts",
545
+ "routes", "route_verification"):
546
+ if value := file[field]:
547
+ label = ", ".join(value) if isinstance(value, list) else value
548
+ click.echo(f" {field} {label}")
549
+ return
550
+ if paths:
551
+ raise click.UsageError("Project paths require --files.")
502
552
  root = current_project()
503
553
  report = engine.status(root)
504
554
  if as_json:
@@ -576,7 +626,10 @@ _NOT_ONLINE = (
576
626
  help="Emit the report as JSON on stdout.",
577
627
  )
578
628
  def fetch(targets: tuple[str, ...], as_json: bool) -> None:
579
- """Bring the bytes of current results, and of named inputs, into this clone.
629
+ """Make selected results and named inputs available on this machine.
630
+
631
+ A registered file verified in its mounted archive is available in place.
632
+ Anything else this clone lacks is brought into it.
580
633
 
581
634
  A clone, or a pull, holds each result as a small stand-in for its
582
635
  bytes until they are fetched; `lc status` marks those results
@@ -593,14 +646,15 @@ def fetch(targets: tuple[str, ...], as_json: bool) -> None:
593
646
  """
594
647
  from rich.markup import escape
595
648
 
596
- from lightcone.engine import materialize as engine
649
+ from lightcone.engine.fetch import fetch as fetch_files
597
650
  from lightcone.engine.project import current_project
598
651
 
599
- report = engine.fetch(current_project(), targets)
652
+ report = fetch_files(current_project(), targets)
600
653
  if as_json:
601
654
  click.echo(json.dumps(report.as_dict(), indent=2))
602
655
  else:
603
656
  lines = [f" {_DONE} fetched {name}" for name in report.fetched]
657
+ lines += [f" {_DONE} available in place {escape(name)}" for name in report.in_place]
604
658
  lines += [
605
659
  f" {_TODO} {state} {name} — `lc materialize` makes it again"
606
660
  for name, state in report.left.items()
@@ -621,6 +675,8 @@ def fetch(targets: tuple[str, ...], as_json: bool) -> None:
621
675
  verdict = f"{_FAILED} {counted(report.failed)} could not be fetched"
622
676
  elif report.fetched:
623
677
  verdict = f"{_DONE} Fetched {counted(report.fetched)}"
678
+ elif report.in_place:
679
+ verdict = f"{_DONE} {counted(report.in_place)} available in place"
624
680
  else:
625
681
  verdict = f"{_DONE} Nothing to fetch" + (
626
682
  ""
@@ -696,23 +752,14 @@ def publish(
696
752
  check_only: bool,
697
753
  as_json: bool,
698
754
  ) -> None:
699
- """Put the project online: its commits on GitHub, its data in its store.
700
-
701
- URL names the repository on GitHub (github.com/OWNER/NAME), and is
702
- needed only the first time. The first publication makes the two
703
- choices no tool should make for you: who can read the project
704
- (--private or --public, when lc creates the repository), and where its
705
- data lives (--data). Both are asked once; every clone learns them. A
706
- repository that does not exist is created with a token from GH_TOKEN,
707
- GITHUB_TOKEN or `gh`.
708
-
709
- Every publication then sends, in this order, the bytes of what the
710
- commit names and the store lacks, git-annex's log of where they are,
711
- and the current branch. Where some bytes could not be sent, no commit
712
- is, and it exits 1: run it again to send the rest. Run it again
713
- whenever there is something new: with nothing to send it says so. A
714
- plain `git push` sends the commits without their bytes, and every
715
- clone then sees those results as missing.
755
+ """Publish the committed analysis to GitHub and its annexed outputs to the store.
756
+
757
+ Supply github.com/OWNER/NAME for a first publication. Choose --private or --public
758
+ to create the repository and --data to declare a store for annexed outputs.
759
+
760
+ Every rebuild input must travel in Git or have a reachable annex remote. --check
761
+ previews the committed dependency graph, including historical pins. A release
762
+ copies generated content, records its locations and pushes both refs atomically.
716
763
 
717
764
  A clone that did not choose the store confirms it once before it
718
765
  publishes, with --confirm-data: lc shows where the data goes and
@@ -738,10 +785,10 @@ def publish(
738
785
  )
739
786
  if as_json:
740
787
  click.echo(json.dumps(report.as_dict(), indent=2))
741
- elif not report.target:
742
- click.echo(_NOT_ONLINE.format(name=root.name))
743
788
  else:
744
789
  _render_publish_output(report, dry_run=check_only)
790
+ if not report.target:
791
+ click.echo(_NOT_ONLINE.format(name=root.name))
745
792
  if not report.ok or (check_only and not report.published):
746
793
  sys.exit(1)
747
794
 
@@ -803,13 +850,13 @@ def _render_materialize_output(
803
850
 
804
851
 
805
852
  def _counted(files: dict[str, str]) -> str:
806
- """Count files by what each is: `2 results, 1 input`."""
853
+ """Count the generated results and container images in a publication."""
807
854
  tally: dict[str, int] = {}
808
855
  for kind in files.values():
809
856
  tally[kind] = tally.get(kind, 0) + 1
810
857
  return ", ".join(
811
858
  f"{count} {kind}{'s' if count > 1 else ''}"
812
- for kind in ("result", "input", "file")
859
+ for kind in ("result", "image")
813
860
  if (count := tally.get(kind))
814
861
  )
815
862
 
@@ -824,6 +871,12 @@ def _render_publish_output(report: PublishReport, *, dry_run: bool) -> None:
824
871
 
825
872
  target, store = report.target, escape(report.store)
826
873
  lines = []
874
+ for path, checked in report.inputs.items():
875
+ if checked.reachable:
876
+ lines.append(f" {_DONE} {escape(path)} {escape(checked.key)}"
877
+ f" required by {escape(', '.join(checked.results))}")
878
+ lines.extend(f" {escape(remote)} {escape(' or '.join(addresses))}"
879
+ for remote, addresses in checked.reachable.items())
827
880
  if report.created:
828
881
  lines.append(f" {_DONE} created {target}, {report.visibility}")
829
882
  if report.declared:
@@ -868,10 +921,9 @@ def _render_publish_output(report: PublishReport, *, dry_run: bool) -> None:
868
921
  lines.append(f" {_WARN} {report.uncommitted} uncommitted change(s) are not published")
869
922
 
870
923
  if report.failed:
871
- verdict = (
872
- f"{_FAILED} {len(report.failed)} file(s) could not be sent, so no commit was — "
873
- "publishing again continues from here"
874
- )
924
+ verdict = f"{_FAILED} Release blocked. Review the files above."
925
+ elif not target:
926
+ verdict = ""
875
927
  elif dry_run:
876
928
  at = f"{report.branch} at {report.commit[:7]}"
877
929
  verdict = (
@@ -55,6 +55,15 @@ def configured_directory(path: Path) -> Path:
55
55
  raise ComputeError(f"cannot resolve compute root {expanded}: {exc}") from exc
56
56
 
57
57
 
58
+ def _overflow_uid() -> int:
59
+ try:
60
+ return int(Path("/proc/sys/kernel/overflowuid").read_text())
61
+ except (OSError, ValueError):
62
+ return 65534
63
+
64
+
65
+ _OVERFLOW_UID = _overflow_uid()
66
+
58
67
  def private_directory(path: Path, *, create: bool = False) -> Path:
59
68
  """Check an owner-only directory without following symlinks.
60
69
 
@@ -82,7 +91,12 @@ def private_directory(path: Path, *, create: bool = False) -> Path:
82
91
  info = component.lstat()
83
92
  if not stat.S_ISDIR(info.st_mode):
84
93
  raise ComputeError(f"compute connection path is not a plain directory: {component}")
85
- if info.st_uid not in (0, os.getuid()) or (
94
+ # A cluster filesystem that squashes ids shows its mount point as
95
+ # owned by the kernel's overflow id (Lustre /home and /scratch on
96
+ # Alliance clusters); no user holds that id, so it is trusted
97
+ # where neither group nor others can write.
98
+ squashed = info.st_uid == _OVERFLOW_UID and not info.st_mode & 0o022
99
+ if (info.st_uid not in (0, os.getuid()) and not squashed) or (
86
100
  info.st_mode & 0o022 and not (info.st_uid == 0 and info.st_mode & stat.S_ISVTX)
87
101
  ):
88
102
  raise ComputeError(f"compute connection path has an unsafe ancestor: {component}")
@@ -29,7 +29,7 @@ import shutil
29
29
  import sys
30
30
  import tarfile
31
31
  import tempfile
32
- from dataclasses import dataclass
32
+ from dataclasses import dataclass, replace
33
33
  from pathlib import Path
34
34
  from typing import Literal, cast
35
35
 
@@ -54,8 +54,7 @@ class Runtime:
54
54
 
55
55
  root: Path
56
56
  mode: Literal["direct", "containerized"]
57
- #: Where the project environment lives: ``.venv``, or the in-image
58
- #: ``.lightcone/venv``.
57
+ #: The private or published environment this execution uses.
59
58
  env_dir: Path
60
59
  #: ``podman``, ``podman-hpc`` or ``docker``; empty in direct mode.
61
60
  runtime: str = ""
@@ -69,6 +68,46 @@ class Runtime:
69
68
  #: store; a manifest's digest under Docker's containerd store.
70
69
  store_id: str = ""
71
70
 
71
+ #: Commands in execution worktrees must leave annex/LFS filters disabled.
72
+ staged: bool = False
73
+ #: Only git metadata needed by version-aware package build backends.
74
+ git_read: tuple[Path, ...] = ()
75
+
76
+ @property
77
+ def env(self) -> dict[str, str]:
78
+ """Tell uv which complete environment to use, including outside the tree."""
79
+ env = {**project.child_env(), "UV_PROJECT_ENVIRONMENT": str(self.env_dir)}
80
+ if self.staged:
81
+ env.update(dataset.plain_env(env))
82
+ return env
83
+
84
+ def at(self, root: Path) -> Runtime:
85
+ """Enter the resolved world from a run's pinned checkout.
86
+
87
+ The checkout is the commit the world was resolved at, whose tree
88
+ its owner found clean: it declares the same image.
89
+
90
+ Args:
91
+ root: Project root in the checkout.
92
+
93
+ Returns:
94
+ The runtime, with a private environment until one is prepared.
95
+ """
96
+ gitdir = Path(dataset._git(
97
+ [*dataset.PLAIN, "rev-parse", "--absolute-git-dir"], cwd=root,
98
+ ).strip())
99
+ common = (root / dataset._git(
100
+ [*dataset.PLAIN, "rev-parse", "--git-common-dir"], cwd=root,
101
+ ).strip()).resolve()
102
+ # A build backend may ask git for its version. Mount metadata only,
103
+ # never the common directory itself, which would expose every annex object.
104
+ metadata = (gitdir, *(common / name for name in
105
+ ("objects", "refs", "packed-refs", "shallow")))
106
+ return replace(
107
+ self, root=root, env_dir=project.env_dir(root), staged=True,
108
+ git_read=tuple(path for path in metadata if path.exists()),
109
+ )
110
+
72
111
  @property
73
112
  def supports_gpus(self) -> bool:
74
113
  """Whether this execution mode can expose the allocation's GPUs."""
@@ -244,7 +283,9 @@ def runtime_name(root: Path) -> str:
244
283
  return name
245
284
 
246
285
 
247
- def backend(runtime: Runtime, *, workdir: Path) -> sandbox.Backend:
286
+ def backend(
287
+ runtime: Runtime, *, workdir: Path, over: tuple[tuple[Path, Path], ...] = ()
288
+ ) -> sandbox.Backend:
248
289
  """Pick the exec boundary for a resolved runtime.
249
290
 
250
291
  The only *mode* branch above the sandbox seam, mirroring
@@ -257,6 +298,9 @@ def backend(runtime: Runtime, *, workdir: Path) -> sandbox.Backend:
257
298
  workdir: The folder the command runs in. A host mechanism runs it
258
299
  where the process is; a container is told, since the runtime
259
300
  decides where its command starts.
301
+ over: Files to show at other places, as ``OCIBackend.over``
302
+ takes them. Only a container can, so only a containerized
303
+ runtime is given any.
260
304
 
261
305
  Returns:
262
306
  The backend the exec goes through.
@@ -275,6 +319,7 @@ def backend(runtime: Runtime, *, workdir: Path) -> sandbox.Backend:
275
319
  image_id=runtime.store_id,
276
320
  workdir=workdir,
277
321
  user_flags=(*uid_flags(runtime.runtime), *pull),
322
+ over=over,
278
323
  )
279
324
 
280
325
 
@@ -282,10 +327,8 @@ def build(root: Path) -> tuple[Runtime, str]:
282
327
  """Converge the system-layer image, the whole of ``lc build``.
283
328
 
284
329
  Refuses a dirty tree before anything else: the archive is committed,
285
- ``dataset.save`` stages scoped but commits the whole index, and the
286
- tag derives from ``pyproject.toml`` — so the declaration must be
287
- committed before the image it defines, and nothing of the user's may
288
- be swept into the image commit.
330
+ and its tag derives from ``pyproject.toml``, so the declaration must
331
+ be committed before the image it defines.
289
332
 
290
333
  Args:
291
334
  root: The project root.
@@ -364,8 +407,8 @@ def image_state(root: Path) -> tuple[str, str, str]:
364
407
 
365
408
 
366
409
  def sync(root: Path, runtime: Runtime) -> list[str]:
367
- """Converge ``.lightcone/venv`` inside the image. The containerized twin
368
- of ``project.sync``.
410
+ """Converge the project environment inside the image. The containerized
411
+ twin of ``project.sync``.
369
412
 
370
413
  The one container run that gets a writable project mount — converge
371
414
  once, then execute without writing to the environment, the same
@@ -385,26 +428,59 @@ def sync(root: Path, runtime: Runtime) -> list[str]:
385
428
  Raises:
386
429
  ProjectError: If uv fails inside the container.
387
430
  """
431
+ return _check_call(_uv_in_image(root, runtime, "rw", project._SYNC_ARGS), cwd=root)
432
+
433
+
434
+ def current(runtime: Runtime) -> bool:
435
+ """Whether the project environment is what the lock says, whichever world
436
+ this is. uv's own read-only check (measured: it writes nothing, and
437
+ answers alike from another tree of the same lock).
438
+
439
+ Args:
440
+ runtime: The resolved runtime.
441
+
442
+ Returns:
443
+ False where uv would change anything in it, or there is none.
444
+ """
445
+ args = [*project._SYNC_ARGS, "--check"]
446
+ if runtime.mode == "direct":
447
+ argv = ["uv", *args, "--project", str(runtime.root)]
448
+ else:
449
+ argv = _uv_in_image(runtime.root, runtime, "ro", args)
450
+ return project._run(argv, cwd=runtime.root, env=runtime.env).returncode == 0
451
+
452
+
453
+ def _uv_in_image(root: Path, runtime: Runtime, access: str, args: list[str]) -> list[str]:
454
+ """A uv command against the project environment, run inside the image.
455
+
456
+ The environment is mounted on its own where it is not in the tree,
457
+ with *access*: a check never writes it.
458
+ """
388
459
  asked = project._run(["uv", "cache", "dir"], cwd=root)
389
460
  if asked.returncode != 0:
390
461
  raise ProjectError(f"`uv cache dir` failed:\n{asked.stderr.strip()}")
391
462
  cache = asked.stdout.strip()
392
- argv = [
463
+ env = runtime.env_dir
464
+ if access == "rw" and not env.is_relative_to(root):
465
+ env.mkdir(parents=True, exist_ok=True)
466
+ return [
393
467
  runtime.runtime, "run", "--rm", "--entrypoint", "",
394
468
  # Same reason as the exec boundary's flag: SELinux hosts refuse
395
469
  # bind reads from container_t, and relabeling user data is worse.
396
470
  "--security-opt", "label=disable",
397
471
  *uid_flags(runtime.runtime),
398
472
  "-v", f"{root}:{root}:rw",
473
+ *(["-v", f"{env}:{env}:{access}"] if not env.is_relative_to(root) else []),
399
474
  "-v", f"{cache}:{cache}:rw",
475
+ *(arg for path in runtime.git_read for arg in ("-v", f"{path}:{path}:ro")),
476
+ *(f"--env={k}={v}" for k, v in dataset.plain_env({}).items()),
400
477
  "--env", f"UV_CACHE_DIR={cache}",
401
- "--env", f"UV_PROJECT_ENVIRONMENT={runtime.env_dir}",
478
+ "--env", f"UV_PROJECT_ENVIRONMENT={env}",
402
479
  "-w", str(root),
403
480
  runtime.store_id,
404
- # The same sync `project.sync` runs, spelled once for both modes.
405
- "uv", *project._SYNC_ARGS, "--project", str(root),
481
+ # The same uv `project.sync` runs, spelled once for both modes.
482
+ "uv", *args, "--project", str(root),
406
483
  ] # fmt: skip
407
- return _check_call(argv, cwd=root)
408
484
 
409
485
 
410
486
  def converge(runtime: Runtime) -> list[str]:
@@ -422,7 +498,7 @@ def converge(runtime: Runtime) -> list[str]:
422
498
  Whatever uv warned about.
423
499
  """
424
500
  if runtime.mode == "direct":
425
- return project.sync(runtime.root)
501
+ return project.sync(runtime.root, runtime.env)
426
502
  return sync(runtime.root, runtime)
427
503
 
428
504
 
@@ -643,6 +719,23 @@ def _build(root: Path, runtime: str, tag: str, archive: Path) -> None:
643
719
  )
644
720
 
645
721
 
722
+ def archives(root: Path) -> list[str]:
723
+ """Each image archive the dataset's ``.datalad/config`` names, from the
724
+ project root, where :func:`_build` puts one (:func:`image.archive_path`).
725
+ """
726
+ listed = dataset._ask(
727
+ ["config", "-z", "-f", ".datalad/config", "--get-regexp",
728
+ r"^datalad\.containers\.lc-env-[0-9a-f]{16}\.image$"],
729
+ cwd=root,
730
+ ) or ""
731
+ found = []
732
+ for entry in filter(None, listed.split("\0")):
733
+ setting, _, path = entry.partition("\n")
734
+ if Path(path) == image.archive_path(Path(), setting.split(".")[2]):
735
+ found.append(path)
736
+ return found
737
+
738
+
646
739
  def _build_failure(tag: str, stderr: str) -> str:
647
740
  """Turn a build log into the refusal it means. Never the raw log."""
648
741
  for line in stderr.splitlines():