@orkestrel/scaffold 0.0.117 → 0.0.119

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.
@@ -1492,8 +1492,9 @@ function stageBytes(host, root, destinations) {
1492
1492
  * host root is not vacant, the checkout does not carry every vendored path, two
1493
1493
  * vendored files claim one storage name, a vendored file is not a plain file
1494
1494
  * within the artifact ceiling, published guides are unreadable, a staged
1495
- * collision's owner set is not a subset of its published owner set, the inventory is absent without
1496
- * `establish: true`, or the staged manifest does not read back.
1495
+ * collision's owner set is not a subset of its published owner set, a
1496
+ * `SURFACE_TRANSFERS` entry is spent because its keeper alone claims the name, the
1497
+ * inventory is absent without `establish: true`, or the staged manifest does not read back.
1497
1498
  * @throws `ScaffoldError('WRITE', …)` when a staged file or the manifest cannot
1498
1499
  * be written.
1499
1500
  *
@@ -1529,7 +1530,10 @@ function stageBytes(host, root, destinations) {
1529
1530
  * the canon and reference files for reading. Every catalog package must have a
1530
1531
  * guide in the discovered membership before the host is written.
1531
1532
  * Copied guides must carry no collision whose name and exact owner set the
1532
- * committed inventory lacks. An absent inventory requires `establish: true`;
1533
+ * committed inventory lacks. A `SURFACE_TRANSFERS` entry that another guide claims
1534
+ * admits its keeper beside the recorded owners, or beside the one owner of a name
1535
+ * the inventory lacks, and the staged surface records that keeper whether or not
1536
+ * its guide is mirrored. An absent inventory requires `establish: true`;
1533
1537
  * an inventory without a valid recorded Surface is refused.
1534
1538
  * Everything downstream — the missing-path refusal, the
1535
1539
  * storage collision guard, the sort, the digests, and the root inventory — reads
@@ -1670,29 +1674,48 @@ function stageHost(checkout, host, options) {
1670
1674
  digest
1671
1675
  };
1672
1676
  });
1673
- const collisions = readSurfaceCollisions((0, node_path.join)(root, "guides"));
1674
- const growth = published === void 0 ? [] : (0, _src_core.compareSurfaceCollisions)([...collisions].map(([name, owners]) => ({
1677
+ const claims = readSurfaceClaims((0, node_path.join)(root, "guides"));
1678
+ const claimants = Map.groupBy(claims.flatMap(({ owner, names }) => names.map((name) => ({
1675
1679
  name,
1676
- owners
1677
- })), [...published].map(([name, owners]) => ({
1680
+ owner
1681
+ }))), ({ name }) => name);
1682
+ const transfers = _src_core.SURFACE_TRANSFERS.map((transfer) => {
1683
+ const owners = new Set(claimants.get(transfer.name)?.map(({ owner }) => owner));
1684
+ return {
1685
+ ...transfer,
1686
+ claimed: owners.has(transfer.keeper),
1687
+ givers: [...owners].filter((owner) => owner !== transfer.keeper).sort()
1688
+ };
1689
+ });
1690
+ const spent = transfers.filter(({ claimed, givers }) => claimed && givers.length === 0).map(({ name, keeper, item }) => `${name} to ${keeper} under item ${item}`);
1691
+ if (spent.length > 0) throw new _src_core.ScaffoldError("TARGET", `Surface transfers are spent, so remove them from SURFACE_TRANSFERS: ${spent.join("; ")}`, {
1692
+ checkout: source,
1693
+ host: root,
1694
+ transfers: spent
1695
+ });
1696
+ const active = transfers.filter(({ givers }) => givers.length > 0);
1697
+ const collisions = (0, _src_core.collectSurfaceCollisions)([...claims, ...active.map(({ name, keeper }) => ({
1698
+ owner: keeper,
1699
+ names: [name]
1700
+ }))]);
1701
+ const growth = published === void 0 ? [] : (0, _src_core.compareSurfaceCollisions)(collisions, [...new Map([...published, ...active.map(({ name, keeper, givers }) => [name, [...published.get(name) ?? (givers.length === 1 ? givers : []), keeper]])])].map(([name, owners]) => ({
1678
1702
  name,
1679
1703
  owners
1680
- }))).filter(({ standing }) => standing === "error").map(({ name, owners }) => `${name} staged (${owners.join(", ")}), recorded (${published.get(name)?.join(", ") ?? "absent"})`);
1704
+ }))).filter(({ standing }) => standing === "error").map(({ name, owners }) => {
1705
+ const keeper = active.find((transfer) => transfer.name === name)?.keeper;
1706
+ return `${name} staged (${owners.join(", ")}), recorded (${published.get(name)?.join(", ") ?? "absent"})${keeper === void 0 ? "" : `, transferred to ${keeper}`}`;
1707
+ });
1681
1708
  if (growth.length > 0) throw new _src_core.ScaffoldError("TARGET", `Staged Surface collisions differ from the inventory: ${growth.join("; ")}`, {
1682
1709
  checkout: source,
1683
1710
  host: root,
1684
1711
  baseline,
1685
1712
  collisions: growth
1686
1713
  });
1687
- const surface = [...collisions].map(([name, owners]) => ({
1688
- name,
1689
- owners
1690
- }));
1691
1714
  const manifest = {
1692
1715
  entries,
1693
1716
  roots,
1694
- surface,
1695
- digest: computeManifestDigest(entries, roots, surface)
1717
+ surface: collisions,
1718
+ digest: computeManifestDigest(entries, roots, collisions)
1696
1719
  };
1697
1720
  const metadata = resolveContainedPath(root, MANIFEST_NAME);
1698
1721
  if (metadata === void 0) throw new _src_core.ScaffoldError("INVALID", `Host manifest leaves its root at ${root}`, { host: root });
@@ -1770,15 +1793,16 @@ function readSurfaceModule(loader = (0, node_module.createRequire)(require("url"
1770
1793
  * @example
1771
1794
  * ```ts
1772
1795
  * import { readSurfaceGuide } from '@orkestrel/scaffold/server'
1773
- * readSurfaceGuide('# Sample', 'sample', 'live guides/sample.md') // { owner: 'sample', names: [] }
1796
+ * readSurfaceGuide('# Sample', 'sample', 'live guides/sample.md') // { owner: 'sample', names: [], signatures: new Map() }
1774
1797
  * ```
1775
1798
  */
1776
1799
  function readSurfaceGuide(text, owner, source, loader) {
1777
1800
  const guide = readSurfaceModule(loader);
1778
- const parsed = (0, _orkestrel_contract.attempt)(() => guide.createGuide(text).surface().map(({ name }) => name));
1801
+ const parsed = (0, _orkestrel_contract.attempt)(() => guide.createGuide(text).surface());
1779
1802
  if (parsed.success) return {
1780
1803
  owner,
1781
- names: parsed.value
1804
+ names: parsed.value.map(({ name }) => name),
1805
+ signatures: new Map(parsed.value.flatMap(({ name, signature }) => (0, _orkestrel_contract.isString)(signature) ? [[name, signature]] : []))
1782
1806
  };
1783
1807
  if (!guide.isGuideError(parsed.error)) throw parsed.error;
1784
1808
  throw new _src_core.ScaffoldError("TARGET", `Surface guide for ${JSON.stringify(owner.slice(0, 512))} from ${JSON.stringify(source.slice(0, 512))} was refused: ${parsed.error.message}`, {
@@ -1867,6 +1891,7 @@ function readSurfaceCandidate(root, loader) {
1867
1891
  return {
1868
1892
  owner,
1869
1893
  names: [.../* @__PURE__ */ new Set([...guide?.names ?? [], ...Object.values(exports).flat()])].sort(),
1894
+ signatures: guide?.signatures ?? /* @__PURE__ */ new Map(),
1870
1895
  conflicts: (0, _src_core.collectSurfaceConflicts)(owner, exports)
1871
1896
  };
1872
1897
  }