stringforge 0.1.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.
@@ -0,0 +1,634 @@
1
+ # Copyright 2026 Andreas Schachner
2
+ #
3
+ # This file is part of StringForge.
4
+ #
5
+ # StringForge is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+
10
+ r"""
11
+ Vulcan: production vacuum-forging pipeline for StringForge.
12
+
13
+ Vulcan is the high-volume, cluster-side, append-only writer that
14
+ forges vacuum-search output into a HuggingFace dataset repo. It is
15
+ the production counterpart to
16
+ :class:`stringforge.vacua_writer.VacuaWriter` -- VacuaWriter
17
+ *designates* curated vacua into ``vacua_vault``, Vulcan *forges*
18
+ production runs into a separate, ML-friendly repo.
19
+
20
+ Architecture summary:
21
+
22
+ * Worker code calls :meth:`Vulcan.write` to stage validated parquet
23
+ shards under ``{staging_dir}/pending/``. No HuggingFace I/O.
24
+ * A separate sync tier (:meth:`Vulcan.sync`, the ``vulcan sync`` CLI,
25
+ or a cron job on a head node) batches pending shards into one
26
+ :func:`huggingface_hub.HfApi.create_commit` call per
27
+ ``max_batch``-sized chunk (default 500 files per commit),
28
+ respecting HF's 100-commit-per-hour cap via
29
+ :mod:`~stringforge.vulcan.ratelimit`.
30
+ """
31
+ from __future__ import annotations
32
+
33
+ import os
34
+ from pathlib import Path
35
+ from typing import Any, Callable, Mapping, Optional, Sequence, Union
36
+
37
+ import pandas as pd
38
+
39
+ from . import schema as _schema_module
40
+ from .certify import (
41
+ CertifyResult,
42
+ CertRow,
43
+ StabilityRecord,
44
+ build_jaxvacua_certifier,
45
+ check_endpoint_stability,
46
+ certify_shard,
47
+ )
48
+ from .community import (
49
+ CommunityGateResult,
50
+ dedup_key,
51
+ review_submission,
52
+ )
53
+ from .ml_view import (
54
+ DEFAULT_FRACTIONS,
55
+ DEFAULT_SPLITS,
56
+ FeatureSpec,
57
+ VulcanMLView,
58
+ assign_split,
59
+ )
60
+ from .ratelimit import DEFAULT_BUDGET, DEFAULT_WINDOW_S
61
+ from .reader import CATALOG_COLUMNS, DEFAULT_CACHE_SIZE, VulcanReader
62
+ from .runid import DEFAULT_TEMPLATE, render as render_run_id
63
+ from .snapshot import (
64
+ MANIFEST_FILENAME,
65
+ SnapshotManifest,
66
+ build_manifest,
67
+ freeze_snapshot,
68
+ )
69
+ from .sync import (
70
+ DEFAULT_MAX_BATCH,
71
+ DEFAULT_MAX_RETRIES,
72
+ SyncReport,
73
+ remaining_budget,
74
+ sync_pending,
75
+ )
76
+ from .verifier import (
77
+ CANONICAL_CHECK_NAMES,
78
+ FULL_CASCADE_CHECKS,
79
+ VerifierRegistry,
80
+ VerifierSpec,
81
+ verifier_id,
82
+ )
83
+ from .writer import (
84
+ FAILED_DIRNAME,
85
+ PENDING_DIRNAME,
86
+ SYNCED_DIRNAME,
87
+ StagedShard,
88
+ list_pending,
89
+ write_shard,
90
+ )
91
+
92
+ __all__ = (
93
+ "Vulcan",
94
+ "VulcanReader",
95
+ "VulcanMLView",
96
+ "FeatureSpec",
97
+ "StagedShard",
98
+ "SyncReport",
99
+ "VerifierSpec",
100
+ "VerifierRegistry",
101
+ "verifier_id",
102
+ "StabilityRecord",
103
+ "check_endpoint_stability",
104
+ "SnapshotManifest",
105
+ "build_manifest",
106
+ "freeze_snapshot",
107
+ "CertRow",
108
+ "CertifyResult",
109
+ "certify_shard",
110
+ "build_jaxvacua_certifier",
111
+ "CommunityGateResult",
112
+ "dedup_key",
113
+ "review_submission",
114
+ "resolve_staging_dir",
115
+ )
116
+
117
+
118
+ def resolve_staging_dir(explicit: Optional[Union[str, Path]] = None) -> Path:
119
+ r"""
120
+ **Description:**
121
+ Resolve the Vulcan staging directory used by workers and the sync
122
+ tier.
123
+
124
+ Resolution order -- uses whichever stage succeeds first:
125
+
126
+ 1. ``explicit`` argument when provided.
127
+ 2. ``STRINGFORGE_VULCAN_STAGING_DIR`` environment variable.
128
+ 3. ``<stringforge_repo_root>/vulcan_staging/`` when running from a
129
+ stringforge source checkout.
130
+ 4. ``<stringforge.data_dir>/vulcan_staging/``.
131
+
132
+ The directory is **not** created here; the writer / sync helpers
133
+ materialise its ``pending/``, ``synced/`` and ``failed/`` subdirs
134
+ on first use via
135
+ :func:`~stringforge.vulcan.writer.ensure_staging_layout`.
136
+
137
+ Args:
138
+ explicit: An explicit path that overrides every other source.
139
+
140
+ Returns:
141
+ Path: Absolute path to the chosen staging directory.
142
+ """
143
+ if explicit is not None:
144
+ return Path(explicit).resolve()
145
+
146
+ env = os.environ.get("STRINGFORGE_VULCAN_STAGING_DIR")
147
+ if env:
148
+ return Path(env).resolve()
149
+
150
+ # Try repo-root detection, falling through to the data-dir.
151
+ try:
152
+ from stringforge.cy_io import _find_stringforge_repo_root # type: ignore
153
+ root = _find_stringforge_repo_root()
154
+ except Exception:
155
+ root = None
156
+ if root is not None:
157
+ return (Path(root) / "vulcan_staging").resolve()
158
+
159
+ try:
160
+ from stringforge import data_dir as _data_dir
161
+ except ImportError:
162
+ _data_dir = os.environ.get(
163
+ "STRINGFORGE_DATA_DIR",
164
+ str(Path.home() / ".stringforge_cache"),
165
+ )
166
+ return (Path(_data_dir) / "vulcan_staging").resolve()
167
+
168
+
169
+ class Vulcan:
170
+ r"""
171
+ **Description:**
172
+ Per-repo handle for the production vacuum-forging pipeline.
173
+
174
+ A ``Vulcan`` instance is bound to a single HuggingFace repo and a
175
+ single local staging directory. Workers call :meth:`write` to
176
+ stage validated shards; a head node (cron job, daemon, or
177
+ ``python -m stringforge.vulcan sync``) calls :meth:`sync` to push
178
+ them to the Hub. Multiple ``Vulcan`` instances may co-exist in
179
+ the same process to write to different repos -- useful for
180
+ cross-project workflows where different paper drafts target
181
+ different production repos.
182
+
183
+ See :class:`stringforge.vacua_writer.VacuaWriter` for the curated
184
+ counterpart that targets the paper-aligned ``vacua_vault`` repo.
185
+
186
+ Args:
187
+ repo: ``"user/repo"`` on HuggingFace. Required; no global
188
+ default. Override per-call via :meth:`sync` with
189
+ ``repo=...``.
190
+ staging_dir: Local staging root. Resolution order is
191
+ documented in :func:`resolve_staging_dir`.
192
+ run_id_template: Either a format string with ``{name}`` /
193
+ ``{name?}`` placeholders, a callable returning the
194
+ run_id, or ``None`` for the UUID fallback. See
195
+ :mod:`~stringforge.vulcan.runid`.
196
+ project: Default ``{project}`` value for the run-id template.
197
+ token: HuggingFace write token. Falls back to
198
+ ``STRINGFORGE_VULCAN_TOKEN`` then ``HF_TOKEN`` at sync
199
+ time.
200
+ budget: Commits-per-hour ceiling. Defaults to 90 (10-commit
201
+ margin below HuggingFace's 100/hour cap).
202
+ window_s: Rolling-window length, in seconds, over which
203
+ ``budget`` applies. Defaults to 3600 s.
204
+ extra_kwargs: Default substitutions for the run-id template
205
+ applied to every :meth:`write` call. Per-call
206
+ ``extra_kwargs=`` arguments take precedence.
207
+
208
+ Raises:
209
+ ValueError: When ``repo`` is empty.
210
+ """
211
+
212
+ def __init__(
213
+ self,
214
+ *,
215
+ repo: str,
216
+ staging_dir: Optional[Union[str, Path]] = None,
217
+ run_id_template: Optional[Union[str, Callable[..., str]]] = DEFAULT_TEMPLATE,
218
+ project: str = "",
219
+ token: Optional[str] = None,
220
+ budget: int = DEFAULT_BUDGET,
221
+ window_s: float = DEFAULT_WINDOW_S,
222
+ extra_kwargs: Optional[Mapping[str, Any]] = None,
223
+ ) -> None:
224
+ if not repo:
225
+ raise ValueError("Vulcan requires a HuggingFace repo (e.g. 'user/repo').")
226
+ self.repo = str(repo)
227
+ self.staging_dir = resolve_staging_dir(staging_dir)
228
+ self.run_id_template = run_id_template
229
+ self.project = str(project)
230
+ self._token = token
231
+ self.budget = int(budget)
232
+ self.window_s = float(window_s)
233
+ self.extra_kwargs = dict(extra_kwargs) if extra_kwargs else {}
234
+
235
+ # ── factory ────────────────────────────────────────────────────
236
+
237
+ @classmethod
238
+ def from_env(
239
+ cls,
240
+ *,
241
+ repo: Optional[str] = None,
242
+ run_id_template: Optional[Union[str, Callable[..., str]]] = DEFAULT_TEMPLATE,
243
+ **kwargs: Any,
244
+ ) -> "Vulcan":
245
+ r"""
246
+ **Description:**
247
+ Construct a :class:`Vulcan` from ``STRINGFORGE_VULCAN_*``
248
+ environment variables.
249
+
250
+ Environment variables read:
251
+
252
+ * ``STRINGFORGE_VULCAN_REPO`` -- target HF repo.
253
+ * ``STRINGFORGE_VULCAN_PROJECT`` -- default ``{project}``
254
+ substitution.
255
+ * ``STRINGFORGE_VULCAN_BUDGET`` -- commits/hour ceiling.
256
+ * ``STRINGFORGE_VULCAN_TOKEN`` -- HuggingFace write token.
257
+
258
+ Explicit keyword arguments take precedence over the
259
+ environment.
260
+
261
+ Args:
262
+ repo: Optional override for ``STRINGFORGE_VULCAN_REPO``.
263
+ run_id_template: Override for the run-id template; see
264
+ :class:`Vulcan`'s constructor.
265
+ **kwargs: Forwarded to :class:`Vulcan`.
266
+
267
+ Returns:
268
+ Vulcan: A configured instance.
269
+
270
+ Raises:
271
+ ValueError: When ``repo`` is unset and
272
+ ``STRINGFORGE_VULCAN_REPO`` is empty, or when
273
+ ``STRINGFORGE_VULCAN_BUDGET`` is non-empty but not a
274
+ valid integer.
275
+ """
276
+ repo = repo or os.environ.get("STRINGFORGE_VULCAN_REPO")
277
+ if not repo:
278
+ raise ValueError(
279
+ "Vulcan.from_env: no repo specified. Set "
280
+ "STRINGFORGE_VULCAN_REPO or pass repo=... explicitly."
281
+ )
282
+ project_kw = kwargs.pop("project", None)
283
+ project = project_kw if project_kw is not None else os.environ.get(
284
+ "STRINGFORGE_VULCAN_PROJECT", "",
285
+ )
286
+ budget_env = (os.environ.get("STRINGFORGE_VULCAN_BUDGET") or "").strip()
287
+ if budget_env:
288
+ try:
289
+ env_budget = int(budget_env)
290
+ except ValueError:
291
+ raise ValueError(
292
+ f"STRINGFORGE_VULCAN_BUDGET must be an integer; got "
293
+ f"{budget_env!r}"
294
+ ) from None
295
+ else:
296
+ env_budget = DEFAULT_BUDGET
297
+ budget_kw = kwargs.pop("budget", None)
298
+ budget = budget_kw if budget_kw is not None else env_budget
299
+ token_kw = kwargs.pop("token", None)
300
+ token = token_kw if token_kw is not None else os.environ.get("STRINGFORGE_VULCAN_TOKEN")
301
+ return cls(
302
+ repo=repo,
303
+ run_id_template=run_id_template,
304
+ project=project,
305
+ budget=budget,
306
+ token=token,
307
+ **kwargs,
308
+ )
309
+
310
+ def __repr__(self) -> str:
311
+ return (
312
+ f"Vulcan(repo={self.repo!r}, staging_dir={str(self.staging_dir)!r}, "
313
+ f"project={self.project!r}, budget={self.budget})"
314
+ )
315
+
316
+ # ── worker-side ────────────────────────────────────────────────
317
+
318
+ def render_run_id(self, **substitutions: Any) -> str:
319
+ r"""
320
+ **Description:**
321
+ Render a ``run_id`` using the instance's template, the
322
+ instance-wide ``extra_kwargs`` defaults, and the supplied
323
+ per-call substitutions.
324
+
325
+ Per-call substitutions take precedence over instance defaults.
326
+
327
+ Args:
328
+ **substitutions: Values to interpolate into the template.
329
+
330
+ Returns:
331
+ str: A slug-safe run identifier.
332
+ """
333
+ env: dict[str, Any] = dict(self.extra_kwargs)
334
+ env.update(substitutions)
335
+ return render_run_id(
336
+ self.run_id_template,
337
+ project=self.project,
338
+ **env,
339
+ )
340
+
341
+ def write(
342
+ self,
343
+ df: pd.DataFrame,
344
+ *,
345
+ geometry: Mapping[str, Any],
346
+ run_id: Optional[str] = None,
347
+ tadpole_charge: Optional[int] = None,
348
+ solver: Optional[Mapping[str, Any]] = None,
349
+ provenance: Optional[Mapping[str, Any]] = None,
350
+ extra_kwargs: Optional[Mapping[str, Any]] = None,
351
+ ) -> StagedShard:
352
+ r"""
353
+ **Description:**
354
+ Stage a vacuum batch as a parquet shard in ``pending/``.
355
+
356
+ This method never contacts HuggingFace. Workers can call
357
+ it safely from any cluster node, including nodes with no
358
+ outbound network. Pending shards are picked up by
359
+ :meth:`sync` (or the ``vulcan sync`` CLI) and uploaded
360
+ in batches.
361
+
362
+ Args:
363
+ df: Per-vacuum DataFrame. Must carry the vault-floor
364
+ columns (``flux``, ``moduli_re``, ``moduli_im``,
365
+ ``tau_re``, ``tau_im``). The writer is authoritative
366
+ on identity: ``run_id``, ``geometry_id`` and the
367
+ geometry-key columns are unconditionally overwritten
368
+ with the values resolved here. ``tadpole_charge`` and
369
+ ``created_at`` are filled in only when absent from
370
+ ``df`` (the caller may pre-populate them).
371
+ geometry: ``{h11, h12, ks_id, triang_id, conifold_id,
372
+ cicy_id}`` mapping. Missing keys are filled with the
373
+ ``-1`` sentinel. ``h11``, ``h12`` are interpreted in
374
+ mirror (jaxvacua / lcs_tree) convention, matching
375
+ :class:`~stringforge.vacua_writer.LCSDatabase`.
376
+ run_id: Override the rendered run_id. Defaults to
377
+ :meth:`render_run_id` driven by the geometry-key
378
+ substitutions ``{h11, h12, ks_id, triang_id,
379
+ conifold_id, cicy_id}``, plus ``solver`` (when
380
+ ``solver['name']`` is supplied), ``seed`` (when
381
+ ``provenance['seed']`` is supplied), and any
382
+ instance- or call-level ``extra_kwargs``.
383
+ tadpole_charge: Production-tier required column. May be
384
+ supplied here or pre-populated on ``df``; filled in
385
+ only when absent.
386
+ solver: ``{name, config_hash, ...}`` -- embedded in the
387
+ parquet kv-metadata.
388
+ provenance: ``{git_sha, seed, wall_clock_s, ...}`` --
389
+ embedded alongside ``solver``.
390
+ extra_kwargs: Extra substitutions for the run-id template
391
+ (e.g. a custom ``{variant}`` placeholder).
392
+
393
+ Returns:
394
+ StagedShard: Reference to the on-disk parquet + sidecar
395
+ pair and the canonical HF-repo-relative path.
396
+ """
397
+ substitutions: dict[str, Any] = {
398
+ "h11": geometry.get("h11"),
399
+ "h12": geometry.get("h12"),
400
+ "ks_id": geometry.get("ks_id"),
401
+ "triang_id": geometry.get("triang_id"),
402
+ "conifold_id": geometry.get("conifold_id"),
403
+ "cicy_id": geometry.get("cicy_id"),
404
+ }
405
+ if solver is not None and "name" in solver:
406
+ substitutions["solver"] = solver["name"]
407
+ if provenance is not None and "seed" in provenance:
408
+ substitutions["seed"] = provenance["seed"]
409
+ if extra_kwargs:
410
+ substitutions.update(extra_kwargs)
411
+
412
+ rid = run_id if run_id is not None else self.render_run_id(**substitutions)
413
+ return write_shard(
414
+ df,
415
+ staging_dir=self.staging_dir,
416
+ run_id=rid,
417
+ geometry=geometry,
418
+ tadpole_charge=tadpole_charge,
419
+ solver=solver,
420
+ provenance=provenance,
421
+ )
422
+
423
+ # ── observability ──────────────────────────────────────────────
424
+
425
+ def list_pending(self) -> list[StagedShard]:
426
+ r"""
427
+ **Description:**
428
+ Return shards currently awaiting sync from this Vulcan's
429
+ staging directory.
430
+
431
+ Returns:
432
+ list[StagedShard]: One entry per pending shard.
433
+ """
434
+ return list_pending(self.staging_dir)
435
+
436
+ def remaining_budget(self) -> int:
437
+ r"""
438
+ **Description:**
439
+ Report how many commits are still available in the current
440
+ rolling window for this Vulcan's staging directory.
441
+
442
+ Returns:
443
+ int: Non-negative slot count.
444
+ """
445
+ return remaining_budget(
446
+ self.staging_dir, budget=self.budget, window_s=self.window_s,
447
+ )
448
+
449
+ # ── read path ──────────────────────────────────────────────────
450
+
451
+ def reader(self, *, cache_size: int = DEFAULT_CACHE_SIZE) -> "VulcanReader":
452
+ r"""
453
+ **Description:**
454
+ Return a :class:`VulcanReader` bound to this Vulcan's local
455
+ ``synced/`` directory.
456
+
457
+ Args:
458
+ cache_size: LRU capacity passed through to the reader.
459
+
460
+ Returns:
461
+ VulcanReader: A local-source reader.
462
+ """
463
+ return VulcanReader.from_local(self.staging_dir, cache_size=cache_size)
464
+
465
+ def query(self, **filters: Any) -> pd.DataFrame:
466
+ r"""
467
+ **Description:**
468
+ Convenience wrapper around :meth:`VulcanReader.query` using
469
+ this Vulcan's local ``synced/`` directory.
470
+
471
+ Args:
472
+ **filters: Forwarded to :meth:`VulcanReader.query`.
473
+
474
+ Returns:
475
+ pd.DataFrame: Matching rows.
476
+ """
477
+ return self.reader().query(**filters)
478
+
479
+ def fetch_run(self, run_id: str) -> pd.DataFrame:
480
+ r"""
481
+ **Description:**
482
+ Convenience wrapper around :meth:`VulcanReader.fetch_run`
483
+ using this Vulcan's local ``synced/`` directory.
484
+
485
+ Args:
486
+ run_id: Identifier carried on each row of the target
487
+ shards.
488
+
489
+ Returns:
490
+ pd.DataFrame: Concatenated rows.
491
+ """
492
+ return self.reader().fetch_run(run_id)
493
+
494
+ def ml_view(
495
+ self,
496
+ *,
497
+ fractions: Optional[Sequence[float]] = None,
498
+ splits: Optional[Sequence[str]] = None,
499
+ salt: str = "",
500
+ feature_spec: Optional["FeatureSpec"] = None,
501
+ ) -> "VulcanMLView":
502
+ r"""
503
+ **Description:**
504
+ Return a :class:`VulcanMLView` backed by this Vulcan's local
505
+ ``synced/`` directory.
506
+
507
+ Args:
508
+ fractions: Per-split fractions; defaults to
509
+ :data:`~stringforge.vulcan.ml_view.DEFAULT_FRACTIONS`.
510
+ splits: Split labels; defaults to
511
+ :data:`~stringforge.vulcan.ml_view.DEFAULT_SPLITS`.
512
+ salt: Optional salt for cross-validation folds.
513
+ feature_spec: Default :class:`FeatureSpec`.
514
+
515
+ Returns:
516
+ VulcanMLView: A ready-to-use ML view.
517
+ """
518
+ return VulcanMLView(
519
+ self.reader(),
520
+ fractions=fractions or DEFAULT_FRACTIONS,
521
+ splits=splits or DEFAULT_SPLITS,
522
+ salt=salt,
523
+ feature_spec=feature_spec,
524
+ )
525
+
526
+ def freeze_snapshot(
527
+ self,
528
+ *,
529
+ tag: str,
530
+ created_at: str,
531
+ repo: Optional[str] = None,
532
+ require_fully_certified: bool = True,
533
+ dry_run: bool = False,
534
+ **kwargs: Any,
535
+ ) -> "SnapshotManifest":
536
+ r"""
537
+ **Description:**
538
+ Freeze a citeable snapshot of this Vulcan's local ``synced/``
539
+ view (convenience wrapper around
540
+ :func:`stringforge.vulcan.snapshot.freeze_snapshot`).
541
+
542
+ Args:
543
+ tag: Immutable git tag to create (e.g. ``"v2026.06"``).
544
+ created_at: UTC timestamp string (caller-supplied for
545
+ determinism).
546
+ repo: HuggingFace repo to tag; defaults to this Vulcan's
547
+ ``repo``. Ignored when ``dry_run``.
548
+ require_fully_certified: Refuse to tag a not-fully-certified
549
+ snapshot (default ``True``).
550
+ dry_run: Build the manifest only; no network call, no tag.
551
+ **kwargs: Forwarded to
552
+ :func:`~stringforge.vulcan.snapshot.freeze_snapshot`
553
+ (e.g. ``local_manifest_dir``, ``token``, ``message``).
554
+
555
+ Returns:
556
+ SnapshotManifest: The manifest.
557
+ """
558
+ token = kwargs.pop("token", None)
559
+ if token is None:
560
+ token = self._token
561
+ if token is None:
562
+ token = os.environ.get(
563
+ "STRINGFORGE_VULCAN_TOKEN", os.environ.get("HF_TOKEN"),
564
+ )
565
+ return freeze_snapshot(
566
+ self.reader(),
567
+ tag=tag,
568
+ created_at=created_at,
569
+ repo=repo or self.repo,
570
+ token=token,
571
+ require_fully_certified=require_fully_certified,
572
+ dry_run=dry_run,
573
+ **kwargs,
574
+ )
575
+
576
+ # ── sync tier ──────────────────────────────────────────────────
577
+
578
+ def sync(
579
+ self,
580
+ *,
581
+ repo: Optional[str] = None,
582
+ token: Optional[str] = None,
583
+ budget: Optional[int] = None,
584
+ max_batch: int = DEFAULT_MAX_BATCH,
585
+ max_retries: int = DEFAULT_MAX_RETRIES,
586
+ create_pr: bool = False,
587
+ revision: Optional[str] = None,
588
+ commit_prefix: str = "vulcan: forge",
589
+ dry_run: bool = False,
590
+ ) -> SyncReport:
591
+ r"""
592
+ **Description:**
593
+ Drain ``pending/`` into HuggingFace commits.
594
+
595
+ Wraps :func:`~stringforge.vulcan.sync.sync_pending` with this
596
+ instance's repo, staging directory, token, budget, and
597
+ window.
598
+
599
+ Args:
600
+ repo: Override the instance's target repo.
601
+ token: HuggingFace write token; falls back to
602
+ ``STRINGFORGE_VULCAN_TOKEN`` then ``HF_TOKEN``.
603
+ budget: Override the instance's commits-per-hour ceiling.
604
+ max_batch: Maximum files per HuggingFace commit.
605
+ max_retries: Per-batch retry budget on 429/503 responses.
606
+ create_pr: Open PRs instead of pushing to the default
607
+ branch.
608
+ revision: HF revision name; defaults to the repo's default
609
+ branch.
610
+ commit_prefix: Commit-message prefix used for each batch.
611
+ dry_run: Skip the network call (still reserves budget
612
+ slots).
613
+
614
+ Returns:
615
+ SyncReport: Summary of the work done.
616
+ """
617
+ effective_token = token if token is not None else self._token
618
+ if effective_token is None:
619
+ effective_token = os.environ.get(
620
+ "STRINGFORGE_VULCAN_TOKEN", os.environ.get("HF_TOKEN"),
621
+ )
622
+ return sync_pending(
623
+ self.staging_dir,
624
+ repo_id=repo or self.repo,
625
+ token=effective_token,
626
+ budget=budget if budget is not None else self.budget,
627
+ window_s=self.window_s,
628
+ max_batch=max_batch,
629
+ max_retries=max_retries,
630
+ create_pr=create_pr,
631
+ revision=revision,
632
+ commit_prefix=commit_prefix,
633
+ dry_run=dry_run,
634
+ )