@ttsc/unplugin 0.36.4 → 0.37.1

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 (25) hide show
  1. package/lib/core/transform/clock/filesystemListingDevices.d.cts +24 -0
  2. package/lib/core/transform/clock/filesystemListingDevices.d.mts +24 -0
  3. package/lib/core/transform/clock/filesystemListingDevices.d.ts +24 -0
  4. package/lib/core/transform/clock/filesystemListingDevices.js +36 -0
  5. package/lib/core/transform/clock/filesystemListingDevices.js.map +1 -0
  6. package/lib/core/transform/clock/filesystemListingDevices.mjs +34 -0
  7. package/lib/core/transform/clock/filesystemListingDevices.mjs.map +1 -0
  8. package/lib/core/transform/clock/refreshFilesystemClockReference.d.cts +10 -4
  9. package/lib/core/transform/clock/refreshFilesystemClockReference.d.mts +10 -4
  10. package/lib/core/transform/clock/refreshFilesystemClockReference.d.ts +10 -4
  11. package/lib/core/transform/clock/refreshFilesystemClockReference.js +40 -4
  12. package/lib/core/transform/clock/refreshFilesystemClockReference.js.map +1 -1
  13. package/lib/core/transform/clock/refreshFilesystemClockReference.mjs +40 -4
  14. package/lib/core/transform/clock/refreshFilesystemClockReference.mjs.map +1 -1
  15. package/lib/core/transform/inputs/pluginSourceFilesDigest.d.cts +7 -1
  16. package/lib/core/transform/inputs/pluginSourceFilesDigest.d.mts +7 -1
  17. package/lib/core/transform/inputs/pluginSourceFilesDigest.d.ts +7 -1
  18. package/lib/core/transform/inputs/pluginSourceFilesDigest.js +66 -4
  19. package/lib/core/transform/inputs/pluginSourceFilesDigest.js.map +1 -1
  20. package/lib/core/transform/inputs/pluginSourceFilesDigest.mjs +66 -4
  21. package/lib/core/transform/inputs/pluginSourceFilesDigest.mjs.map +1 -1
  22. package/package.json +3 -3
  23. package/src/core/transform/clock/filesystemListingDevices.ts +38 -0
  24. package/src/core/transform/clock/refreshFilesystemClockReference.ts +42 -4
  25. package/src/core/transform/inputs/pluginSourceFilesDigest.ts +73 -5
@@ -0,0 +1,24 @@
1
+ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransformFilesystemOperations.cjs";
2
+ /**
3
+ * The devices on which an observing view saw its adapter-owned probe directory
4
+ * move both of its stamps when the probe was recreated, keyed by the operations
5
+ * object, as `filesystemClockReferences` keys their references.
6
+ *
7
+ * A directory's stamps move when an entry is created, removed or renamed in it,
8
+ * so while they hold still a directory still holds the entries a walk read
9
+ * (`IPluginSourceListing` from `ttsc/plugin-source`). That premise is offered
10
+ * as evidence only on a device where the view has seen it hold, and each
11
+ * refresh clears and re-establishes it with the reference it mints.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation A device enters only after the view observed a fresh entry change in owned storage move that directory's modification and change stamps; refresh clears the set before minting.
14
+ * @evidence contracts/common.md#clear-and-simple-design One WeakMap owns the sets by operation identity, beside the reference tables they qualify.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No device is assumed to keep directory stamps from its platform or filesystem name.
16
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the premise, how a device is admitted and when it is cleared.
17
+ * @evidence contracts/portability.md#os-neutral-implementation Devices are the observing view's bigint identifiers; the premise is observed, not inferred from the OS.
18
+ * @evidence contracts/performance.md#efficient-algorithms One WeakMap lookup selects the set.
19
+ * @evidence contracts/performance.md#reuse-equivalent-work Every proof through one operations object shares its admitted devices until the next refresh.
20
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Weak association does not retain the operations object, and a set holds at most the devices of its probes.
21
+ */
22
+ export declare function filesystemListingDevices(
23
+ /** Coherent observing view whose probe established the premise. */
24
+ filesystem: TtscTransformFilesystemOperations): Set<bigint>;
@@ -0,0 +1,24 @@
1
+ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransformFilesystemOperations.mjs";
2
+ /**
3
+ * The devices on which an observing view saw its adapter-owned probe directory
4
+ * move both of its stamps when the probe was recreated, keyed by the operations
5
+ * object, as `filesystemClockReferences` keys their references.
6
+ *
7
+ * A directory's stamps move when an entry is created, removed or renamed in it,
8
+ * so while they hold still a directory still holds the entries a walk read
9
+ * (`IPluginSourceListing` from `ttsc/plugin-source`). That premise is offered
10
+ * as evidence only on a device where the view has seen it hold, and each
11
+ * refresh clears and re-establishes it with the reference it mints.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation A device enters only after the view observed a fresh entry change in owned storage move that directory's modification and change stamps; refresh clears the set before minting.
14
+ * @evidence contracts/common.md#clear-and-simple-design One WeakMap owns the sets by operation identity, beside the reference tables they qualify.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No device is assumed to keep directory stamps from its platform or filesystem name.
16
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the premise, how a device is admitted and when it is cleared.
17
+ * @evidence contracts/portability.md#os-neutral-implementation Devices are the observing view's bigint identifiers; the premise is observed, not inferred from the OS.
18
+ * @evidence contracts/performance.md#efficient-algorithms One WeakMap lookup selects the set.
19
+ * @evidence contracts/performance.md#reuse-equivalent-work Every proof through one operations object shares its admitted devices until the next refresh.
20
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Weak association does not retain the operations object, and a set holds at most the devices of its probes.
21
+ */
22
+ export declare function filesystemListingDevices(
23
+ /** Coherent observing view whose probe established the premise. */
24
+ filesystem: TtscTransformFilesystemOperations): Set<bigint>;
@@ -0,0 +1,24 @@
1
+ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransformFilesystemOperations";
2
+ /**
3
+ * The devices on which an observing view saw its adapter-owned probe directory
4
+ * move both of its stamps when the probe was recreated, keyed by the operations
5
+ * object, as `filesystemClockReferences` keys their references.
6
+ *
7
+ * A directory's stamps move when an entry is created, removed or renamed in it,
8
+ * so while they hold still a directory still holds the entries a walk read
9
+ * (`IPluginSourceListing` from `ttsc/plugin-source`). That premise is offered
10
+ * as evidence only on a device where the view has seen it hold, and each
11
+ * refresh clears and re-establishes it with the reference it mints.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation A device enters only after the view observed a fresh entry change in owned storage move that directory's modification and change stamps; refresh clears the set before minting.
14
+ * @evidence contracts/common.md#clear-and-simple-design One WeakMap owns the sets by operation identity, beside the reference tables they qualify.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No device is assumed to keep directory stamps from its platform or filesystem name.
16
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the premise, how a device is admitted and when it is cleared.
17
+ * @evidence contracts/portability.md#os-neutral-implementation Devices are the observing view's bigint identifiers; the premise is observed, not inferred from the OS.
18
+ * @evidence contracts/performance.md#efficient-algorithms One WeakMap lookup selects the set.
19
+ * @evidence contracts/performance.md#reuse-equivalent-work Every proof through one operations object shares its admitted devices until the next refresh.
20
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Weak association does not retain the operations object, and a set holds at most the devices of its probes.
21
+ */
22
+ export declare function filesystemListingDevices(
23
+ /** Coherent observing view whose probe established the premise. */
24
+ filesystem: TtscTransformFilesystemOperations): Set<bigint>;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * The devices on which an observing view saw its adapter-owned probe directory
5
+ * move both of its stamps when the probe was recreated, keyed by the operations
6
+ * object, as `filesystemClockReferences` keys their references.
7
+ *
8
+ * A directory's stamps move when an entry is created, removed or renamed in it,
9
+ * so while they hold still a directory still holds the entries a walk read
10
+ * (`IPluginSourceListing` from `ttsc/plugin-source`). That premise is offered
11
+ * as evidence only on a device where the view has seen it hold, and each
12
+ * refresh clears and re-establishes it with the reference it mints.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation A device enters only after the view observed a fresh entry change in owned storage move that directory's modification and change stamps; refresh clears the set before minting.
15
+ * @evidence contracts/common.md#clear-and-simple-design One WeakMap owns the sets by operation identity, beside the reference tables they qualify.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No device is assumed to keep directory stamps from its platform or filesystem name.
17
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the premise, how a device is admitted and when it is cleared.
18
+ * @evidence contracts/portability.md#os-neutral-implementation Devices are the observing view's bigint identifiers; the premise is observed, not inferred from the OS.
19
+ * @evidence contracts/performance.md#efficient-algorithms One WeakMap lookup selects the set.
20
+ * @evidence contracts/performance.md#reuse-equivalent-work Every proof through one operations object shares its admitted devices until the next refresh.
21
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Weak association does not retain the operations object, and a set holds at most the devices of its probes.
22
+ */
23
+ function filesystemListingDevices(
24
+ /** Coherent observing view whose probe established the premise. */
25
+ filesystem) {
26
+ let devices = FILESYSTEM_LISTING_DEVICES.get(filesystem);
27
+ if (devices === undefined) {
28
+ devices = new Set();
29
+ FILESYSTEM_LISTING_DEVICES.set(filesystem, devices);
30
+ }
31
+ return devices;
32
+ }
33
+ const FILESYSTEM_LISTING_DEVICES = new WeakMap();
34
+
35
+ exports.filesystemListingDevices = filesystemListingDevices;
36
+ //# sourceMappingURL=filesystemListingDevices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystemListingDevices.js","sources":["../../../../src/core/transform/clock/filesystemListingDevices.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;AAmBG;SACa,wBAAwB;AACtC;AACA,UAA6C,EAAA;IAE7C,IAAI,OAAO,GAAG,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAC;AACxD,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,QAAA,OAAO,GAAG,IAAI,GAAG,EAAE;AACnB,QAAA,0BAA0B,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;IACrD;AACA,IAAA,OAAO,OAAO;AAChB;AAEA,MAAM,0BAA0B,GAAG,IAAI,OAAO,EAG3C;;;;"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The devices on which an observing view saw its adapter-owned probe directory
3
+ * move both of its stamps when the probe was recreated, keyed by the operations
4
+ * object, as `filesystemClockReferences` keys their references.
5
+ *
6
+ * A directory's stamps move when an entry is created, removed or renamed in it,
7
+ * so while they hold still a directory still holds the entries a walk read
8
+ * (`IPluginSourceListing` from `ttsc/plugin-source`). That premise is offered
9
+ * as evidence only on a device where the view has seen it hold, and each
10
+ * refresh clears and re-establishes it with the reference it mints.
11
+ *
12
+ * @evidence contracts/common.md#principled-implementation A device enters only after the view observed a fresh entry change in owned storage move that directory's modification and change stamps; refresh clears the set before minting.
13
+ * @evidence contracts/common.md#clear-and-simple-design One WeakMap owns the sets by operation identity, beside the reference tables they qualify.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No device is assumed to keep directory stamps from its platform or filesystem name.
15
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the premise, how a device is admitted and when it is cleared.
16
+ * @evidence contracts/portability.md#os-neutral-implementation Devices are the observing view's bigint identifiers; the premise is observed, not inferred from the OS.
17
+ * @evidence contracts/performance.md#efficient-algorithms One WeakMap lookup selects the set.
18
+ * @evidence contracts/performance.md#reuse-equivalent-work Every proof through one operations object shares its admitted devices until the next refresh.
19
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Weak association does not retain the operations object, and a set holds at most the devices of its probes.
20
+ */
21
+ function filesystemListingDevices(
22
+ /** Coherent observing view whose probe established the premise. */
23
+ filesystem) {
24
+ let devices = FILESYSTEM_LISTING_DEVICES.get(filesystem);
25
+ if (devices === undefined) {
26
+ devices = new Set();
27
+ FILESYSTEM_LISTING_DEVICES.set(filesystem, devices);
28
+ }
29
+ return devices;
30
+ }
31
+ const FILESYSTEM_LISTING_DEVICES = new WeakMap();
32
+
33
+ export { filesystemListingDevices };
34
+ //# sourceMappingURL=filesystemListingDevices.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystemListingDevices.mjs","sources":["../../../../src/core/transform/clock/filesystemListingDevices.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;AAmBG;SACa,wBAAwB;AACtC;AACA,UAA6C,EAAA;IAE7C,IAAI,OAAO,GAAG,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAC;AACxD,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,QAAA,OAAO,GAAG,IAAI,GAAG,EAAE;AACnB,QAAA,0BAA0B,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;IACrD;AACA,IAAA,OAAO,OAAO;AAChB;AAEA,MAAM,0BAA0B,GAAG,IAAI,OAAO,EAG3C;;;;"}
@@ -19,6 +19,12 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
19
19
  * valid price for this optimization, so the cross-volume case degrades to more
20
20
  * reads instead.
21
21
  *
22
+ * Recreating the probe is also an entry change in the owned directory. When the
23
+ * view sees that directory's modification and change stamps both move, its
24
+ * device is admitted as one whose directory stamps witness their entries
25
+ * (`filesystemListingDevices`), so a plugin source listing can be replayed
26
+ * there instead of enumerated.
27
+ *
22
28
  * @evidence contracts/common.md#principled-implementation Clearing old references before a fresh owned probe write prevents previous or rolled-back stamps from certifying content; only observed regular-file metadata establishes a same-device reference.
23
29
  * @evidence contracts/common.md#clear-and-simple-design This operation mints and records one probe stamp; input metadata comparison remains in the separability consumer.
24
30
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed writes, inaccessible probes, or another device cannot be replaced by Date.now or a historical maximum; actual content proof remains necessary.
@@ -26,10 +32,10 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
26
32
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral clock proof uses native owned-path writes and the observing view's bigint device/time metadata, preserving cross-volume and unavailable-probe behavior without a platform clock assumption.
27
33
  * @evidence contracts/performance.md#efficient-algorithms
28
34
  * Clear the view's prior entries, then an available directory performs native
29
- * path joining, one write of process-counter text and one observed metadata
30
- * read. Costs include path/counter text and native I/O; a missing directory
31
- * skips I/O. Clearing/recording follows the current reference population,
32
- * not a scan of project inputs.
35
+ * path joining, one removal and one write of process-counter text and three
36
+ * observed metadata reads. Costs include path/counter text and native I/O; a
37
+ * missing directory skips I/O. Clearing/recording follows the current
38
+ * reference population, not a scan of project inputs.
33
39
  * @evidence contracts/performance.md#reuse-equivalent-work The existing probe path and shared per-view reference table are reused; only a newly minted stamp can authorize signature reuse.
34
40
  * @evidence contracts/performance.md#bound-retention-and-release-resources
35
41
  * Refresh clears history and retains at most one regular-file device stamp;
@@ -19,6 +19,12 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
19
19
  * valid price for this optimization, so the cross-volume case degrades to more
20
20
  * reads instead.
21
21
  *
22
+ * Recreating the probe is also an entry change in the owned directory. When the
23
+ * view sees that directory's modification and change stamps both move, its
24
+ * device is admitted as one whose directory stamps witness their entries
25
+ * (`filesystemListingDevices`), so a plugin source listing can be replayed
26
+ * there instead of enumerated.
27
+ *
22
28
  * @evidence contracts/common.md#principled-implementation Clearing old references before a fresh owned probe write prevents previous or rolled-back stamps from certifying content; only observed regular-file metadata establishes a same-device reference.
23
29
  * @evidence contracts/common.md#clear-and-simple-design This operation mints and records one probe stamp; input metadata comparison remains in the separability consumer.
24
30
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed writes, inaccessible probes, or another device cannot be replaced by Date.now or a historical maximum; actual content proof remains necessary.
@@ -26,10 +32,10 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
26
32
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral clock proof uses native owned-path writes and the observing view's bigint device/time metadata, preserving cross-volume and unavailable-probe behavior without a platform clock assumption.
27
33
  * @evidence contracts/performance.md#efficient-algorithms
28
34
  * Clear the view's prior entries, then an available directory performs native
29
- * path joining, one write of process-counter text and one observed metadata
30
- * read. Costs include path/counter text and native I/O; a missing directory
31
- * skips I/O. Clearing/recording follows the current reference population,
32
- * not a scan of project inputs.
35
+ * path joining, one removal and one write of process-counter text and three
36
+ * observed metadata reads. Costs include path/counter text and native I/O; a
37
+ * missing directory skips I/O. Clearing/recording follows the current
38
+ * reference population, not a scan of project inputs.
33
39
  * @evidence contracts/performance.md#reuse-equivalent-work The existing probe path and shared per-view reference table are reused; only a newly minted stamp can authorize signature reuse.
34
40
  * @evidence contracts/performance.md#bound-retention-and-release-resources
35
41
  * Refresh clears history and retains at most one regular-file device stamp;
@@ -19,6 +19,12 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
19
19
  * valid price for this optimization, so the cross-volume case degrades to more
20
20
  * reads instead.
21
21
  *
22
+ * Recreating the probe is also an entry change in the owned directory. When the
23
+ * view sees that directory's modification and change stamps both move, its
24
+ * device is admitted as one whose directory stamps witness their entries
25
+ * (`filesystemListingDevices`), so a plugin source listing can be replayed
26
+ * there instead of enumerated.
27
+ *
22
28
  * @evidence contracts/common.md#principled-implementation Clearing old references before a fresh owned probe write prevents previous or rolled-back stamps from certifying content; only observed regular-file metadata establishes a same-device reference.
23
29
  * @evidence contracts/common.md#clear-and-simple-design This operation mints and records one probe stamp; input metadata comparison remains in the separability consumer.
24
30
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed writes, inaccessible probes, or another device cannot be replaced by Date.now or a historical maximum; actual content proof remains necessary.
@@ -26,10 +32,10 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
26
32
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral clock proof uses native owned-path writes and the observing view's bigint device/time metadata, preserving cross-volume and unavailable-probe behavior without a platform clock assumption.
27
33
  * @evidence contracts/performance.md#efficient-algorithms
28
34
  * Clear the view's prior entries, then an available directory performs native
29
- * path joining, one write of process-counter text and one observed metadata
30
- * read. Costs include path/counter text and native I/O; a missing directory
31
- * skips I/O. Clearing/recording follows the current reference population,
32
- * not a scan of project inputs.
35
+ * path joining, one removal and one write of process-counter text and three
36
+ * observed metadata reads. Costs include path/counter text and native I/O; a
37
+ * missing directory skips I/O. Clearing/recording follows the current
38
+ * reference population, not a scan of project inputs.
33
39
  * @evidence contracts/performance.md#reuse-equivalent-work The existing probe path and shared per-view reference table are reused; only a newly minted stamp can authorize signature reuse.
34
40
  * @evidence contracts/performance.md#bound-retention-and-release-resources
35
41
  * Refresh clears history and retains at most one regular-file device stamp;
@@ -3,6 +3,7 @@
3
3
  var fs = require('node:fs');
4
4
  var path = require('node:path');
5
5
  var filesystemClockReferences = require('./filesystemClockReferences.js');
6
+ var filesystemListingDevices = require('./filesystemListingDevices.js');
6
7
 
7
8
  /**
8
9
  * Replace every prior clock proof with one reference minted by a fresh write.
@@ -24,6 +25,12 @@ var filesystemClockReferences = require('./filesystemClockReferences.js');
24
25
  * valid price for this optimization, so the cross-volume case degrades to more
25
26
  * reads instead.
26
27
  *
28
+ * Recreating the probe is also an entry change in the owned directory. When the
29
+ * view sees that directory's modification and change stamps both move, its
30
+ * device is admitted as one whose directory stamps witness their entries
31
+ * (`filesystemListingDevices`), so a plugin source listing can be replayed
32
+ * there instead of enumerated.
33
+ *
27
34
  * @evidence contracts/common.md#principled-implementation Clearing old references before a fresh owned probe write prevents previous or rolled-back stamps from certifying content; only observed regular-file metadata establishes a same-device reference.
28
35
  * @evidence contracts/common.md#clear-and-simple-design This operation mints and records one probe stamp; input metadata comparison remains in the separability consumer.
29
36
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed writes, inaccessible probes, or another device cannot be replaced by Date.now or a historical maximum; actual content proof remains necessary.
@@ -31,10 +38,10 @@ var filesystemClockReferences = require('./filesystemClockReferences.js');
31
38
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral clock proof uses native owned-path writes and the observing view's bigint device/time metadata, preserving cross-volume and unavailable-probe behavior without a platform clock assumption.
32
39
  * @evidence contracts/performance.md#efficient-algorithms
33
40
  * Clear the view's prior entries, then an available directory performs native
34
- * path joining, one write of process-counter text and one observed metadata
35
- * read. Costs include path/counter text and native I/O; a missing directory
36
- * skips I/O. Clearing/recording follows the current reference population,
37
- * not a scan of project inputs.
41
+ * path joining, one removal and one write of process-counter text and three
42
+ * observed metadata reads. Costs include path/counter text and native I/O; a
43
+ * missing directory skips I/O. Clearing/recording follows the current
44
+ * reference population, not a scan of project inputs.
38
45
  * @evidence contracts/performance.md#reuse-equivalent-work The existing probe path and shared per-view reference table are reused; only a newly minted stamp can authorize signature reuse.
39
46
  * @evidence contracts/performance.md#bound-retention-and-release-resources
40
47
  * Refresh clears history and retains at most one regular-file device stamp;
@@ -48,20 +55,49 @@ referenceDirectory,
48
55
  /** Coherent observing view whose device/time reference will be replaced. */
49
56
  filesystem) {
50
57
  const references = filesystemClockReferences.filesystemClockReferences(filesystem);
58
+ const listings = filesystemListingDevices.filesystemListingDevices(filesystem);
51
59
  references.clear();
60
+ listings.clear();
52
61
  if (referenceDirectory === undefined)
53
62
  return;
54
63
  try {
55
64
  const probe = path.join(referenceDirectory, "clock-reference");
65
+ // The probe is recreated rather than rewritten, so the owned directory sees
66
+ // an entry change whose effect on its stamps qualifies the device.
67
+ const directory = () => {
68
+ try {
69
+ return filesystem.lstat(referenceDirectory);
70
+ }
71
+ catch {
72
+ // A view that cannot state the directory only forgoes the listing.
73
+ return undefined;
74
+ }
75
+ };
76
+ const parent = directory();
77
+ try {
78
+ fs.rmSync(probe, { force: true });
79
+ }
80
+ catch {
81
+ // A probe that cannot be removed is rewritten in place, which moves no
82
+ // directory stamp, so the device is simply not admitted.
83
+ }
56
84
  fs.writeFileSync(probe, `${process.hrtime.bigint()}\n`);
57
85
  const stats = filesystem.lstat(probe);
58
86
  if (stats.isFile()) {
59
87
  references.set(stats.dev, stats.mtimeNs);
88
+ const moved = parent === undefined ? undefined : directory();
89
+ if (parent !== undefined &&
90
+ moved !== undefined &&
91
+ moved.dev === stats.dev &&
92
+ moved.mtimeNs > parent.mtimeNs &&
93
+ moved.ctimeNs > parent.ctimeNs)
94
+ listings.add(stats.dev);
60
95
  }
61
96
  }
62
97
  catch {
63
98
  // A failed refresh leaves no reference, so content comparison continues.
64
99
  references.clear();
100
+ listings.clear();
65
101
  }
66
102
  }
67
103
 
@@ -1 +1 @@
1
- {"version":3,"file":"refreshFilesystemClockReference.js","sources":["../../../../src/core/transform/clock/refreshFilesystemClockReference.ts"],"sourcesContent":[null],"names":["filesystemClockReferences"],"mappings":";;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;SACa,+BAA+B;AAC7C;AACA,kBAAsC;AACtC;AACA,UAA6C,EAAA;AAE7C,IAAA,MAAM,UAAU,GAAGA,mDAAyB,CAAC,UAAU,CAAC;IACxD,UAAU,CAAC,KAAK,EAAE;IAClB,IAAI,kBAAkB,KAAK,SAAS;QAAE;AACtC,IAAA,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;AAC9D,QAAA,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAA,EAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,EAAA,CAAI,CAAC;QACvD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;AACrC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAClB,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QAC1C;IACF;AAAE,IAAA,MAAM;;QAEN,UAAU,CAAC,KAAK,EAAE;IACpB;AACF;;;;"}
1
+ {"version":3,"file":"refreshFilesystemClockReference.js","sources":["../../../../src/core/transform/clock/refreshFilesystemClockReference.ts"],"sourcesContent":[null],"names":["filesystemClockReferences","filesystemListingDevices"],"mappings":";;;;;;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;SACa,+BAA+B;AAC7C;AACA,kBAAsC;AACtC;AACA,UAA6C,EAAA;AAE7C,IAAA,MAAM,UAAU,GAAGA,mDAAyB,CAAC,UAAU,CAAC;AACxD,IAAA,MAAM,QAAQ,GAAGC,iDAAwB,CAAC,UAAU,CAAC;IACrD,UAAU,CAAC,KAAK,EAAE;IAClB,QAAQ,CAAC,KAAK,EAAE;IAChB,IAAI,kBAAkB,KAAK,SAAS;QAAE;AACtC,IAAA,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;;;QAG9D,MAAM,SAAS,GAAG,MAEF;AACd,YAAA,IAAI;AACF,gBAAA,OAAO,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC;YAC7C;AAAE,YAAA,MAAM;;AAEN,gBAAA,OAAO,SAAS;YAClB;AACF,QAAA,CAAC;AACD,QAAA,MAAM,MAAM,GAAG,SAAS,EAAE;AAC1B,QAAA,IAAI;YACF,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnC;AAAE,QAAA,MAAM;;;QAGR;AACA,QAAA,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAA,EAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,EAAA,CAAI,CAAC;QACvD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;AACrC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAClB,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;AACxC,YAAA,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,EAAE;YAC5D,IACE,MAAM,KAAK,SAAS;AACpB,gBAAA,KAAK,KAAK,SAAS;AACnB,gBAAA,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;AACvB,gBAAA,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAC9B,gBAAA,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAE9B,gBAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;AAAE,IAAA,MAAM;;QAEN,UAAU,CAAC,KAAK,EAAE;QAClB,QAAQ,CAAC,KAAK,EAAE;IAClB;AACF;;;;"}
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { filesystemClockReferences } from './filesystemClockReferences.mjs';
4
+ import { filesystemListingDevices } from './filesystemListingDevices.mjs';
4
5
 
5
6
  /**
6
7
  * Replace every prior clock proof with one reference minted by a fresh write.
@@ -22,6 +23,12 @@ import { filesystemClockReferences } from './filesystemClockReferences.mjs';
22
23
  * valid price for this optimization, so the cross-volume case degrades to more
23
24
  * reads instead.
24
25
  *
26
+ * Recreating the probe is also an entry change in the owned directory. When the
27
+ * view sees that directory's modification and change stamps both move, its
28
+ * device is admitted as one whose directory stamps witness their entries
29
+ * (`filesystemListingDevices`), so a plugin source listing can be replayed
30
+ * there instead of enumerated.
31
+ *
25
32
  * @evidence contracts/common.md#principled-implementation Clearing old references before a fresh owned probe write prevents previous or rolled-back stamps from certifying content; only observed regular-file metadata establishes a same-device reference.
26
33
  * @evidence contracts/common.md#clear-and-simple-design This operation mints and records one probe stamp; input metadata comparison remains in the separability consumer.
27
34
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed writes, inaccessible probes, or another device cannot be replaced by Date.now or a historical maximum; actual content proof remains necessary.
@@ -29,10 +36,10 @@ import { filesystemClockReferences } from './filesystemClockReferences.mjs';
29
36
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral clock proof uses native owned-path writes and the observing view's bigint device/time metadata, preserving cross-volume and unavailable-probe behavior without a platform clock assumption.
30
37
  * @evidence contracts/performance.md#efficient-algorithms
31
38
  * Clear the view's prior entries, then an available directory performs native
32
- * path joining, one write of process-counter text and one observed metadata
33
- * read. Costs include path/counter text and native I/O; a missing directory
34
- * skips I/O. Clearing/recording follows the current reference population,
35
- * not a scan of project inputs.
39
+ * path joining, one removal and one write of process-counter text and three
40
+ * observed metadata reads. Costs include path/counter text and native I/O; a
41
+ * missing directory skips I/O. Clearing/recording follows the current
42
+ * reference population, not a scan of project inputs.
36
43
  * @evidence contracts/performance.md#reuse-equivalent-work The existing probe path and shared per-view reference table are reused; only a newly minted stamp can authorize signature reuse.
37
44
  * @evidence contracts/performance.md#bound-retention-and-release-resources
38
45
  * Refresh clears history and retains at most one regular-file device stamp;
@@ -46,20 +53,49 @@ referenceDirectory,
46
53
  /** Coherent observing view whose device/time reference will be replaced. */
47
54
  filesystem) {
48
55
  const references = filesystemClockReferences(filesystem);
56
+ const listings = filesystemListingDevices(filesystem);
49
57
  references.clear();
58
+ listings.clear();
50
59
  if (referenceDirectory === undefined)
51
60
  return;
52
61
  try {
53
62
  const probe = path.join(referenceDirectory, "clock-reference");
63
+ // The probe is recreated rather than rewritten, so the owned directory sees
64
+ // an entry change whose effect on its stamps qualifies the device.
65
+ const directory = () => {
66
+ try {
67
+ return filesystem.lstat(referenceDirectory);
68
+ }
69
+ catch {
70
+ // A view that cannot state the directory only forgoes the listing.
71
+ return undefined;
72
+ }
73
+ };
74
+ const parent = directory();
75
+ try {
76
+ fs.rmSync(probe, { force: true });
77
+ }
78
+ catch {
79
+ // A probe that cannot be removed is rewritten in place, which moves no
80
+ // directory stamp, so the device is simply not admitted.
81
+ }
54
82
  fs.writeFileSync(probe, `${process.hrtime.bigint()}\n`);
55
83
  const stats = filesystem.lstat(probe);
56
84
  if (stats.isFile()) {
57
85
  references.set(stats.dev, stats.mtimeNs);
86
+ const moved = parent === undefined ? undefined : directory();
87
+ if (parent !== undefined &&
88
+ moved !== undefined &&
89
+ moved.dev === stats.dev &&
90
+ moved.mtimeNs > parent.mtimeNs &&
91
+ moved.ctimeNs > parent.ctimeNs)
92
+ listings.add(stats.dev);
58
93
  }
59
94
  }
60
95
  catch {
61
96
  // A failed refresh leaves no reference, so content comparison continues.
62
97
  references.clear();
98
+ listings.clear();
63
99
  }
64
100
  }
65
101
 
@@ -1 +1 @@
1
- {"version":3,"file":"refreshFilesystemClockReference.mjs","sources":["../../../../src/core/transform/clock/refreshFilesystemClockReference.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;SACa,+BAA+B;AAC7C;AACA,kBAAsC;AACtC;AACA,UAA6C,EAAA;AAE7C,IAAA,MAAM,UAAU,GAAG,yBAAyB,CAAC,UAAU,CAAC;IACxD,UAAU,CAAC,KAAK,EAAE;IAClB,IAAI,kBAAkB,KAAK,SAAS;QAAE;AACtC,IAAA,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;AAC9D,QAAA,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAA,EAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,EAAA,CAAI,CAAC;QACvD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;AACrC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAClB,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QAC1C;IACF;AAAE,IAAA,MAAM;;QAEN,UAAU,CAAC,KAAK,EAAE;IACpB;AACF;;;;"}
1
+ {"version":3,"file":"refreshFilesystemClockReference.mjs","sources":["../../../../src/core/transform/clock/refreshFilesystemClockReference.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;SACa,+BAA+B;AAC7C;AACA,kBAAsC;AACtC;AACA,UAA6C,EAAA;AAE7C,IAAA,MAAM,UAAU,GAAG,yBAAyB,CAAC,UAAU,CAAC;AACxD,IAAA,MAAM,QAAQ,GAAG,wBAAwB,CAAC,UAAU,CAAC;IACrD,UAAU,CAAC,KAAK,EAAE;IAClB,QAAQ,CAAC,KAAK,EAAE;IAChB,IAAI,kBAAkB,KAAK,SAAS;QAAE;AACtC,IAAA,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;;;QAG9D,MAAM,SAAS,GAAG,MAEF;AACd,YAAA,IAAI;AACF,gBAAA,OAAO,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC;YAC7C;AAAE,YAAA,MAAM;;AAEN,gBAAA,OAAO,SAAS;YAClB;AACF,QAAA,CAAC;AACD,QAAA,MAAM,MAAM,GAAG,SAAS,EAAE;AAC1B,QAAA,IAAI;YACF,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnC;AAAE,QAAA,MAAM;;;QAGR;AACA,QAAA,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAA,EAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,EAAA,CAAI,CAAC;QACvD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;AACrC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAClB,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;AACxC,YAAA,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,EAAE;YAC5D,IACE,MAAM,KAAK,SAAS;AACpB,gBAAA,KAAK,KAAK,SAAS;AACnB,gBAAA,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;AACvB,gBAAA,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAC9B,gBAAA,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAE9B,gBAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;AAAE,IAAA,MAAM;;QAEN,UAAU,CAAC,KAAK,EAAE;QAClB,QAAQ,CAAC,KAAK,EAAE;IAClB;AACF;;;;"}
@@ -9,6 +9,12 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
9
9
  * separability again against the caller's refreshed device clock references; a
10
10
  * historical reference cannot establish safety after a clock rollback.
11
11
  *
12
+ * The population's listing is kept with the digest, so a later proof states the
13
+ * listed directories' stamps instead of enumerating them, on a device where
14
+ * this view saw directory stamps move with an entry change
15
+ * (`filesystemListingDevices`). A directory whose stamps moved, or that cannot
16
+ * be stated, sends the proof back to the walk.
17
+ *
12
18
  * Source enumeration and byte reads use ttsc's native filesystem. Injected
13
19
  * metadata must describe that same source tree; this adapter does not make
14
20
  * arbitrary foreign filesystems interchangeable. The process-wide map has no
@@ -30,7 +36,7 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
30
36
  * @evidence contracts/common.md#prohibited-implementation-shortcuts A quiet tracker or equal timestamps alone cannot certify reuse; changed or unavailable evidence requires the real source digest rather than expected output or a compensating cache exception.
31
37
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
32
38
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
33
- * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
39
+ * @evidence contracts/performance.md#efficient-algorithms Reuse with a held listing stats D directories and F files without enumerating any; without one it enumerates D directories. A miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
34
40
  * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
35
41
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
36
42
  */
@@ -9,6 +9,12 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
9
9
  * separability again against the caller's refreshed device clock references; a
10
10
  * historical reference cannot establish safety after a clock rollback.
11
11
  *
12
+ * The population's listing is kept with the digest, so a later proof states the
13
+ * listed directories' stamps instead of enumerating them, on a device where
14
+ * this view saw directory stamps move with an entry change
15
+ * (`filesystemListingDevices`). A directory whose stamps moved, or that cannot
16
+ * be stated, sends the proof back to the walk.
17
+ *
12
18
  * Source enumeration and byte reads use ttsc's native filesystem. Injected
13
19
  * metadata must describe that same source tree; this adapter does not make
14
20
  * arbitrary foreign filesystems interchangeable. The process-wide map has no
@@ -30,7 +36,7 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
30
36
  * @evidence contracts/common.md#prohibited-implementation-shortcuts A quiet tracker or equal timestamps alone cannot certify reuse; changed or unavailable evidence requires the real source digest rather than expected output or a compensating cache exception.
31
37
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
32
38
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
33
- * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
39
+ * @evidence contracts/performance.md#efficient-algorithms Reuse with a held listing stats D directories and F files without enumerating any; without one it enumerates D directories. A miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
34
40
  * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
35
41
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
36
42
  */
@@ -9,6 +9,12 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
9
9
  * separability again against the caller's refreshed device clock references; a
10
10
  * historical reference cannot establish safety after a clock rollback.
11
11
  *
12
+ * The population's listing is kept with the digest, so a later proof states the
13
+ * listed directories' stamps instead of enumerating them, on a device where
14
+ * this view saw directory stamps move with an entry change
15
+ * (`filesystemListingDevices`). A directory whose stamps moved, or that cannot
16
+ * be stated, sends the proof back to the walk.
17
+ *
12
18
  * Source enumeration and byte reads use ttsc's native filesystem. Injected
13
19
  * metadata must describe that same source tree; this adapter does not make
14
20
  * arbitrary foreign filesystems interchangeable. The process-wide map has no
@@ -30,7 +36,7 @@ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransf
30
36
  * @evidence contracts/common.md#prohibited-implementation-shortcuts A quiet tracker or equal timestamps alone cannot certify reuse; changed or unavailable evidence requires the real source digest rather than expected output or a compensating cache exception.
31
37
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
32
38
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
33
- * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
39
+ * @evidence contracts/performance.md#efficient-algorithms Reuse with a held listing stats D directories and F files without enumerating any; without one it enumerates D directories. A miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
34
40
  * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
35
41
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
36
42
  */
@@ -2,6 +2,8 @@
2
2
 
3
3
  var path = require('node:path');
4
4
  var pluginSource = require('ttsc/plugin-source');
5
+ var filesystemClockReferences = require('../clock/filesystemClockReferences.js');
6
+ var filesystemListingDevices = require('../clock/filesystemListingDevices.js');
5
7
  var DEFAULT_FILESYSTEM_OPERATIONS = require('../filesystem/DEFAULT_FILESYSTEM_OPERATIONS.js');
6
8
  var inputMetadataEvidence = require('./inputMetadataEvidence.js');
7
9
 
@@ -15,6 +17,12 @@ var inputMetadataEvidence = require('./inputMetadataEvidence.js');
15
17
  * separability again against the caller's refreshed device clock references; a
16
18
  * historical reference cannot establish safety after a clock rollback.
17
19
  *
20
+ * The population's listing is kept with the digest, so a later proof states the
21
+ * listed directories' stamps instead of enumerating them, on a device where
22
+ * this view saw directory stamps move with an entry change
23
+ * (`filesystemListingDevices`). A directory whose stamps moved, or that cannot
24
+ * be stated, sends the proof back to the walk.
25
+ *
18
26
  * Source enumeration and byte reads use ttsc's native filesystem. Injected
19
27
  * metadata must describe that same source tree; this adapter does not make
20
28
  * arbitrary foreign filesystems interchangeable. The process-wide map has no
@@ -36,7 +44,7 @@ var inputMetadataEvidence = require('./inputMetadataEvidence.js');
36
44
  * @evidence contracts/common.md#prohibited-implementation-shortcuts A quiet tracker or equal timestamps alone cannot certify reuse; changed or unavailable evidence requires the real source digest rather than expected output or a compensating cache exception.
37
45
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
38
46
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
39
- * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
47
+ * @evidence contracts/performance.md#efficient-algorithms Reuse with a held listing stats D directories and F files without enumerating any; without one it enumerates D directories. A miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
40
48
  * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
41
49
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
42
50
  */
@@ -47,20 +55,32 @@ function pluginSourceFilesDigest(directory, filesystem = DEFAULT_FILESYSTEM_OPER
47
55
  * The filesystem must observe the same source tree the selector enumerates.
48
56
  */
49
57
  const evidence = (file) => inputMetadataEvidence.inputMetadataEvidence(file, filesystem);
50
- const before = pluginSource.pluginSourceFilesSignature(key, evidence);
51
58
  const known = DIGESTS.get(key);
59
+ const before = pluginSource.pluginSourceFilesSignature(key, evidence, {
60
+ directory: (entry) => directoryEvidence(entry, filesystem),
61
+ known: known?.listing,
62
+ });
52
63
  if (before !== undefined &&
53
64
  before.separable &&
54
65
  known?.signature === before.signature) {
66
+ // A walk that stated every directory leaves its listing for the next proof.
67
+ if (before.listing !== undefined && before.listing !== known.listing)
68
+ DIGESTS.set(key, { ...known, listing: before.listing });
55
69
  return known.digest;
56
70
  }
57
71
  const digest = pluginSource.provenPluginSourceDigest(key, projectRoot);
58
- const after = pluginSource.pluginSourceFilesSignature(key, evidence);
72
+ const after = pluginSource.pluginSourceFilesSignature(key, evidence, {
73
+ directory: (entry) => directoryEvidence(entry, filesystem),
74
+ });
59
75
  if (before !== undefined &&
60
76
  after !== undefined &&
61
77
  after.signature === before.signature &&
62
78
  after.separable) {
63
- DIGESTS.set(key, { digest, signature: after.signature });
79
+ DIGESTS.set(key, {
80
+ digest,
81
+ signature: after.signature,
82
+ listing: after.listing,
83
+ });
64
84
  }
65
85
  else {
66
86
  DIGESTS.delete(key);
@@ -72,6 +92,48 @@ function pluginSourceFilesDigest(directory, filesystem = DEFAULT_FILESYSTEM_OPER
72
92
  * was read under.
73
93
  */
74
94
  const DIGESTS = new Map();
95
+ /**
96
+ * A directory's metadata signature when its stamps witness its entries in this
97
+ * view: a device the view admitted (`filesystemListingDevices`), and both
98
+ * stamps strictly older than the view's reference on it.
99
+ */
100
+ function directoryEvidence(directory, filesystem) {
101
+ const stated = (stats) => {
102
+ const reference = filesystemClockReferences.filesystemClockReferences(filesystem).get(stats.dev);
103
+ return filesystemListingDevices.filesystemListingDevices(filesystem).has(stats.dev) &&
104
+ reference !== undefined &&
105
+ stats.mtimeNs < reference &&
106
+ stats.ctimeNs < reference
107
+ ? [
108
+ stats.dev,
109
+ stats.ino,
110
+ stats.mode,
111
+ stats.nlink,
112
+ stats.mtimeNs,
113
+ stats.ctimeNs,
114
+ ].join(":")
115
+ : undefined;
116
+ };
117
+ try {
118
+ const entry = filesystem.lstat(directory);
119
+ // A source root reached through a link is stated by the link and by the
120
+ // directory it names: a retarget moves the first, an entry change the
121
+ // second.
122
+ const target = entry.isSymbolicLink()
123
+ ? filesystem.statBigInt(directory)
124
+ : entry;
125
+ if (!target.isDirectory())
126
+ return undefined;
127
+ const own = stated(entry);
128
+ if (own === undefined || target === entry)
129
+ return own;
130
+ const named = stated(target);
131
+ return named === undefined ? undefined : `${own}>${named}`;
132
+ }
133
+ catch {
134
+ return undefined;
135
+ }
136
+ }
75
137
 
76
138
  exports.pluginSourceFilesDigest = pluginSourceFilesDigest;
77
139
  //# sourceMappingURL=pluginSourceFilesDigest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pluginSourceFilesDigest.js","sources":["../../../../src/core/transform/inputs/pluginSourceFilesDigest.ts"],"sourcesContent":[null],"names":["DEFAULT_FILESYSTEM_OPERATIONS","inputMetadataEvidence","pluginSourceFilesSignature","provenPluginSourceDigest"],"mappings":";;;;;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACG,SAAU,uBAAuB,CACrC,SAAiB,EACjB,UAAA,GAAgDA,2DAA6B,EAC7E,WAAoB,EAAA;IAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AACnC;;;AAGG;AACH,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAY,KAAKC,2CAAqB,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1E,MAAM,MAAM,GAAGC,uCAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAC9B,IACE,MAAM,KAAK,SAAS;AACpB,QAAA,MAAM,CAAC,SAAS;AAChB,QAAA,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC,SAAS,EACrC;QACA,OAAO,KAAK,CAAC,MAAM;IACrB;IACA,MAAM,MAAM,GAAGC,qCAAwB,CAAC,GAAG,EAAE,WAAW,CAAC;IACzD,MAAM,KAAK,GAAGD,uCAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvD,IACE,MAAM,KAAK,SAAS;AACpB,QAAA,KAAK,KAAK,SAAS;AACnB,QAAA,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS;QACpC,KAAK,CAAC,SAAS,EACf;AACA,QAAA,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC1D;SAAO;AACL,QAAA,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;IACrB;AACA,IAAA,OAAO,MAAM;AACf;AAEA;;;AAGG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiD;;;;"}
1
+ {"version":3,"file":"pluginSourceFilesDigest.js","sources":["../../../../src/core/transform/inputs/pluginSourceFilesDigest.ts"],"sourcesContent":[null],"names":["DEFAULT_FILESYSTEM_OPERATIONS","inputMetadataEvidence","pluginSourceFilesSignature","provenPluginSourceDigest","filesystemClockReferences","filesystemListingDevices"],"mappings":"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"}
@@ -1,5 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { pluginSourceFilesSignature, provenPluginSourceDigest } from 'ttsc/plugin-source';
3
+ import { filesystemClockReferences } from '../clock/filesystemClockReferences.mjs';
4
+ import { filesystemListingDevices } from '../clock/filesystemListingDevices.mjs';
3
5
  import { DEFAULT_FILESYSTEM_OPERATIONS } from '../filesystem/DEFAULT_FILESYSTEM_OPERATIONS.mjs';
4
6
  import { inputMetadataEvidence } from './inputMetadataEvidence.mjs';
5
7
 
@@ -13,6 +15,12 @@ import { inputMetadataEvidence } from './inputMetadataEvidence.mjs';
13
15
  * separability again against the caller's refreshed device clock references; a
14
16
  * historical reference cannot establish safety after a clock rollback.
15
17
  *
18
+ * The population's listing is kept with the digest, so a later proof states the
19
+ * listed directories' stamps instead of enumerating them, on a device where
20
+ * this view saw directory stamps move with an entry change
21
+ * (`filesystemListingDevices`). A directory whose stamps moved, or that cannot
22
+ * be stated, sends the proof back to the walk.
23
+ *
16
24
  * Source enumeration and byte reads use ttsc's native filesystem. Injected
17
25
  * metadata must describe that same source tree; this adapter does not make
18
26
  * arbitrary foreign filesystems interchangeable. The process-wide map has no
@@ -34,7 +42,7 @@ import { inputMetadataEvidence } from './inputMetadataEvidence.mjs';
34
42
  * @evidence contracts/common.md#prohibited-implementation-shortcuts A quiet tracker or equal timestamps alone cannot certify reuse; changed or unavailable evidence requires the real source digest rather than expected output or a compensating cache exception.
35
43
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
36
44
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
37
- * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
45
+ * @evidence contracts/performance.md#efficient-algorithms Reuse with a held listing stats D directories and F files without enumerating any; without one it enumerates D directories. A miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
38
46
  * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
39
47
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
40
48
  */
@@ -45,20 +53,32 @@ function pluginSourceFilesDigest(directory, filesystem = DEFAULT_FILESYSTEM_OPER
45
53
  * The filesystem must observe the same source tree the selector enumerates.
46
54
  */
47
55
  const evidence = (file) => inputMetadataEvidence(file, filesystem);
48
- const before = pluginSourceFilesSignature(key, evidence);
49
56
  const known = DIGESTS.get(key);
57
+ const before = pluginSourceFilesSignature(key, evidence, {
58
+ directory: (entry) => directoryEvidence(entry, filesystem),
59
+ known: known?.listing,
60
+ });
50
61
  if (before !== undefined &&
51
62
  before.separable &&
52
63
  known?.signature === before.signature) {
64
+ // A walk that stated every directory leaves its listing for the next proof.
65
+ if (before.listing !== undefined && before.listing !== known.listing)
66
+ DIGESTS.set(key, { ...known, listing: before.listing });
53
67
  return known.digest;
54
68
  }
55
69
  const digest = provenPluginSourceDigest(key, projectRoot);
56
- const after = pluginSourceFilesSignature(key, evidence);
70
+ const after = pluginSourceFilesSignature(key, evidence, {
71
+ directory: (entry) => directoryEvidence(entry, filesystem),
72
+ });
57
73
  if (before !== undefined &&
58
74
  after !== undefined &&
59
75
  after.signature === before.signature &&
60
76
  after.separable) {
61
- DIGESTS.set(key, { digest, signature: after.signature });
77
+ DIGESTS.set(key, {
78
+ digest,
79
+ signature: after.signature,
80
+ listing: after.listing,
81
+ });
62
82
  }
63
83
  else {
64
84
  DIGESTS.delete(key);
@@ -70,6 +90,48 @@ function pluginSourceFilesDigest(directory, filesystem = DEFAULT_FILESYSTEM_OPER
70
90
  * was read under.
71
91
  */
72
92
  const DIGESTS = new Map();
93
+ /**
94
+ * A directory's metadata signature when its stamps witness its entries in this
95
+ * view: a device the view admitted (`filesystemListingDevices`), and both
96
+ * stamps strictly older than the view's reference on it.
97
+ */
98
+ function directoryEvidence(directory, filesystem) {
99
+ const stated = (stats) => {
100
+ const reference = filesystemClockReferences(filesystem).get(stats.dev);
101
+ return filesystemListingDevices(filesystem).has(stats.dev) &&
102
+ reference !== undefined &&
103
+ stats.mtimeNs < reference &&
104
+ stats.ctimeNs < reference
105
+ ? [
106
+ stats.dev,
107
+ stats.ino,
108
+ stats.mode,
109
+ stats.nlink,
110
+ stats.mtimeNs,
111
+ stats.ctimeNs,
112
+ ].join(":")
113
+ : undefined;
114
+ };
115
+ try {
116
+ const entry = filesystem.lstat(directory);
117
+ // A source root reached through a link is stated by the link and by the
118
+ // directory it names: a retarget moves the first, an entry change the
119
+ // second.
120
+ const target = entry.isSymbolicLink()
121
+ ? filesystem.statBigInt(directory)
122
+ : entry;
123
+ if (!target.isDirectory())
124
+ return undefined;
125
+ const own = stated(entry);
126
+ if (own === undefined || target === entry)
127
+ return own;
128
+ const named = stated(target);
129
+ return named === undefined ? undefined : `${own}>${named}`;
130
+ }
131
+ catch {
132
+ return undefined;
133
+ }
134
+ }
73
135
 
74
136
  export { pluginSourceFilesDigest };
75
137
  //# sourceMappingURL=pluginSourceFilesDigest.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pluginSourceFilesDigest.mjs","sources":["../../../../src/core/transform/inputs/pluginSourceFilesDigest.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACG,SAAU,uBAAuB,CACrC,SAAiB,EACjB,UAAA,GAAgD,6BAA6B,EAC7E,WAAoB,EAAA;IAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AACnC;;;AAGG;AACH,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAY,KAAK,qBAAqB,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1E,MAAM,MAAM,GAAG,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAC9B,IACE,MAAM,KAAK,SAAS;AACpB,QAAA,MAAM,CAAC,SAAS;AAChB,QAAA,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC,SAAS,EACrC;QACA,OAAO,KAAK,CAAC,MAAM;IACrB;IACA,MAAM,MAAM,GAAG,wBAAwB,CAAC,GAAG,EAAE,WAAW,CAAC;IACzD,MAAM,KAAK,GAAG,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvD,IACE,MAAM,KAAK,SAAS;AACpB,QAAA,KAAK,KAAK,SAAS;AACnB,QAAA,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS;QACpC,KAAK,CAAC,SAAS,EACf;AACA,QAAA,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC1D;SAAO;AACL,QAAA,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;IACrB;AACA,IAAA,OAAO,MAAM;AACf;AAEA;;;AAGG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiD;;;;"}
1
+ {"version":3,"file":"pluginSourceFilesDigest.mjs","sources":["../../../../src/core/transform/inputs/pluginSourceFilesDigest.ts"],"sourcesContent":[null],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/unplugin",
3
- "version": "0.36.4",
3
+ "version": "0.37.1",
4
4
  "description": "Bundler adapters for ttsc plugins.",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
@@ -202,7 +202,7 @@
202
202
  "fsevents": "^2.3.3"
203
203
  },
204
204
  "peerDependencies": {
205
- "ttsc": "^0.36.4"
205
+ "ttsc": "^0.37.1"
206
206
  },
207
207
  "devDependencies": {
208
208
  "@wrtnlabs/evidence": "^0.5.1",
@@ -218,7 +218,7 @@
218
218
  "typescript": "^7.0.2",
219
219
  "vite": "^7.3.5",
220
220
  "vite8": "npm:vite@^8.3.4",
221
- "ttsc": "0.36.4"
221
+ "ttsc": "0.37.1"
222
222
  },
223
223
  "repository": {
224
224
  "type": "git",
@@ -0,0 +1,38 @@
1
+ import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransformFilesystemOperations";
2
+
3
+ /**
4
+ * The devices on which an observing view saw its adapter-owned probe directory
5
+ * move both of its stamps when the probe was recreated, keyed by the operations
6
+ * object, as `filesystemClockReferences` keys their references.
7
+ *
8
+ * A directory's stamps move when an entry is created, removed or renamed in it,
9
+ * so while they hold still a directory still holds the entries a walk read
10
+ * (`IPluginSourceListing` from `ttsc/plugin-source`). That premise is offered
11
+ * as evidence only on a device where the view has seen it hold, and each
12
+ * refresh clears and re-establishes it with the reference it mints.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation A device enters only after the view observed a fresh entry change in owned storage move that directory's modification and change stamps; refresh clears the set before minting.
15
+ * @evidence contracts/common.md#clear-and-simple-design One WeakMap owns the sets by operation identity, beside the reference tables they qualify.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No device is assumed to keep directory stamps from its platform or filesystem name.
17
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the premise, how a device is admitted and when it is cleared.
18
+ * @evidence contracts/portability.md#os-neutral-implementation Devices are the observing view's bigint identifiers; the premise is observed, not inferred from the OS.
19
+ * @evidence contracts/performance.md#efficient-algorithms One WeakMap lookup selects the set.
20
+ * @evidence contracts/performance.md#reuse-equivalent-work Every proof through one operations object shares its admitted devices until the next refresh.
21
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Weak association does not retain the operations object, and a set holds at most the devices of its probes.
22
+ */
23
+ export function filesystemListingDevices(
24
+ /** Coherent observing view whose probe established the premise. */
25
+ filesystem: TtscTransformFilesystemOperations,
26
+ ): Set<bigint> {
27
+ let devices = FILESYSTEM_LISTING_DEVICES.get(filesystem);
28
+ if (devices === undefined) {
29
+ devices = new Set();
30
+ FILESYSTEM_LISTING_DEVICES.set(filesystem, devices);
31
+ }
32
+ return devices;
33
+ }
34
+
35
+ const FILESYSTEM_LISTING_DEVICES = new WeakMap<
36
+ TtscTransformFilesystemOperations,
37
+ Set<bigint>
38
+ >();
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
 
4
4
  import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransformFilesystemOperations";
5
5
  import { filesystemClockReferences } from "./filesystemClockReferences";
6
+ import { filesystemListingDevices } from "./filesystemListingDevices";
6
7
 
7
8
  /**
8
9
  * Replace every prior clock proof with one reference minted by a fresh write.
@@ -24,6 +25,12 @@ import { filesystemClockReferences } from "./filesystemClockReferences";
24
25
  * valid price for this optimization, so the cross-volume case degrades to more
25
26
  * reads instead.
26
27
  *
28
+ * Recreating the probe is also an entry change in the owned directory. When the
29
+ * view sees that directory's modification and change stamps both move, its
30
+ * device is admitted as one whose directory stamps witness their entries
31
+ * (`filesystemListingDevices`), so a plugin source listing can be replayed
32
+ * there instead of enumerated.
33
+ *
27
34
  * @evidence contracts/common.md#principled-implementation Clearing old references before a fresh owned probe write prevents previous or rolled-back stamps from certifying content; only observed regular-file metadata establishes a same-device reference.
28
35
  * @evidence contracts/common.md#clear-and-simple-design This operation mints and records one probe stamp; input metadata comparison remains in the separability consumer.
29
36
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed writes, inaccessible probes, or another device cannot be replaced by Date.now or a historical maximum; actual content proof remains necessary.
@@ -31,10 +38,10 @@ import { filesystemClockReferences } from "./filesystemClockReferences";
31
38
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral clock proof uses native owned-path writes and the observing view's bigint device/time metadata, preserving cross-volume and unavailable-probe behavior without a platform clock assumption.
32
39
  * @evidence contracts/performance.md#efficient-algorithms
33
40
  * Clear the view's prior entries, then an available directory performs native
34
- * path joining, one write of process-counter text and one observed metadata
35
- * read. Costs include path/counter text and native I/O; a missing directory
36
- * skips I/O. Clearing/recording follows the current reference population,
37
- * not a scan of project inputs.
41
+ * path joining, one removal and one write of process-counter text and three
42
+ * observed metadata reads. Costs include path/counter text and native I/O; a
43
+ * missing directory skips I/O. Clearing/recording follows the current
44
+ * reference population, not a scan of project inputs.
38
45
  * @evidence contracts/performance.md#reuse-equivalent-work The existing probe path and shared per-view reference table are reused; only a newly minted stamp can authorize signature reuse.
39
46
  * @evidence contracts/performance.md#bound-retention-and-release-resources
40
47
  * Refresh clears history and retains at most one regular-file device stamp;
@@ -49,17 +56,48 @@ export function refreshFilesystemClockReference(
49
56
  filesystem: TtscTransformFilesystemOperations,
50
57
  ): void {
51
58
  const references = filesystemClockReferences(filesystem);
59
+ const listings = filesystemListingDevices(filesystem);
52
60
  references.clear();
61
+ listings.clear();
53
62
  if (referenceDirectory === undefined) return;
54
63
  try {
55
64
  const probe = path.join(referenceDirectory, "clock-reference");
65
+ // The probe is recreated rather than rewritten, so the owned directory sees
66
+ // an entry change whose effect on its stamps qualifies the device.
67
+ const directory = ():
68
+ | { dev: bigint; mtimeNs: bigint; ctimeNs: bigint }
69
+ | undefined => {
70
+ try {
71
+ return filesystem.lstat(referenceDirectory);
72
+ } catch {
73
+ // A view that cannot state the directory only forgoes the listing.
74
+ return undefined;
75
+ }
76
+ };
77
+ const parent = directory();
78
+ try {
79
+ fs.rmSync(probe, { force: true });
80
+ } catch {
81
+ // A probe that cannot be removed is rewritten in place, which moves no
82
+ // directory stamp, so the device is simply not admitted.
83
+ }
56
84
  fs.writeFileSync(probe, `${process.hrtime.bigint()}\n`);
57
85
  const stats = filesystem.lstat(probe);
58
86
  if (stats.isFile()) {
59
87
  references.set(stats.dev, stats.mtimeNs);
88
+ const moved = parent === undefined ? undefined : directory();
89
+ if (
90
+ parent !== undefined &&
91
+ moved !== undefined &&
92
+ moved.dev === stats.dev &&
93
+ moved.mtimeNs > parent.mtimeNs &&
94
+ moved.ctimeNs > parent.ctimeNs
95
+ )
96
+ listings.add(stats.dev);
60
97
  }
61
98
  } catch {
62
99
  // A failed refresh leaves no reference, so content comparison continues.
63
100
  references.clear();
101
+ listings.clear();
64
102
  }
65
103
  }
@@ -1,9 +1,13 @@
1
+ import type fs from "node:fs";
1
2
  import path from "node:path";
2
3
  import {
4
+ type IPluginSourceListing,
3
5
  pluginSourceFilesSignature,
4
6
  provenPluginSourceDigest,
5
7
  } from "ttsc/plugin-source";
6
8
 
9
+ import { filesystemClockReferences } from "../clock/filesystemClockReferences";
10
+ import { filesystemListingDevices } from "../clock/filesystemListingDevices";
7
11
  import { DEFAULT_FILESYSTEM_OPERATIONS } from "../filesystem/DEFAULT_FILESYSTEM_OPERATIONS";
8
12
  import type { TtscTransformFilesystemOperations } from "../filesystem/TtscTransformFilesystemOperations";
9
13
  import { inputMetadataEvidence } from "./inputMetadataEvidence";
@@ -18,6 +22,12 @@ import { inputMetadataEvidence } from "./inputMetadataEvidence";
18
22
  * separability again against the caller's refreshed device clock references; a
19
23
  * historical reference cannot establish safety after a clock rollback.
20
24
  *
25
+ * The population's listing is kept with the digest, so a later proof states the
26
+ * listed directories' stamps instead of enumerating them, on a device where
27
+ * this view saw directory stamps move with an entry change
28
+ * (`filesystemListingDevices`). A directory whose stamps moved, or that cannot
29
+ * be stated, sends the proof back to the walk.
30
+ *
21
31
  * Source enumeration and byte reads use ttsc's native filesystem. Injected
22
32
  * metadata must describe that same source tree; this adapter does not make
23
33
  * arbitrary foreign filesystems interchangeable. The process-wide map has no
@@ -39,7 +49,7 @@ import { inputMetadataEvidence } from "./inputMetadataEvidence";
39
49
  * @evidence contracts/common.md#prohibited-implementation-shortcuts A quiet tracker or equal timestamps alone cannot certify reuse; changed or unavailable evidence requires the real source digest rather than expected output or a compensating cache exception.
40
50
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
41
51
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
42
- * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
52
+ * @evidence contracts/performance.md#efficient-algorithms Reuse with a held listing stats D directories and F files without enumerating any; without one it enumerates D directories. A miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
43
53
  * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
44
54
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
45
55
  */
@@ -54,24 +64,36 @@ export function pluginSourceFilesDigest(
54
64
  * The filesystem must observe the same source tree the selector enumerates.
55
65
  */
56
66
  const evidence = (file: string) => inputMetadataEvidence(file, filesystem);
57
- const before = pluginSourceFilesSignature(key, evidence);
58
67
  const known = DIGESTS.get(key);
68
+ const before = pluginSourceFilesSignature(key, evidence, {
69
+ directory: (entry) => directoryEvidence(entry, filesystem),
70
+ known: known?.listing,
71
+ });
59
72
  if (
60
73
  before !== undefined &&
61
74
  before.separable &&
62
75
  known?.signature === before.signature
63
76
  ) {
77
+ // A walk that stated every directory leaves its listing for the next proof.
78
+ if (before.listing !== undefined && before.listing !== known.listing)
79
+ DIGESTS.set(key, { ...known, listing: before.listing });
64
80
  return known.digest;
65
81
  }
66
82
  const digest = provenPluginSourceDigest(key, projectRoot);
67
- const after = pluginSourceFilesSignature(key, evidence);
83
+ const after = pluginSourceFilesSignature(key, evidence, {
84
+ directory: (entry) => directoryEvidence(entry, filesystem),
85
+ });
68
86
  if (
69
87
  before !== undefined &&
70
88
  after !== undefined &&
71
89
  after.signature === before.signature &&
72
90
  after.separable
73
91
  ) {
74
- DIGESTS.set(key, { digest, signature: after.signature });
92
+ DIGESTS.set(key, {
93
+ digest,
94
+ signature: after.signature,
95
+ listing: after.listing,
96
+ });
75
97
  } else {
76
98
  DIGESTS.delete(key);
77
99
  }
@@ -82,4 +104,50 @@ export function pluginSourceFilesDigest(
82
104
  * The digests kept, by directory, each with the signature of the metadata it
83
105
  * was read under.
84
106
  */
85
- const DIGESTS = new Map<string, { digest: string; signature: string }>();
107
+ const DIGESTS = new Map<
108
+ string,
109
+ { digest: string; signature: string; listing?: IPluginSourceListing }
110
+ >();
111
+
112
+ /**
113
+ * A directory's metadata signature when its stamps witness its entries in this
114
+ * view: a device the view admitted (`filesystemListingDevices`), and both
115
+ * stamps strictly older than the view's reference on it.
116
+ */
117
+ function directoryEvidence(
118
+ directory: string,
119
+ filesystem: TtscTransformFilesystemOperations,
120
+ ): string | undefined {
121
+ const stated = (stats: fs.BigIntStats): string | undefined => {
122
+ const reference = filesystemClockReferences(filesystem).get(stats.dev);
123
+ return filesystemListingDevices(filesystem).has(stats.dev) &&
124
+ reference !== undefined &&
125
+ stats.mtimeNs < reference &&
126
+ stats.ctimeNs < reference
127
+ ? [
128
+ stats.dev,
129
+ stats.ino,
130
+ stats.mode,
131
+ stats.nlink,
132
+ stats.mtimeNs,
133
+ stats.ctimeNs,
134
+ ].join(":")
135
+ : undefined;
136
+ };
137
+ try {
138
+ const entry = filesystem.lstat(directory);
139
+ // A source root reached through a link is stated by the link and by the
140
+ // directory it names: a retarget moves the first, an entry change the
141
+ // second.
142
+ const target = entry.isSymbolicLink()
143
+ ? filesystem.statBigInt(directory)
144
+ : entry;
145
+ if (!target.isDirectory()) return undefined;
146
+ const own = stated(entry);
147
+ if (own === undefined || target === entry) return own;
148
+ const named = stated(target);
149
+ return named === undefined ? undefined : `${own}>${named}`;
150
+ } catch {
151
+ return undefined;
152
+ }
153
+ }