@bevel-software/platform-core-backend 0.7.4 → 0.8.0
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.
- package/LICENSE +202 -202
- package/THIRD-PARTY-NOTICES.md +428 -454
- package/dist/core/core-ports.d.ts +1 -1
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +51 -7
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +5 -3
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +38 -21
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +8 -7
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +1 -1
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +6 -6
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access-declarations.d.ts +5 -5
- package/dist/modules/access/access-declarations.js +3 -3
- package/dist/modules/access/access-mutation.service.d.ts +3 -3
- package/dist/modules/access/access-mutation.service.d.ts.map +1 -1
- package/dist/modules/access/access-mutation.service.js +3 -3
- package/dist/modules/access/access-mutation.service.js.map +1 -1
- package/dist/modules/access/access-splice.js +4 -4
- package/dist/modules/access/access-splice.js.map +1 -1
- package/dist/modules/access/access.routes.js +19 -19
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/creator-access.d.ts +2 -2
- package/dist/modules/access/creator-access.js +5 -5
- package/dist/modules/access/creator-access.js.map +1 -1
- package/dist/modules/access/roles-admin.service.d.ts +18 -4
- package/dist/modules/access/roles-admin.service.d.ts.map +1 -1
- package/dist/modules/access/roles-admin.service.js +14 -4
- package/dist/modules/access/roles-admin.service.js.map +1 -1
- package/dist/modules/code-mode/code-mode-names.d.ts +5 -13
- package/dist/modules/code-mode/code-mode-names.d.ts.map +1 -1
- package/dist/modules/code-mode/code-mode-names.js +5 -27
- package/dist/modules/code-mode/code-mode-names.js.map +1 -1
- package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
- package/dist/modules/code-mode/code-mode.tool.js +29 -7
- package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +11 -52
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +33 -395
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/plugins/index.d.ts +7 -0
- package/dist/modules/plugins/index.d.ts.map +1 -0
- package/dist/modules/plugins/index.js +6 -0
- package/dist/modules/plugins/index.js.map +1 -0
- package/dist/modules/plugins/join-proposals.d.ts +53 -0
- package/dist/modules/plugins/join-proposals.d.ts.map +1 -0
- package/dist/modules/plugins/join-proposals.js +67 -0
- package/dist/modules/plugins/join-proposals.js.map +1 -0
- package/dist/modules/plugins/join-requests.service.d.ts +81 -0
- package/dist/modules/plugins/join-requests.service.d.ts.map +1 -0
- package/dist/modules/plugins/join-requests.service.js +135 -0
- package/dist/modules/plugins/join-requests.service.js.map +1 -0
- package/dist/modules/plugins/plugin-provision.service.d.ts +134 -0
- package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -0
- package/dist/modules/plugins/plugin-provision.service.js +344 -0
- package/dist/modules/plugins/plugin-provision.service.js.map +1 -0
- package/dist/modules/plugins/plugins.contract.d.ts +106 -0
- package/dist/modules/plugins/plugins.contract.d.ts.map +1 -0
- package/dist/modules/plugins/plugins.contract.js +36 -0
- package/dist/modules/plugins/plugins.contract.js.map +1 -0
- package/dist/modules/plugins/plugins.routes.d.ts +42 -0
- package/dist/modules/plugins/plugins.routes.d.ts.map +1 -0
- package/dist/modules/plugins/plugins.routes.js +379 -0
- package/dist/modules/plugins/plugins.routes.js.map +1 -0
- package/dist/modules/plugins/plugins.service.d.ts +60 -0
- package/dist/modules/plugins/plugins.service.d.ts.map +1 -0
- package/dist/modules/plugins/plugins.service.js +172 -0
- package/dist/modules/plugins/plugins.service.js.map +1 -0
- package/dist/modules/skills/pending-skills.service.d.ts +2 -2
- package/dist/modules/skills/pending-skills.service.js +7 -7
- package/dist/modules/skills/pending-skills.service.js.map +1 -1
- package/dist/modules/skills/skills.contract.d.ts +4 -4
- package/dist/modules/skills/skills.contract.d.ts.map +1 -1
- package/dist/modules/skills/skills.contract.js +1 -1
- package/dist/modules/skills/skills.service.js +5 -5
- package/dist/modules/skills/skills.service.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +65 -0
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -0
- package/dist/modules/tool-manuals/mcp-json-discovery.js +276 -0
- package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -0
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +92 -0
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -0
- package/dist/modules/tool-manuals/mcp-server-edit.service.js +328 -0
- package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +38 -12
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.contract.js +1 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +13 -2
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.js +233 -2
- package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +74 -37
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +6 -3
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/workflow/git/git.service.js +2 -2
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/pending-commits.service.d.ts +11 -0
- package/dist/modules/workflow/pending-commits.service.d.ts.map +1 -1
- package/dist/modules/workflow/pending-commits.service.js +37 -9
- package/dist/modules/workflow/pending-commits.service.js.map +1 -1
- package/dist/modules/workflow/pending-commits.worker.d.ts +17 -4
- package/dist/modules/workflow/pending-commits.worker.d.ts.map +1 -1
- package/dist/modules/workflow/pending-commits.worker.js +63 -9
- package/dist/modules/workflow/pending-commits.worker.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +1 -0
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +6 -1
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/kb-seed.service.d.ts +2 -2
- package/dist/modules/workspace/kb-seed.service.d.ts.map +1 -1
- package/dist/modules/workspace/kb-seed.service.js +43 -10
- package/dist/modules/workspace/kb-seed.service.js.map +1 -1
- package/dist/modules/workspace/plugins-migration.d.ts +50 -0
- package/dist/modules/workspace/plugins-migration.d.ts.map +1 -0
- package/dist/modules/workspace/plugins-migration.js +379 -0
- package/dist/modules/workspace/plugins-migration.js.map +1 -0
- package/dist/modules/workspace/workspace.routes.js +3 -3
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +26 -0
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +83 -12
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/shared/kb-layout.test.js +3 -3
- package/dist/shared/kb-layout.test.js.map +1 -1
- package/dist/shared/utcp-namespace.d.ts +6 -27
- package/dist/shared/utcp-namespace.d.ts.map +1 -1
- package/dist/shared/utcp-namespace.js +6 -63
- package/dist/shared/utcp-namespace.js.map +1 -1
- package/dist/shared/variable-refs.d.ts +42 -0
- package/dist/shared/variable-refs.d.ts.map +1 -0
- package/dist/shared/variable-refs.js +60 -0
- package/dist/shared/variable-refs.js.map +1 -0
- package/kb-template/.bevelignore +1 -1
- package/kb-template/AGENTS.md +88 -35
- package/kb-template/KnowledgeBase/How to get started.md +10 -10
- package/kb-template/access.md +36 -36
- package/migrations/meta/0000_snapshot.json +1479 -1479
- package/package.json +5 -4
- package/src/assets.ts +25 -25
- package/src/core/core-ports.ts +106 -106
- package/src/core/create-core-server.ts +55 -9
- package/src/core/create-core-services.ts +48 -24
- package/src/index.ts +69 -69
- package/src/modules/access/__tests__/access-control.atref-batch.test.ts +98 -98
- package/src/modules/access/__tests__/access-declarations.test.ts +28 -28
- package/src/modules/access/__tests__/access-md-format.test.ts +18 -18
- package/src/modules/access/__tests__/access-mutation.service.test.ts +5 -5
- package/src/modules/access/__tests__/access-splice.test.ts +2 -2
- package/src/modules/access/__tests__/access.routes.overrides.test.ts +16 -16
- package/src/modules/access/__tests__/grant-sources.test.ts +12 -12
- package/src/modules/access/__tests__/roles-admin.service.test.ts +13 -1
- package/src/modules/access/access-control.interface.ts +8 -7
- package/src/modules/access/access-control.service.ts +7 -7
- package/src/modules/access/access-declarations.ts +5 -5
- package/src/modules/access/access-mutation.service.ts +3 -3
- package/src/modules/access/access-splice.ts +4 -4
- package/src/modules/access/access.routes.ts +20 -20
- package/src/modules/access/creator-access.ts +5 -5
- package/src/modules/access/roles-admin.service.ts +13 -2
- package/src/modules/admin/admin-access.routes.ts +29 -29
- package/src/modules/auth/__tests__/auth.routes.test.ts +91 -91
- package/src/modules/auth/__tests__/rate-limit.test.ts +36 -36
- package/src/modules/auth/rate-limit.ts +45 -45
- package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +67 -0
- package/src/modules/code-mode/code-mode-names.ts +10 -36
- package/src/modules/code-mode/code-mode.tool.ts +27 -7
- package/src/modules/database/connection.ts +15 -15
- package/src/modules/database/schema.ts +11 -11
- package/src/modules/diff/__tests__/diff.routes.rejectPathsLocked.test.ts +150 -150
- package/src/modules/mcp/mcp.service.ts +57 -435
- package/src/modules/{groups → plugins}/__tests__/join-proposals.test.ts +1 -1
- package/src/modules/{groups → plugins}/__tests__/join-requests.service.test.ts +7 -7
- package/src/modules/{groups/__tests__/group-index.service.test.ts → plugins/__tests__/plugin-index.service.test.ts} +41 -41
- package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +312 -0
- package/src/modules/{groups/__tests__/groups.routes.test.ts → plugins/__tests__/plugins.routes.test.ts} +100 -100
- package/src/modules/plugins/index.ts +17 -0
- package/src/modules/{groups → plugins}/join-proposals.ts +2 -2
- package/src/modules/{groups → plugins}/join-requests.service.ts +8 -8
- package/src/modules/{groups/group-provision.service.ts → plugins/plugin-provision.service.ts} +139 -69
- package/src/modules/{groups/groups.contract.ts → plugins/plugins.contract.ts} +26 -26
- package/src/modules/{groups/groups.routes.ts → plugins/plugins.routes.ts} +102 -102
- package/src/modules/{groups/groups.service.ts → plugins/plugins.service.ts} +43 -43
- package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +143 -143
- package/src/modules/skills/__tests__/pending-skills.service.test.ts +14 -14
- package/src/modules/skills/__tests__/skills.service.test.ts +13 -13
- package/src/modules/skills/pending-skills.service.ts +7 -7
- package/src/modules/skills/skills.contract.ts +4 -4
- package/src/modules/skills/skills.service.ts +5 -5
- package/src/modules/tool-auth/llm-usage-meter.ts +19 -19
- package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +198 -0
- package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +346 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +101 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +3 -3
- package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +2 -2
- package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +27 -27
- package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +3 -3
- package/src/modules/tool-manuals/mcp-json-discovery.ts +328 -0
- package/src/modules/tool-manuals/mcp-server-edit.service.ts +434 -0
- package/src/modules/tool-manuals/tool-manuals.contract.ts +35 -12
- package/src/modules/tool-manuals/tool-manuals.routes.ts +222 -1
- package/src/modules/tool-manuals/tool-manuals.service.ts +82 -42
- package/src/modules/tool-manuals/tool-manuals.tools.ts +6 -3
- package/src/modules/workflow/__tests__/pending-commits.worker.test.ts +118 -0
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +1 -1
- package/src/modules/workflow/git/__tests__/branch-name.test.ts +3 -3
- package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +3 -3
- package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +13 -8
- package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +1 -1
- package/src/modules/workflow/git/__tests__/pull-request.service.test.ts +1 -1
- package/src/modules/workflow/git/git.service.ts +2 -2
- package/src/modules/workflow/pending-commits.service.ts +48 -12
- package/src/modules/workflow/pending-commits.worker.ts +64 -8
- package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +1 -1
- package/src/modules/workflow/review-workflow/__tests__/cancel-pr.test.ts +1 -1
- package/src/modules/workflow/workflow-hooks.ts +101 -101
- package/src/modules/workflow/workflow.service.ts +13 -2
- package/src/modules/workspace/__tests__/kb-seed.service.test.ts +81 -13
- package/src/modules/workspace/__tests__/plugins-migration.test.ts +427 -0
- package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +237 -237
- package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +236 -236
- package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +179 -179
- package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +320 -320
- package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +337 -337
- package/src/modules/workspace/__tests__/workspace.service.test.ts +116 -0
- package/src/modules/workspace/bevel-ignore.ts +66 -66
- package/src/modules/workspace/kb-seed.service.ts +38 -9
- package/src/modules/workspace/plugins-migration.ts +479 -0
- package/src/modules/workspace/session-sink.ts +25 -25
- package/src/modules/workspace/workspace.routes.ts +3 -3
- package/src/modules/workspace/workspace.service.ts +85 -14
- package/src/modules/workspace/workspace.tools.ts +922 -922
- package/src/shared/__tests__/join-request.test.ts +13 -13
- package/src/shared/__tests__/kb-layout.plugin.test.ts +45 -0
- package/src/shared/kb-layout.test.ts +3 -3
- package/src/shared/utcp-namespace.ts +10 -68
- package/src/shared/variable-refs.ts +64 -0
- package/src/modules/groups/__tests__/group-provision.service.test.ts +0 -247
- package/src/modules/groups/index.ts +0 -17
- package/src/shared/__tests__/kb-layout.group.test.ts +0 -45
- /package/kb-template/{Groups → Plugins}/.gitkeep +0 -0
|
@@ -119,6 +119,22 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
119
119
|
*/
|
|
120
120
|
private readonly inFlightBootstraps = new Map<string, Promise<void>>();
|
|
121
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Branches whose clone already got this process's scaffolding top-up.
|
|
124
|
+
* Per-process on purpose: each boot of a new build re-offers the top-up
|
|
125
|
+
* once, which is exactly when an upgrade's migrations must run. Cleared
|
|
126
|
+
* wherever `branchDirs` forgets a branch (delete, failed bootstrap), so a
|
|
127
|
+
* re-created clone is offered the top-up again rather than judged by the
|
|
128
|
+
* fate of one that no longer exists.
|
|
129
|
+
*
|
|
130
|
+
* `inFlightTopUps` is the concurrency half: membership in the Set is
|
|
131
|
+
* claimed BEFORE the (slow, file-moving) top-up finishes, so a concurrent
|
|
132
|
+
* caller that finds the branch claimed must still await the in-flight run
|
|
133
|
+
* — returning early would hand out a workspace mid-migration.
|
|
134
|
+
*/
|
|
135
|
+
private readonly toppedUpBranches = new Set<string>();
|
|
136
|
+
private readonly inFlightTopUps = new Map<string, Promise<void>>();
|
|
137
|
+
|
|
122
138
|
/** Per-workspace-dir `git fetch origin` timestamp + in-flight tracker. */
|
|
123
139
|
private readonly lastFetchAt = new Map<string, number>();
|
|
124
140
|
private readonly inFlightFetches = new Map<string, Promise<void>>();
|
|
@@ -338,6 +354,11 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
338
354
|
// pulls it. Once per branch per process — the cached paths above return
|
|
339
355
|
// before reaching here.
|
|
340
356
|
await this.normalizeCloneTracking(repoDir, branch);
|
|
357
|
+
// Same restart-survivor reasoning for the scaffolding top-up: an
|
|
358
|
+
// UPGRADED deployment reuses this clone, so a top-up bound to fresh
|
|
359
|
+
// clones alone never runs a new build's scaffolding or migrations —
|
|
360
|
+
// the Groups→Plugins rename sat out an upgrade exactly this way.
|
|
361
|
+
await this.topUpScaffolding(repoDir, branch);
|
|
341
362
|
this.branchDirs.set(branch, workspaceDir);
|
|
342
363
|
return this.buildWorkspaceInfo(branch, workspaceDir);
|
|
343
364
|
} catch {
|
|
@@ -376,6 +397,9 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
376
397
|
resolveBootstrap();
|
|
377
398
|
} catch (err) {
|
|
378
399
|
this.branchDirs.delete(branch);
|
|
400
|
+
// The clone was rolled back, and any top-up claim belonged to it — a
|
|
401
|
+
// retried bootstrap must be offered the top-up afresh.
|
|
402
|
+
this.toppedUpBranches.delete(branch);
|
|
379
403
|
rejectBootstrap(err);
|
|
380
404
|
throw err;
|
|
381
405
|
} finally {
|
|
@@ -420,6 +444,7 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
420
444
|
await pending;
|
|
421
445
|
} catch (err) {
|
|
422
446
|
this.branchDirs.delete(branch);
|
|
447
|
+
this.toppedUpBranches.delete(branch);
|
|
423
448
|
throw err;
|
|
424
449
|
}
|
|
425
450
|
}
|
|
@@ -450,6 +475,44 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
450
475
|
}
|
|
451
476
|
}
|
|
452
477
|
|
|
478
|
+
/**
|
|
479
|
+
* The ONE spelling of the best-effort scaffolding top-up (three call sites:
|
|
480
|
+
* the restart-survivor path in `getOrCreateForBranch`, and the
|
|
481
|
+
* already-cloned / fresh-clone paths in `cloneProcessMapForBranch`). Once
|
|
482
|
+
* per branch per process, and SINGLE-FLIGHT: the branch is claimed in
|
|
483
|
+
* `toppedUpBranches` before the run starts, so a concurrent caller that
|
|
484
|
+
* finds it claimed awaits the in-flight run instead of returning a
|
|
485
|
+
* workspace the migration is still moving files under. Never throws — a
|
|
486
|
+
* failed top-up costs the upgrade, not the clone.
|
|
487
|
+
*/
|
|
488
|
+
private async topUpScaffolding(repoDir: string, branch: string): Promise<void> {
|
|
489
|
+
const seedService = this.seedService;
|
|
490
|
+
if (!seedService) return;
|
|
491
|
+
if (this.toppedUpBranches.has(branch)) {
|
|
492
|
+
await this.inFlightTopUps.get(branch);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
this.toppedUpBranches.add(branch);
|
|
496
|
+
const run = (async () => {
|
|
497
|
+
try {
|
|
498
|
+
await seedService.topUpWorkspace(repoDir, branch);
|
|
499
|
+
} catch (topUpErr) {
|
|
500
|
+
console.error(
|
|
501
|
+
`[workspace] scaffolding top-up failed for branch "${branch}" (clone kept):`,
|
|
502
|
+
redactError(topUpErr),
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
})();
|
|
506
|
+
this.inFlightTopUps.set(branch, run);
|
|
507
|
+
try {
|
|
508
|
+
await run;
|
|
509
|
+
} finally {
|
|
510
|
+
if (this.inFlightTopUps.get(branch) === run) {
|
|
511
|
+
this.inFlightTopUps.delete(branch);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
453
516
|
private async cloneProcessMapForBranch(workspaceDir: string, branch: string): Promise<void> {
|
|
454
517
|
const targetDir = path.join(workspaceDir, this.kbDirName);
|
|
455
518
|
|
|
@@ -498,6 +561,11 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
498
561
|
// it never touches the working tree, and a drifted config is what
|
|
499
562
|
// breaks the next pull.
|
|
500
563
|
await this.normalizeCloneTracking(targetDir, branch);
|
|
564
|
+
// An upgraded deployment REUSES this persistent clone, so a top-up
|
|
565
|
+
// bound to fresh clones alone never runs a new build's scaffolding
|
|
566
|
+
// or migrations here — the Groups→Plugins rename sat out an upgrade
|
|
567
|
+
// for exactly this reason.
|
|
568
|
+
await this.topUpScaffolding(targetDir, branch);
|
|
501
569
|
return;
|
|
502
570
|
}
|
|
503
571
|
// Half-built dir — wipe and re-clone.
|
|
@@ -539,20 +607,14 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
539
607
|
);
|
|
540
608
|
}
|
|
541
609
|
// Fill in any base scaffolding this branch is missing, now that it's
|
|
542
|
-
// freshly checked out. Runs on whichever branch the user loaded (not
|
|
543
|
-
// protected ones)
|
|
544
|
-
//
|
|
545
|
-
//
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
console.error(
|
|
551
|
-
`[workspace] scaffolding top-up failed for branch "${branch}" (clone kept):`,
|
|
552
|
-
redactError(topUpErr),
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
610
|
+
// freshly checked out. Runs on whichever branch the user loaded (not
|
|
611
|
+
// just protected ones). Best-effort inside the helper — like the
|
|
612
|
+
// onWorkspaceCloned listener above — so even a future change that lets
|
|
613
|
+
// it throw can never roll back an otherwise-good clone. (The
|
|
614
|
+
// once-per-process guard is a formality here: a branch being freshly
|
|
615
|
+
// cloned was either never topped up or had its claim cleared with the
|
|
616
|
+
// clone it belonged to.)
|
|
617
|
+
await this.topUpScaffolding(targetDir, branch);
|
|
556
618
|
} catch (err) {
|
|
557
619
|
const redacted = redactError(err);
|
|
558
620
|
console.error(`[workspace] Failed to clone for branch "${branch}":`, redacted);
|
|
@@ -581,6 +643,10 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
581
643
|
await fs.rm(workspaceDir, { recursive: true, force: true });
|
|
582
644
|
const branch = branchForWorkspaceId(workspaceId);
|
|
583
645
|
this.branchDirs.delete(branch);
|
|
646
|
+
// The top-up claim died with the clone it was made against — a branch
|
|
647
|
+
// re-created later gets a fresh clone and must be offered it again (and
|
|
648
|
+
// without this, long-lived processes would accumulate dead branch names).
|
|
649
|
+
this.toppedUpBranches.delete(branch);
|
|
584
650
|
}
|
|
585
651
|
|
|
586
652
|
async listFiles(workspaceId: string, readFilter?: ReadTreeFilter): Promise<FileTreeEntry> {
|
|
@@ -1218,6 +1284,11 @@ export class WorkspaceService implements IWorkspaceService {
|
|
|
1218
1284
|
try {
|
|
1219
1285
|
await fs.rm(dir, { recursive: true, force: true });
|
|
1220
1286
|
this.branchDirs.delete(branchForWorkspaceId(entry.name));
|
|
1287
|
+
// The top-up claim dies with the clone (same rule as every other
|
|
1288
|
+
// eviction site): a branch re-created after the sweep gets a fresh
|
|
1289
|
+
// clone that must be OFFERED the scaffolding top-up, not judged by
|
|
1290
|
+
// the fate of a directory that no longer exists.
|
|
1291
|
+
this.toppedUpBranches.delete(branchForWorkspaceId(entry.name));
|
|
1221
1292
|
removed.push(entry.name);
|
|
1222
1293
|
} catch (err) {
|
|
1223
1294
|
console.warn(
|