Skip to content

Commit c111d07

Browse files
committed
refactor(project): Rename leftover task terminology to stage in build cache
The step-based build API renamed the build-time unit from "task" to "stage" (one stage per legacy task, one per step of a step-based task), but several cache identifiers kept the old "task" name while holding stage data. Align them with what the code actually stores. - Index cache: the stage-execution-order field `tasks` -> `stages`. It holds one entry per stage, keyed by stage id, not per task. - Persistent storage: the `task_metadata` table -> `stage_request_metadata` (it holds a stage's resource request graphs and non-resource inputs, not task output), and its accessors readTaskMetadata/writeTaskMetadata -> readStageRequestMetadata/writeStageRequestMetadata on BuildCacheStorage and CacheManager. - In-code identifiers: tasksWithDepRequests -> stagesWithDepRequests, taskDependencySignatures -> stageDependencySignatures, #anyTaskHasRootRequests -> #anyStageHasRootRequests, and cache-layer comments/JSDoc that called a stage a "task". Genuine task terms are kept: taskName/stepName, the task/{taskName} stage-id prefix, setTasks, allTasksCompleted, and references to step-based and legacy build tasks. The table and field renames change the on-disk cache format. The incremental build cache is unreleased and obsolete versioned cache directories are ignored and rebuilt, so no migration or CACHE_VERSION bump is required. Also updates the incremental-build skill architecture doc to match.
1 parent 9084f6a commit c111d07

9 files changed

Lines changed: 138 additions & 138 deletions

File tree

‎.claude/skills/incremental-build/architecture.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ On a failed re-resolve `Supervisor` flags the surviving stack degraded (last-goo
255255
| content (CAS: integrity -> gzip-compressed BLOB) |
256256
| index_cache (resource index trees, by kind="source") |
257257
| stage_metadata (cached stage results, by stage signature) |
258-
| task_metadata (resource requests per stage, by type) |
258+
| stage_request_metadata (resource requests per stage, by type)|
259259
| result_metadata(per-build result metadata) |
260260
+-----------------------------------------------------------------+
261261
```
@@ -279,7 +279,7 @@ A task's output can depend on inputs that are not resources: an environment vari
279279

280280
Tracking has a record side and a lookup side, mirroring the resource-request flow:
281281

282-
- **Record** (task executes): the TaskRunner hands the task a `MonitoredTaskUtil` instead of the raw `TaskUtil`. It is a Proxy that preserves the wrapped shape (a custom task's limited interface stays limited) and records every tracked read as `{type, name, value}`, normalizing the value via `normalizeInputValue`. `getProject(name)` returns a wrapped project whose tracked accessors record under the project's name; its `getReader()` result is wrapped in a `MonitoredReader` so the resources the task reads through it are recorded as resource requests, and, for the project being built, its `getRootReader()` result is wrapped too so reads of files outside the UI5 resource model are recorded as root requests (see the reader-monitoring note below), while untracked members (`getRootPath`, `getSpecVersion`, ...) pass straight through unrecorded. After the task, the TaskRunner drains `getInputRecording()` into `ProjectBuildCache.recordStageResult`, which builds a `TaskInputSet` and folds its signature into the task's project-component signature (`combineProjectAndInputSignature`). Only entry type/name are persisted (`task_metadata` type `"input"`), never values.
282+
- **Record** (task executes): the TaskRunner hands the task a `MonitoredTaskUtil` instead of the raw `TaskUtil`. It is a Proxy that preserves the wrapped shape (a custom task's limited interface stays limited) and records every tracked read as `{type, name, value}`, normalizing the value via `normalizeInputValue`. `getProject(name)` returns a wrapped project whose tracked accessors record under the project's name; its `getReader()` result is wrapped in a `MonitoredReader` so the resources the task reads through it are recorded as resource requests, and, for the project being built, its `getRootReader()` result is wrapped too so reads of files outside the UI5 resource model are recorded as root requests (see the reader-monitoring note below), while untracked members (`getRootPath`, `getSpecVersion`, ...) pass straight through unrecorded. After the task, the TaskRunner drains `getInputRecording()` into `ProjectBuildCache.recordStageResult`, which builds a `TaskInputSet` and folds its signature into the task's project-component signature (`combineProjectAndInputSignature`). Only entry type/name are persisted (`stage_request_metadata` type `"input"`), never values.
283283
- **Lookup** (later build): `BuildStageCache.getInputSignature(resolveValue)` recomputes the input signature, re-reading each recorded input's *current* value through `ProjectBuildContext.resolveInputValue(type, name)` (which reaches `process.env` and the current project graph). A value that differs from the one baked into the cached stage signature misses the cache and re-runs the task. Record and lookup normalize through the same `normalizeInputValue`, so equal values compare equal.
284284

285285
Excluded from input-value tracking: mutations (`setTag`/`clearTag`, already captured as tag operations in the hash trees), constructors (`resourceFactory`), readers (`getReader`/`getRootReader`), side effects (`registerCleanupTask`), and the FS-path accessors (`getRootPath`/`getSourcePath`) whose absolute, machine-specific values would make cache entries non-portable.
@@ -601,7 +601,7 @@ project.getProjectResources().setStage(stageName, stageCache.stage,
601601
- content(integrity TEXT PK, data BLOB) # CAS: gzip above ~128 bytes
602602
- index_cache(project_id, build_signature, kind, data) # kind: "source"
603603
- stage_metadata(project_id, build_signature, stage_id, stage_signature, data)
604-
- task_metadata(project_id, build_signature, stage_id, type, data) # stage_id is the STAGE id (task/{taskName} or task/{taskName}::step/{stepName}); type: "project" | "dependencies" | "input" | "root" | "root-no-gitignore"
604+
- stage_request_metadata(project_id, build_signature, stage_id, type, data) # stage_id is the STAGE id (task/{taskName} or task/{taskName}::step/{stepName}); type: "project" | "dependencies" | "input" | "root" | "root-no-gitignore"
605605
- result_metadata(project_id, build_signature, stage_signature, data)
606606
```
607607

@@ -612,7 +612,7 @@ Note: Both CAS content and metadata BLOBs are gzip-compressed via thresholds (`C
612612
The index cache (one row per `(project_id, build_signature, kind="source")`) contains:
613613
- `indexTimestamp`: creation timestamp (used for racy-git detection)
614614
- `root`: serialized Merkle tree (TreeNode hierarchy)
615-
- `tasks`: array of `[stageId, stepBased ? 1 : 0]` recording the stage execution order (one entry per stage: a legacy task's `task/{taskName}`, or a step-based task's per-step `task/{taskName}::step/{stepName}`) and whether the stage ran the step runner (step-based), which drives delta tracking. The stage id is the `task_metadata` key everything else for that stage is stored under
615+
- `stages`: array of `[stageId, stepBased ? 1 : 0]` recording the stage execution order (one entry per stage: a legacy task's `task/{taskName}`, or a step-based task's per-step `task/{taskName}::step/{stepName}`) and whether the stage ran the step runner (step-based), which drives delta tracking. The stage id is the `stage_request_metadata` key everything else for that stage is stored under
616616

617617
#### Stage Metadata Format
618618

‎packages/project/lib/build/cache/BuildCacheStorage.js‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ const METADATA_COMPRESSION_THRESHOLD = 4096;
1010
const CONTENT_COMPRESSION_THRESHOLD = 128;
1111

1212
/** All live data table names */
13-
const DATA_TABLES = ["content", "index_cache", "stage_metadata", "task_metadata", "result_metadata"];
13+
const DATA_TABLES = ["content", "index_cache", "stage_metadata", "stage_request_metadata", "result_metadata"];
1414

1515
/**
1616
* Unified SQLite-backed storage for the build cache
1717
*
18-
* Stores both metadata (index caches, stage metadata, task metadata, result metadata)
18+
* Stores both metadata (index caches, stage metadata, stage request metadata, result metadata)
1919
* and content-addressable resource content (gzip-compressed BLOBs) in a single database.
2020
*
2121
* @class
@@ -70,7 +70,7 @@ export default class BuildCacheStorage {
7070
PRIMARY KEY (project_id, build_signature, stage_id, stage_signature)
7171
) WITHOUT ROWID;
7272
73-
CREATE TABLE IF NOT EXISTS task_metadata (
73+
CREATE TABLE IF NOT EXISTS stage_request_metadata (
7474
project_id TEXT NOT NULL,
7575
build_signature TEXT NOT NULL,
7676
stage_id TEXT NOT NULL,
@@ -127,12 +127,12 @@ export default class BuildCacheStorage {
127127
),
128128

129129
// Stage request metadata
130-
readTaskMetadata: this.#db.prepare(
131-
`SELECT data FROM task_metadata
130+
readStageRequestMetadata: this.#db.prepare(
131+
`SELECT data FROM stage_request_metadata
132132
WHERE project_id = ? AND build_signature = ? AND stage_id = ? AND type = ?`
133133
),
134-
writeTaskMetadata: this.#db.prepare(
135-
`INSERT OR REPLACE INTO task_metadata
134+
writeStageRequestMetadata: this.#db.prepare(
135+
`INSERT OR REPLACE INTO stage_request_metadata
136136
(project_id, build_signature, stage_id, type, data) VALUES (?, ?, ?, ?, ?)`
137137
),
138138

@@ -335,9 +335,9 @@ export default class BuildCacheStorage {
335335
* @param {string} type "project" or "dependency"
336336
* @returns {object|null} Parsed stage metadata or null if not found
337337
*/
338-
readTaskMetadata(projectId, buildSignature, stageId, type) {
338+
readStageRequestMetadata(projectId, buildSignature, stageId, type) {
339339
try {
340-
const row = this.#stmts.readTaskMetadata.get(
340+
const row = this.#stmts.readStageRequestMetadata.get(
341341
projectId, buildSignature, stageId, type
342342
);
343343
return row ? this.#deserializeMetadata(row.data) : null;
@@ -359,8 +359,8 @@ export default class BuildCacheStorage {
359359
* @param {string} type "project" or "dependency"
360360
* @param {object} metadata Stage metadata object to serialize
361361
*/
362-
writeTaskMetadata(projectId, buildSignature, stageId, type, metadata) {
363-
this.#stmts.writeTaskMetadata.run(
362+
writeStageRequestMetadata(projectId, buildSignature, stageId, type, metadata) {
363+
this.#stmts.writeStageRequestMetadata.run(
364364
projectId, buildSignature, stageId, type, this.#serializeMetadata(metadata)
365365
);
366366
}

‎packages/project/lib/build/cache/BuildStageCache.js‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export default class BuildStageCache {
5555
// managers because getRootReader's useGitignore flag changes which resources a glob matches, so a
5656
// request recorded with the flag on must re-materialize against a root reader with the flag on.
5757
// Both are resolved against a dedicated root reader (not the stage-pipeline project reader) and
58-
// their signatures fold into the task's stage signature.
58+
// their signatures fold into the stage signature.
5959
#rootRequestManagers;
6060

6161
// Tracks non-resource inputs (environment variables and TaskUtil interface reads) recorded during
62-
// the last execution of this task. Its signature is folded into the task's stage signature so that
62+
// the last execution of this stage. Its signature is folded into the stage signature so that
6363
// a changed input invalidates the cached result. Only entry names are persisted; values are
6464
// re-read on lookup (see #inputSet.getSignatureWithCurrentValues).
6565
#inputSet;
@@ -120,7 +120,7 @@ export default class BuildStageCache {
120120
* @param {boolean} options.stepBased Whether the stage ran the step runner, driving per-step delta tracking
121121
* @param {object} options.projectRequests Cached project request manager data
122122
* @param {object} options.dependencyRequests Cached dependency request manager data
123-
* @param {object} [options.inputSet] Cached task input set data
123+
* @param {object} [options.inputSet] Cached stage input set data
124124
* @param {object} [options.rootRequests] Cached useGitignore:true root request manager data
125125
* @param {object} [options.rootNoGitignoreRequests] Cached useGitignore:false root request manager data
126126
* @returns {BuildStageCache} Restored stage cache instance
@@ -190,12 +190,12 @@ export default class BuildStageCache {
190190
}
191191

192192
/**
193-
* Returns the signature of this task's recorded non-resource inputs, computed against the current
193+
* Returns the signature of this stage's recorded non-resource inputs, computed against the current
194194
* environment and project graph.
195195
*
196196
* Used on cache lookup: each recorded input name is re-evaluated via the given resolver, so the
197197
* returned signature reflects the environment and graph of the build performing the lookup. When
198-
* the task recorded no inputs, a stable empty-input digest is returned.
198+
* the stage recorded no inputs, a stable empty-input digest is returned.
199199
*
200200
* @public
201201
* @param {function(string, string, (string|undefined)): (string|undefined)} [resolveValue]
@@ -208,7 +208,7 @@ export default class BuildStageCache {
208208
}
209209

210210
/**
211-
* Returns whether this task recorded any root resource requests
211+
* Returns whether this stage recorded any root resource requests
212212
*
213213
* @public
214214
* @returns {boolean}
@@ -242,9 +242,9 @@ export default class BuildStageCache {
242242
/**
243243
* Returns a single signature aggregating the current signatures of both root request sets.
244244
*
245-
* Folded into the task's stage signature so a changed root file misses the cached stage. Unlike
245+
* Folded into the stage signature so a changed root file misses the cached stage. Unlike
246246
* the project and dependency components, root requests are not delta-tracked: the aggregate is one
247-
* value, so any root change re-runs the whole task. A task with no recorded root requests yields a
247+
* value, so any root change re-runs the whole stage. A stage with no recorded root requests yields a
248248
* stable digest that stays constant across builds.
249249
*
250250
* @public
@@ -292,7 +292,7 @@ export default class BuildStageCache {
292292
}
293293

294294
/**
295-
* Returns whether this task has any recorded dependency resource requests
295+
* Returns whether this stage has any recorded dependency resource requests
296296
*
297297
* @public
298298
* @returns {boolean}
@@ -306,7 +306,7 @@ export default class BuildStageCache {
306306
*
307307
* Since dependency resources may change independently from this project's cache, a full
308308
* refresh of the dependency index is required at the beginning of every build from cache.
309-
* This ensures all dependency resources are current before task execution.
309+
* This ensures all dependency resources are current before stage execution.
310310
*
311311
* @public
312312
* @param {module:@ui5/fs.AbstractReader} dependencyReader Reader for accessing dependency resources
@@ -317,11 +317,11 @@ export default class BuildStageCache {
317317
}
318318

319319
/**
320-
* Gets all project index signatures for this task
320+
* Gets all project index signatures for this stage
321321
*
322322
* Returns signatures from all recorded project-request sets. Each signature represents
323323
* a unique combination of resources, belonging to the current project, that were accessed
324-
* during task execution. These can be used as cache keys for restoring cached task results.
324+
* during stage execution. These can be used as cache keys for restoring cached stage results.
325325
*
326326
* @public
327327
* @returns {string[]} Array of signature strings
@@ -332,12 +332,12 @@ export default class BuildStageCache {
332332
}
333333

334334
/**
335-
* Gets all dependency index signatures for this task
335+
* Gets all dependency index signatures for this stage
336336
*
337337
* Returns signatures from all recorded dependency-request sets. Each signature represents
338338
* a unique combination of resources, belonging to all dependencies of the current project,
339-
* that were accessed during task execution. These can be used as cache keys for restoring
340-
* cached task results.
339+
* that were accessed during stage execution. These can be used as cache keys for restoring
340+
* cached stage results.
341341
*
342342
* @public
343343
* @returns {string[]} Array of signature strings
@@ -351,7 +351,7 @@ export default class BuildStageCache {
351351
* Gets all project index delta transitions for differential updates
352352
*
353353
* Returns a map of signature transitions and their associated changed resource paths
354-
* for project resources. Used when tasks support differential updates to identify
354+
* for project resources. Used when stages support differential updates to identify
355355
* which resources changed between cache states.
356356
*
357357
* @public
@@ -366,7 +366,7 @@ export default class BuildStageCache {
366366
* Gets all dependency index delta transitions for differential updates
367367
*
368368
* Returns a map of signature transitions and their associated changed resource paths
369-
* for dependency resources. Used when tasks support differential updates to identify
369+
* for dependency resources. Used when stages support differential updates to identify
370370
* which dependency resources changed between cache states.
371371
*
372372
* @public
@@ -493,7 +493,7 @@ export default class BuildStageCache {
493493
}
494494

495495
/**
496-
* Serializes the task cache to plain objects for persistence
496+
* Serializes the stage cache to plain objects for persistence
497497
*
498498
* Exports both project and dependency resource request graphs in a format suitable
499499
* for JSON serialization. The serialized data can be passed to fromCache() to restore

‎packages/project/lib/build/cache/CacheManager.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export const CACHE_VERSION = "v0_9";
1818
* for both metadata and content-addressable resource content
1919
*
2020
* CacheManager delegates metadata operations (index caches, stage metadata,
21-
* task metadata, result metadata) and binary resource content (gzip-compressed
21+
* stage request metadata, result metadata) and binary resource content (gzip-compressed
2222
* BLOBs) to BuildCacheStorage (single SQLite database).
2323
*
2424
* The cache is organized by:
2525
* 1. Project ID (package name)
2626
* 2. Build signature (hash of build configuration)
27-
* 3. Stage/task identifiers and signatures
27+
* 3. Stage identifiers and signatures
2828
*
2929
* Key features:
3030
* - Content-addressable storage with deduplication
@@ -119,7 +119,7 @@ export default class CacheManager {
119119
* @param {string} projectId Project identifier
120120
* @param {string} buildSignature Build signature hash
121121
* @param {string} kind "source" or "result"
122-
* @param {object} index Index object containing resource tree and task metadata
122+
* @param {object} index Index object containing resource tree and stage list
123123
*/
124124
writeIndexCache(projectId, buildSignature, kind, index) {
125125
this.#storage.writeIndexCache(projectId, buildSignature, kind, index);
@@ -163,8 +163,8 @@ export default class CacheManager {
163163
* @param {string} type "project" or "dependency"
164164
* @returns {object|null} Parsed stage metadata or null if not found
165165
*/
166-
readTaskMetadata(projectId, buildSignature, stageId, type) {
167-
return this.#storage.readTaskMetadata(projectId, buildSignature, stageId, type);
166+
readStageRequestMetadata(projectId, buildSignature, stageId, type) {
167+
return this.#storage.readStageRequestMetadata(projectId, buildSignature, stageId, type);
168168
}
169169

170170
/**
@@ -177,8 +177,8 @@ export default class CacheManager {
177177
* @param {string} type "project" or "dependency"
178178
* @param {object} metadata Stage metadata object to serialize
179179
*/
180-
writeTaskMetadata(projectId, buildSignature, stageId, type, metadata) {
181-
this.#storage.writeTaskMetadata(projectId, buildSignature, stageId, type, metadata);
180+
writeStageRequestMetadata(projectId, buildSignature, stageId, type, metadata) {
181+
this.#storage.writeStageRequestMetadata(projectId, buildSignature, stageId, type, metadata);
182182
}
183183

184184
/**

0 commit comments

Comments
 (0)