@kuafucloud/repo-kit 0.0.0-stage → 0.2.2-alpha.4
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.md +9 -0
- package/README.md +6 -2
- package/assets/git-hooks/check-push.cjs +21 -0
- package/assets/git-hooks/pre-push +7 -0
- package/assets/git-hooks/prepare-commit-msg +5 -0
- package/assets/verification/heavy-test-admission-core.d.mts +1 -0
- package/assets/verification/heavy-test-admission-core.mjs +10 -0
- package/assets/verification/host-process-lock.d.mts +24 -0
- package/assets/verification/host-process-lock.mjs +140 -0
- package/assets/verification/test-heavy-admission.d.mts +4 -0
- package/assets/verification/test-heavy-admission.mjs +34 -0
- package/bin/kuafu-guard.mjs +3 -0
- package/bin/kuafu-verify.mjs +3 -0
- package/dist/cli/guard.d.ts +1 -0
- package/dist/cli/guard.js +59 -0
- package/dist/cli/verify.d.ts +1 -0
- package/dist/cli/verify.js +58 -0
- package/dist/guard/core/config.d.ts +7 -0
- package/dist/guard/core/config.js +159 -0
- package/dist/guard/core/engine.d.ts +2 -0
- package/dist/guard/core/engine.js +151 -0
- package/dist/guard/core/formatters/sarif-rules.d.ts +2 -0
- package/dist/guard/core/formatters/sarif-rules.js +67 -0
- package/dist/guard/core/formatters/sarif.d.ts +2 -0
- package/dist/guard/core/formatters/sarif.js +3 -0
- package/dist/guard/core/formatters/text.d.ts +2 -0
- package/dist/guard/core/formatters/text.js +22 -0
- package/dist/guard/core/index.d.ts +5 -0
- package/dist/guard/core/index.js +5 -0
- package/dist/guard/core/types.d.ts +94 -0
- package/dist/guard/core/types.js +1 -0
- package/dist/guard/hooks/install-rules.d.ts +2 -0
- package/dist/guard/hooks/install-rules.js +5 -0
- package/dist/guard/hooks/install.d.ts +36 -0
- package/dist/guard/hooks/install.js +212 -0
- package/dist/guard/hooks/push.d.ts +1 -0
- package/dist/guard/hooks/push.js +5 -0
- package/dist/guard/index.d.ts +16 -0
- package/dist/guard/index.js +16 -0
- package/dist/guard/product-roots.d.ts +12 -0
- package/dist/guard/product-roots.js +37 -0
- package/dist/guard/repo-args.d.ts +8 -0
- package/dist/guard/repo-args.js +75 -0
- package/dist/guard/repo-output-rules.d.ts +12 -0
- package/dist/guard/repo-output-rules.js +44 -0
- package/dist/guard/repo.d.ts +21 -0
- package/dist/guard/repo.js +74 -0
- package/dist/guard/rules/external/api/collect-orphan-tests.d.ts +2 -0
- package/dist/guard/rules/external/api/collect-orphan-tests.js +34 -0
- package/dist/guard/rules/external/api/collect.d.ts +2 -0
- package/dist/guard/rules/external/api/collect.js +419 -0
- package/dist/guard/rules/external/api/validate-orphan-tests.d.ts +2 -0
- package/dist/guard/rules/external/api/validate-orphan-tests.js +10 -0
- package/dist/guard/rules/external/api/validate.d.ts +2 -0
- package/dist/guard/rules/external/api/validate.js +278 -0
- package/dist/guard/rules/external/app/native-source-rules.d.ts +6 -0
- package/dist/guard/rules/external/app/native-source-rules.js +164 -0
- package/dist/guard/rules/external/app/validate-native-source-boundary.d.ts +2 -0
- package/dist/guard/rules/external/app/validate-native-source-boundary.js +187 -0
- package/dist/guard/rules/external/boundary/check.d.ts +4 -0
- package/dist/guard/rules/external/boundary/check.js +198 -0
- package/dist/guard/rules/external/extension/collect.d.ts +1 -0
- package/dist/guard/rules/external/extension/collect.js +1 -0
- package/dist/guard/rules/external/extension/electron-boundary-rules.d.ts +6 -0
- package/dist/guard/rules/external/extension/electron-boundary-rules.js +10 -0
- package/dist/guard/rules/external/extension/index.d.ts +6 -0
- package/dist/guard/rules/external/extension/index.js +29 -0
- package/dist/guard/rules/external/extension/manual-cross-call-rules.d.ts +19 -0
- package/dist/guard/rules/external/extension/manual-cross-call-rules.js +19 -0
- package/dist/guard/rules/external/extension/resolve-import.d.ts +1 -0
- package/dist/guard/rules/external/extension/resolve-import.js +43 -0
- package/dist/guard/rules/external/extension/scan-relative-dependencies.d.ts +5 -0
- package/dist/guard/rules/external/extension/scan-relative-dependencies.js +53 -0
- package/dist/guard/rules/external/extension/scan-source.d.ts +11 -0
- package/dist/guard/rules/external/extension/scan-source.js +25 -0
- package/dist/guard/rules/external/extension/source-import-boundary-rules.d.ts +26 -0
- package/dist/guard/rules/external/extension/source-import-boundary-rules.js +40 -0
- package/dist/guard/rules/external/extension/test-layer-import-rules.d.ts +1 -0
- package/dist/guard/rules/external/extension/test-layer-import-rules.js +16 -0
- package/dist/guard/rules/external/extension/types.d.ts +51 -0
- package/dist/guard/rules/external/extension/types.js +1 -0
- package/dist/guard/rules/external/extension/unused-export-rules.d.ts +23 -0
- package/dist/guard/rules/external/extension/unused-export-rules.js +119 -0
- package/dist/guard/rules/external/extension/unused-module-rules.d.ts +6 -0
- package/dist/guard/rules/external/extension/unused-module-rules.js +90 -0
- package/dist/guard/rules/external/extension/validate-admin.d.ts +8 -0
- package/dist/guard/rules/external/extension/validate-admin.js +73 -0
- package/dist/guard/rules/external/extension/validate-database.d.ts +3 -0
- package/dist/guard/rules/external/extension/validate-database.js +4 -0
- package/dist/guard/rules/external/extension/validate-electron-boundary.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-electron-boundary.js +18 -0
- package/dist/guard/rules/external/extension/validate-empty-dirs.d.ts +9 -0
- package/dist/guard/rules/external/extension/validate-empty-dirs.js +44 -0
- package/dist/guard/rules/external/extension/validate-extension-kit-server-boundary.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-extension-kit-server-boundary.js +116 -0
- package/dist/guard/rules/external/extension/validate-features.d.ts +7 -0
- package/dist/guard/rules/external/extension/validate-features.js +27 -0
- package/dist/guard/rules/external/extension/validate-manual-cross-extension-call.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-manual-cross-extension-call.js +131 -0
- package/dist/guard/rules/external/extension/validate-peer-extension-import.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-peer-extension-import.js +41 -0
- package/dist/guard/rules/external/extension/validate-server-cross-domain-import.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-server-cross-domain-import.js +48 -0
- package/dist/guard/rules/external/extension/validate-server-index-api-entry-satisfies.d.ts +1 -0
- package/dist/guard/rules/external/extension/validate-server-index-api-entry-satisfies.js +1 -0
- package/dist/guard/rules/external/extension/validate-shared-import-boundary.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-shared-import-boundary.js +40 -0
- package/dist/guard/rules/external/extension/validate-shared.d.ts +1 -0
- package/dist/guard/rules/external/extension/validate-shared.js +1 -0
- package/dist/guard/rules/external/extension/validate-test-layer-boundary.d.ts +8 -0
- package/dist/guard/rules/external/extension/validate-test-layer-boundary.js +59 -0
- package/dist/guard/rules/external/extension/validate-test-mirror.d.ts +4 -0
- package/dist/guard/rules/external/extension/validate-test-mirror.js +32 -0
- package/dist/guard/rules/external/extension/validate-top-level.d.ts +7 -0
- package/dist/guard/rules/external/extension/validate-top-level.js +76 -0
- package/dist/guard/rules/external/extension/validate-unused-export.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-unused-export.js +187 -0
- package/dist/guard/rules/external/extension/validate-unused-module.d.ts +2 -0
- package/dist/guard/rules/external/extension/validate-unused-module.js +38 -0
- package/dist/guard/rules/external/index.d.ts +1 -0
- package/dist/guard/rules/external/index.js +1 -0
- package/dist/guard/rules/external/npm-dependency-policy.d.ts +14 -0
- package/dist/guard/rules/external/npm-dependency-policy.js +216 -0
- package/dist/guard/rules/external/rules.d.ts +2 -0
- package/dist/guard/rules/external/rules.js +222 -0
- package/dist/guard/rules/external/shared/config.d.ts +3 -0
- package/dist/guard/rules/external/shared/config.js +14 -0
- package/dist/guard/rules/external/shared/diagnostic.d.ts +4 -0
- package/dist/guard/rules/external/shared/diagnostic.js +12 -0
- package/dist/guard/rules/external/shared/records.d.ts +4 -0
- package/dist/guard/rules/external/shared/records.js +46 -0
- package/dist/guard/rules/external/shared/ts-ast.d.ts +8 -0
- package/dist/guard/rules/external/shared/ts-ast.js +103 -0
- package/dist/guard/rules/external/shared/types.d.ts +159 -0
- package/dist/guard/rules/external/shared/types.js +1 -0
- package/dist/guard/rules/external/shared/validate-layer-key.d.ts +2 -0
- package/dist/guard/rules/external/shared/validate-layer-key.js +35 -0
- package/dist/guard/rules/external/story-rules.d.ts +15 -0
- package/dist/guard/rules/external/story-rules.js +59 -0
- package/dist/guard/rules/shared/extension/api-entry-tuple-rules.d.ts +7 -0
- package/dist/guard/rules/shared/extension/api-entry-tuple-rules.js +6 -0
- package/dist/guard/rules/shared/extension/collect.d.ts +5 -0
- package/dist/guard/rules/shared/extension/collect.js +231 -0
- package/dist/guard/rules/shared/extension/database-reference-rules.d.ts +4 -0
- package/dist/guard/rules/shared/extension/database-reference-rules.js +5 -0
- package/dist/guard/rules/shared/extension/database-source-rules.d.ts +17 -0
- package/dist/guard/rules/shared/extension/database-source-rules.js +595 -0
- package/dist/guard/rules/shared/extension/database-structure-rules.d.ts +3 -0
- package/dist/guard/rules/shared/extension/database-structure-rules.js +63 -0
- package/dist/guard/rules/shared/extension/server-index-source-rules.d.ts +2 -0
- package/dist/guard/rules/shared/extension/server-index-source-rules.js +91 -0
- package/dist/guard/rules/shared/extension/shared-consumer-rules.d.ts +23 -0
- package/dist/guard/rules/shared/extension/shared-consumer-rules.js +158 -0
- package/dist/guard/rules/shared/extension/shared-structure-rules.d.ts +6 -0
- package/dist/guard/rules/shared/extension/shared-structure-rules.js +27 -0
- package/dist/guard/rules/shared/extension/validate-database.d.ts +4 -0
- package/dist/guard/rules/shared/extension/validate-database.js +15 -0
- package/dist/guard/rules/shared/extension/validate-server-index-api-entry-satisfies.d.ts +2 -0
- package/dist/guard/rules/shared/extension/validate-server-index-api-entry-satisfies.js +9 -0
- package/dist/guard/rules/shared/extension/validate-shared.d.ts +18 -0
- package/dist/guard/rules/shared/extension/validate-shared.js +149 -0
- package/dist/host-protocol.d.ts +2 -0
- package/dist/host-protocol.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/verify/artifact-recovery-rules.d.ts +39 -0
- package/dist/verify/artifact-recovery-rules.js +48 -0
- package/dist/verify/artifact-session.d.ts +91 -0
- package/dist/verify/artifact-session.js +443 -0
- package/dist/verify/checkout-environment-rules.d.ts +2 -0
- package/dist/verify/checkout-environment-rules.js +25 -0
- package/dist/verify/checkout-environment.d.ts +8 -0
- package/dist/verify/checkout-environment.js +24 -0
- package/dist/verify/commit-candidate-rules.d.ts +3 -0
- package/dist/verify/commit-candidate-rules.js +33 -0
- package/dist/verify/commit-gate.d.ts +64 -0
- package/dist/verify/commit-gate.js +144 -0
- package/dist/verify/delivery-verification.d.ts +3 -0
- package/dist/verify/delivery-verification.js +21 -0
- package/dist/verify/e2e-registry-rules.d.ts +21 -0
- package/dist/verify/e2e-registry-rules.js +33 -0
- package/dist/verify/e2e-registry.d.ts +2 -0
- package/dist/verify/e2e-registry.js +45 -0
- package/dist/verify/full-command.d.ts +35 -0
- package/dist/verify/full-command.js +124 -0
- package/dist/verify/impact-plan-rules.d.ts +61 -0
- package/dist/verify/impact-plan-rules.js +185 -0
- package/dist/verify/impact-plan.d.ts +10 -0
- package/dist/verify/impact-plan.js +151 -0
- package/dist/verify/index.d.ts +22 -0
- package/dist/verify/index.js +22 -0
- package/dist/verify/repository-recipe-rules.d.ts +31 -0
- package/dist/verify/repository-recipe-rules.js +60 -0
- package/dist/verify/repository-recipe.d.ts +3 -0
- package/dist/verify/repository-recipe.js +58 -0
- package/dist/verify/static-validation-rules.d.ts +7 -0
- package/dist/verify/static-validation-rules.js +36 -0
- package/dist/verify/story-selection-rules.d.ts +57 -0
- package/dist/verify/story-selection-rules.js +125 -0
- package/dist/verify/types.d.ts +63 -0
- package/dist/verify/types.js +18 -0
- package/dist/verify/verification-candidate.d.ts +1 -0
- package/dist/verify/verification-candidate.js +20 -0
- package/dist/verify/verification-identity.d.ts +6 -0
- package/dist/verify/verification-identity.js +26 -0
- package/dist/verify/verification-proof-rules.d.ts +35 -0
- package/dist/verify/verification-proof-rules.js +45 -0
- package/dist/verify/verify-full-command-rules.d.ts +18 -0
- package/dist/verify/verify-full-command-rules.js +77 -0
- package/dist/verify/verify-full-runner.d.ts +32 -0
- package/dist/verify/verify-full-runner.js +251 -0
- package/package.json +115 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# KuafuCloud Proprietary Platform License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KuafuCloud. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This package is published solely to support the KuafuCloud platform, official KuafuCloud tooling, and applications developed and operated on the KuafuCloud platform.
|
|
6
|
+
|
|
7
|
+
1. Permitted Use: You may install and execute this package only as a dependency of projects developed with or running on the KuafuCloud platform.
|
|
8
|
+
2. Restrictions: You may not redistribute, sublicense, fork and republish, reverse-engineer for competing platforms, or use this package outside the KuafuCloud platform without prior written permission from KuafuCloud.
|
|
9
|
+
3. No Warranty: This software is provided "as is", without warranty of any kind.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kuafucloud/repo-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Kuafu 仓库守卫、Git hooks 与验证任务编排工具,由项目的 `agent-tool` 调用。
|
|
4
|
+
|
|
5
|
+
项目使用精确版本的 npm 依赖;同仓包可使用 `workspace:*`。正式依赖从 npmjs 安装,仓库守卫检查依赖版本与本地路径协议,不再读取本机包目录判断版本是否已发布。
|
|
6
|
+
|
|
7
|
+
常用入口:`kuafu-guard`、`kuafu-verify`。验证配置及执行环境由 Host 和业务仓共同提供,推送门禁仍由 `agent-tool task push` 执行。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { existsSync, readFileSync } = require("node:fs");
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
|
|
4
|
+
function checkPushTargets(root, updates, configuredBranch) {
|
|
5
|
+
const file = path.join(root, "kuafu.json");
|
|
6
|
+
const manifestBranch = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")).push?.branch : undefined;
|
|
7
|
+
const targetBranch = configuredBranch || manifestBranch || "main";
|
|
8
|
+
for (const line of updates.trim().split("\n").filter(Boolean)) {
|
|
9
|
+
const [, local, target, remote] = line.split(/\s+/u);
|
|
10
|
+
const creating = /^0+$/u.test(remote), deleting = /^0+$/u.test(local);
|
|
11
|
+
const taskTag = /^refs\/tags\/tasks\/T\d{3,}$/u.test(target);
|
|
12
|
+
if (!deleting && (target === `refs/heads/${targetBranch}` || (creating && taskTag))) continue;
|
|
13
|
+
throw new Error(`禁止${deleting ? "删除" : "推送"} ${target};仅允许推送主干分支 ${targetBranch}。`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { checkPushTargets };
|
|
18
|
+
if (require.main === module) {
|
|
19
|
+
const [, , root, branch] = process.argv;
|
|
20
|
+
checkPushTargets(root, readFileSync(0, "utf8"), branch || undefined);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function consumeAndRelease<T>(consume: () => Promise<T>, release: () => Promise<void>, failureMessage: string): Promise<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 锁由原adapter取得;消费与释放的首错、falsy错误和聚合顺序保持原合同。 */
|
|
2
|
+
export async function consumeAndRelease(consume, release, failureMessage) {
|
|
3
|
+
const failures = [];
|
|
4
|
+
let result;
|
|
5
|
+
try { result = await consume(); } catch (error) { failures.push(error); }
|
|
6
|
+
try { await release(); } catch (error) { failures.push(error); }
|
|
7
|
+
if (failures.length > 1) throw new AggregateError(failures, failureMessage, { cause: failures[0] });
|
|
8
|
+
if (failures.length) throw failures[0];
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type HostProcessLock = {
|
|
2
|
+
readonly owner: Readonly<{ schemaVersion: number; pid: number; token: string; createdAt: string; label: string }>;
|
|
3
|
+
close(): Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type HostProcessLockInput = {
|
|
7
|
+
lockPath: string;
|
|
8
|
+
label: string;
|
|
9
|
+
waitTimeoutMs?: number;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type HostProcessLockDependencies = {
|
|
14
|
+
pid?: number;
|
|
15
|
+
token?: string;
|
|
16
|
+
isProcessAlive?: (pid: number) => boolean | Promise<boolean>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function acquireHostProcessLock(
|
|
20
|
+
input: HostProcessLockInput,
|
|
21
|
+
dependencies?: HostProcessLockDependencies,
|
|
22
|
+
): Promise<HostProcessLock>;
|
|
23
|
+
|
|
24
|
+
export function validateHostProcessLockOwner(lockPath: string, token: string): Promise<void>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, unlink, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { performance } from "node:perf_hooks";
|
|
6
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
7
|
+
|
|
8
|
+
const PROCESS_LOCK_SCHEMA_VERSION = 1;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Host 源码构建与开发会话会修改共享 dist、端口和热更新 marker,必须在任何
|
|
12
|
+
* 写操作发生前取得进程锁。锁只保存 PID 与随机 ownership token;异常退出留下的
|
|
13
|
+
* stale lock 会在确认原进程不存在后回收,正常退出只删除自己持有的锁。
|
|
14
|
+
*/
|
|
15
|
+
export async function acquireHostProcessLock(input, dependencies = {}) {
|
|
16
|
+
const lockPath = requireAbsolutePath(input.lockPath);
|
|
17
|
+
const label = requireLabel(input.label);
|
|
18
|
+
const owner = {
|
|
19
|
+
schemaVersion: PROCESS_LOCK_SCHEMA_VERSION,
|
|
20
|
+
pid: dependencies.pid ?? process.pid,
|
|
21
|
+
token: dependencies.token ?? randomUUID(),
|
|
22
|
+
createdAt: new Date().toISOString(),
|
|
23
|
+
label,
|
|
24
|
+
};
|
|
25
|
+
const isProcessAlive = dependencies.isProcessAlive ?? isProcessAliveByPid;
|
|
26
|
+
const waitTimeoutMs = input.waitTimeoutMs ?? 0;
|
|
27
|
+
if (!Number.isFinite(waitTimeoutMs) || waitTimeoutMs < 0) throw new Error("Host process lock 等待期限无效。");
|
|
28
|
+
const deadline = performance.now() + waitTimeoutMs;
|
|
29
|
+
input.signal?.throwIfAborted();
|
|
30
|
+
await mkdir(path.dirname(lockPath), { recursive: true });
|
|
31
|
+
|
|
32
|
+
if (!/^[A-Za-z0-9-]{16,128}$/u.test(owner.token)) throw new Error("Host process lock token 无效。");
|
|
33
|
+
// 先在唯一目录中写完 owner,再原子发布非空目录。所有权从不处于空目录阶段。
|
|
34
|
+
const candidate = await mkdtemp(`${lockPath}.candidate-`);
|
|
35
|
+
try {
|
|
36
|
+
await writeFile(path.join(candidate, `${owner.token}.json`), `${JSON.stringify(owner)}\n`, { mode: 0o600, flag: "wx" });
|
|
37
|
+
for (let attempt = 0; waitTimeoutMs > 0 || attempt < 3; attempt += 1) {
|
|
38
|
+
input.signal?.throwIfAborted();
|
|
39
|
+
if (waitTimeoutMs > 0 && performance.now() >= deadline) throw processLockError("host.process-lock-timeout", `${label}等待进程锁超时。`);
|
|
40
|
+
try {
|
|
41
|
+
await rename(candidate, lockPath);
|
|
42
|
+
if (input.signal?.aborted) {
|
|
43
|
+
await removeOwnedLock(lockPath, owner);
|
|
44
|
+
input.signal.throwIfAborted();
|
|
45
|
+
}
|
|
46
|
+
return { owner: Object.freeze({ ...owner }), async close() { await removeOwnedLock(lockPath, owner); } };
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (!["EEXIST", "ENOTEMPTY", "EPERM", "ENOTDIR"].includes(error?.code)) throw error;
|
|
49
|
+
const current = await readProcessLock(lockPath);
|
|
50
|
+
if (!current) {
|
|
51
|
+
await removeEmptyLock(lockPath);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (await isProcessAlive(current.pid)) {
|
|
55
|
+
if (waitTimeoutMs > 0) {
|
|
56
|
+
await delay(Math.max(1, Math.min(100, deadline - performance.now())), undefined, { signal: input.signal });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
throw processLockError("host.process-lock-active", `${label}已有运行中的实例(PID ${current.pid}),请先关闭该实例。`);
|
|
60
|
+
}
|
|
61
|
+
await removeOwnedLock(lockPath, current);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
throw processLockError("host.process-lock-contended", `${label}进程锁竞争失败,请重试。`);
|
|
65
|
+
} finally {
|
|
66
|
+
// candidate 未发布时只属于本次尝试;已发布后此路径不存在。
|
|
67
|
+
await rm(candidate, { recursive: true, force: true });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 借用者只核对活 owner,不能回收锁或靠旧 token 重新获得权限。 */
|
|
72
|
+
export async function validateHostProcessLockOwner(lockPath, token) {
|
|
73
|
+
const owner = await readProcessLock(requireAbsolutePath(lockPath));
|
|
74
|
+
if (!owner || owner.token !== token || !await isProcessAliveByPid(owner.pid)) {
|
|
75
|
+
throw processLockError("host.process-lock-owner-invalid", "重型测试父会话占用已失效或不属于当前工作区。");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function removeEmptyLock(lockPath) {
|
|
80
|
+
try { await rmdir(lockPath); } catch (error) {
|
|
81
|
+
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error?.code)) throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function removeOwnedLock(lockPath, owner) {
|
|
86
|
+
// 删除具名 token,而不是“检查 token 后删除固定路径”。另一个回收者发布的新
|
|
87
|
+
// owner 具有不同文件名,且目录始终非空,因此旧回收者的 rmdir 不能删掉新锁。
|
|
88
|
+
try { await unlink(path.join(lockPath, `${owner.token}.json`)); } catch (error) {
|
|
89
|
+
if (error?.code !== "ENOENT") throw error;
|
|
90
|
+
}
|
|
91
|
+
await removeEmptyLock(lockPath);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function readProcessLock(lockPath) {
|
|
95
|
+
let entries;
|
|
96
|
+
try {
|
|
97
|
+
const stat = await lstat(lockPath);
|
|
98
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) throw processLockError("host.process-lock-invalid", "Host 锁必须是 owner 目录;旧文件锁需确认原进程退出后显式清理。");
|
|
99
|
+
entries = await readdir(lockPath);
|
|
100
|
+
} catch (error) { if (error?.code === "ENOENT") return null; throw error; }
|
|
101
|
+
if (!entries.length) return null;
|
|
102
|
+
if (entries.length !== 1 || !/^[A-Za-z0-9-]{16,128}\.json$/u.test(entries[0])) throw processLockError("host.process-lock-invalid", "Host process lock owner 无效。");
|
|
103
|
+
let value;
|
|
104
|
+
try { value = JSON.parse(await readFile(path.join(lockPath, entries[0]), "utf8")); }
|
|
105
|
+
catch (error) { if (error?.code === "ENOENT") return null; throw error; }
|
|
106
|
+
if (!value || typeof value !== "object" || Array.isArray(value)
|
|
107
|
+
|| value.schemaVersion !== PROCESS_LOCK_SCHEMA_VERSION
|
|
108
|
+
|| !Number.isSafeInteger(value.pid) || value.pid <= 0
|
|
109
|
+
|| entries[0] !== `${value.token}.json`) throw processLockError("host.process-lock-invalid", "Host process lock 无效。");
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function isProcessAliveByPid(pid) {
|
|
114
|
+
try {
|
|
115
|
+
process.kill(pid, 0);
|
|
116
|
+
return true;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error?.code === "ESRCH") return false;
|
|
119
|
+
if (error?.code === "EPERM") return true;
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function requireAbsolutePath(value) {
|
|
125
|
+
const normalized = typeof value === "string" ? value.trim() : "";
|
|
126
|
+
if (!normalized || !path.isAbsolute(normalized)) {
|
|
127
|
+
throw new Error("Host process lock 路径必须是绝对路径。\n");
|
|
128
|
+
}
|
|
129
|
+
return path.resolve(normalized);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function requireLabel(value) {
|
|
133
|
+
const normalized = typeof value === "string" ? value.trim() : "";
|
|
134
|
+
if (!normalized) throw new Error("Host process lock label 缺失。\n");
|
|
135
|
+
return normalized;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function processLockError(code, message) {
|
|
139
|
+
return Object.assign(new Error(`${message}\n`), { code });
|
|
140
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const HEAVY_TEST_ADMISSION_ENV: string;
|
|
2
|
+
type Input = { workspaceRoot: string; environment?: NodeJS.ProcessEnv };
|
|
3
|
+
export function withHeavyTestAdmission<T>(input: Input, consume: (environment: NodeJS.ProcessEnv) => Promise<T>): Promise<T>;
|
|
4
|
+
export function withHeavyTestConsumer<T>(input: Input, consume: (environment: NodeJS.ProcessEnv) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mkdir, realpath } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { acquireHostProcessLock, validateHostProcessLockOwner } from "./host-process-lock.mjs";
|
|
5
|
+
import { consumeAndRelease } from "./heavy-test-admission-core.mjs";
|
|
6
|
+
|
|
7
|
+
export const HEAVY_TEST_ADMISSION_ENV = "KUAFU_HEAVY_TEST_ADMISSION";
|
|
8
|
+
|
|
9
|
+
/** 整轮持有准入,子入口只借用当前活 owner;消费锁另外保证子入口串行。 */
|
|
10
|
+
export async function withHeavyTestAdmission({ workspaceRoot, environment = process.env }, consume) {
|
|
11
|
+
const root = await realpath(workspaceRoot);
|
|
12
|
+
const directory = path.join(root, ".cache/runtime/host");
|
|
13
|
+
await mkdir(directory, { recursive: true });
|
|
14
|
+
if (await realpath(directory) !== directory) throw new Error("重型测试准入目录不能经过软链。");
|
|
15
|
+
const lockPath = path.join(directory, "heavy-test-session.lock");
|
|
16
|
+
const inherited = environment[HEAVY_TEST_ADMISSION_ENV];
|
|
17
|
+
if (inherited !== undefined) {
|
|
18
|
+
if (!/^[A-Za-z0-9-]{16,128}$/u.test(inherited)) throw new Error("重型测试父会话token无效。");
|
|
19
|
+
await validateHostProcessLockOwner(lockPath, inherited);
|
|
20
|
+
return await consume(environment);
|
|
21
|
+
}
|
|
22
|
+
const lock = await acquireHostProcessLock({ lockPath, label: "重型测试整轮准入" });
|
|
23
|
+
return await consumeAndRelease(() => consume({ ...environment, [HEAVY_TEST_ADMISSION_ENV]: lock.owner.token }),
|
|
24
|
+
() => lock.close(), "重型测试执行与准入释放同时失败。");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** 先准入再取得消费锁;父会话持准入但不持消费锁,避免父子互等。 */
|
|
28
|
+
export async function withHeavyTestConsumer(input, consume) {
|
|
29
|
+
return await withHeavyTestAdmission(input, async environment => {
|
|
30
|
+
const root = await realpath(input.workspaceRoot);
|
|
31
|
+
const lock = await acquireHostProcessLock({ lockPath: path.join(root, ".cache/runtime/host/unit-artifact-producer.lock"), label: "重型测试准备与消费" });
|
|
32
|
+
return await consumeAndRelease(() => consume(environment), () => lock.close(), "重型测试执行与消费锁释放同时失败。");
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runGuardCli(argv: readonly string[], cwd?: string): Promise<void>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { resolveWorkspaceRoot } from "@kuafucloud/product-build/workspace/paths";
|
|
4
|
+
import { executeRepoGuard } from "../guard/repo.js";
|
|
5
|
+
import { installGitHooks } from "../guard/hooks/install.js";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { checkPushTargets } from "../guard/hooks/push.js";
|
|
8
|
+
import { runTaskCommitGate } from "../verify/commit-gate.js";
|
|
9
|
+
function usage() {
|
|
10
|
+
console.log(`Usage:
|
|
11
|
+
kuafu-guard repo [--profile <name>] [--config <path>] [--format text|sarif|json] [--verify-facades]
|
|
12
|
+
kuafu-guard commit [--workspace-id <uuid>]
|
|
13
|
+
kuafu-guard push
|
|
14
|
+
kuafu-guard hooks install [--system] [--prepare]`);
|
|
15
|
+
}
|
|
16
|
+
export async function runGuardCli(argv, cwd = process.cwd()) {
|
|
17
|
+
const [sub, ...rest] = argv;
|
|
18
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
19
|
+
usage();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const workspaceRoot = resolveWorkspaceRoot(cwd);
|
|
23
|
+
if (sub === "repo") {
|
|
24
|
+
const json = rest.includes("--json");
|
|
25
|
+
const args = rest.filter(a => a !== "--json");
|
|
26
|
+
const result = await executeRepoGuard({ args, cwd, workspaceRoot, json });
|
|
27
|
+
if (result.counts.error > 0)
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (sub === "commit") {
|
|
32
|
+
const wsIdx = rest.indexOf("--workspace-id");
|
|
33
|
+
const workspaceId = wsIdx >= 0 ? rest[wsIdx + 1] : process.env.KUAFU_WORKSPACE_ID;
|
|
34
|
+
const result = await runTaskCommitGate({
|
|
35
|
+
workspaceRoot,
|
|
36
|
+
...(workspaceId ? { workspaceId } : { devKey: path.basename(workspaceRoot) }),
|
|
37
|
+
});
|
|
38
|
+
if (!result.ok) {
|
|
39
|
+
for (const err of result.errors)
|
|
40
|
+
console.error(`[${err.code}] ${err.message}`);
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (sub === "push") {
|
|
46
|
+
checkPushTargets(workspaceRoot, readFileSync(0, "utf8"));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (sub === "hooks" && (rest[0] === "install" || rest[0] === "prepare")) {
|
|
50
|
+
const scope = rest.includes("--system") ? "system" : "local";
|
|
51
|
+
const prepare = rest[0] === "prepare" || rest.includes("--prepare");
|
|
52
|
+
const res = installGitHooks({ cwd, scope, prepare });
|
|
53
|
+
console.log(JSON.stringify({ ok: true, ...res }));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.error(`Unknown kuafu-guard subcommand: ${sub}`);
|
|
57
|
+
usage();
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runVerifyCli(argv: readonly string[], cwd?: string): Promise<void>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { resolveWorkspaceRoot } from "@kuafucloud/product-build/workspace/paths";
|
|
4
|
+
import { runTaskCommitGate } from "../verify/commit-gate.js";
|
|
5
|
+
import { runTaskVerification } from "../verify/verify-full-runner.js";
|
|
6
|
+
function usage() {
|
|
7
|
+
console.log(`Usage:
|
|
8
|
+
kuafu-verify check [--workspace-id <uuid>] [--json]
|
|
9
|
+
kuafu-verify plan [--scope auto|full] [--workspace-id <uuid>] [--json]
|
|
10
|
+
kuafu-verify run [--scope auto|full] [--workspace-id <uuid>] [--db do|postgres] [--json]`);
|
|
11
|
+
}
|
|
12
|
+
export async function runVerifyCli(argv, cwd = process.cwd()) {
|
|
13
|
+
const [sub, ...rest] = argv;
|
|
14
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
15
|
+
usage();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const workspaceRoot = resolveWorkspaceRoot(cwd);
|
|
19
|
+
const readOpt = (name) => {
|
|
20
|
+
const i = rest.indexOf(name);
|
|
21
|
+
return i >= 0 ? rest[i + 1] : undefined;
|
|
22
|
+
};
|
|
23
|
+
const json = rest.includes("--json");
|
|
24
|
+
const workspaceId = readOpt("--workspace-id") ?? process.env.KUAFU_WORKSPACE_ID;
|
|
25
|
+
const identity = workspaceId ? { workspaceId } : { devKey: path.basename(workspaceRoot) };
|
|
26
|
+
if (sub === "check") {
|
|
27
|
+
const result = await runTaskCommitGate({ workspaceRoot, ...identity });
|
|
28
|
+
if (json)
|
|
29
|
+
console.log(JSON.stringify(result, null, 2));
|
|
30
|
+
else if (!result.ok) {
|
|
31
|
+
for (const err of result.errors)
|
|
32
|
+
console.error(`[${err.code}] ${err.message}`);
|
|
33
|
+
}
|
|
34
|
+
if (!result.ok)
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (sub === "plan" || sub === "run") {
|
|
39
|
+
const scope = readOpt("--scope") === "full" ? "full" : "auto";
|
|
40
|
+
const result = await runTaskVerification({
|
|
41
|
+
workspaceRoot,
|
|
42
|
+
...identity,
|
|
43
|
+
requestedScope: scope,
|
|
44
|
+
planOnly: sub === "plan",
|
|
45
|
+
databaseBackend: readOpt("--db"),
|
|
46
|
+
});
|
|
47
|
+
if (json)
|
|
48
|
+
console.log(JSON.stringify(result, null, 2));
|
|
49
|
+
else if (!result.ok && result.error)
|
|
50
|
+
console.error(result.error);
|
|
51
|
+
if (!result.ok)
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
console.error(`Unknown kuafu-verify subcommand: ${sub}`);
|
|
56
|
+
usage();
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GuardConfig, ResolvedProfileConfig } from "./types.js";
|
|
2
|
+
export declare function defineGuardConfig(config: GuardConfig): GuardConfig;
|
|
3
|
+
export declare function parseGuardConfig(input: unknown): GuardConfig;
|
|
4
|
+
export declare function resolveProfileConfig(input: {
|
|
5
|
+
config: GuardConfig;
|
|
6
|
+
profileName: string;
|
|
7
|
+
}): ResolvedProfileConfig;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const severitySchema = z.enum(["error", "warning", "note"]);
|
|
3
|
+
const outputFormatSchema = z.enum(["text", "sarif"]);
|
|
4
|
+
const ruleSelectionSchema = z.union([
|
|
5
|
+
z.string().min(1),
|
|
6
|
+
z.object({
|
|
7
|
+
id: z.string().min(1),
|
|
8
|
+
enabled: z.boolean().optional(),
|
|
9
|
+
severity: severitySchema.optional(),
|
|
10
|
+
options: z.unknown().optional(),
|
|
11
|
+
}),
|
|
12
|
+
]);
|
|
13
|
+
const profileSchema = z.object({
|
|
14
|
+
extends: z.array(z.string().min(1)).optional(),
|
|
15
|
+
ruleSets: z.array(z.string().min(1)).min(1),
|
|
16
|
+
outputs: z.array(outputFormatSchema).optional(),
|
|
17
|
+
rules: z
|
|
18
|
+
.record(z.string().min(1), z.object({
|
|
19
|
+
enabled: z.boolean().optional(),
|
|
20
|
+
severity: severitySchema.optional(),
|
|
21
|
+
options: z.unknown().optional(),
|
|
22
|
+
}))
|
|
23
|
+
.optional(),
|
|
24
|
+
});
|
|
25
|
+
const configSchema = z.object({
|
|
26
|
+
profiles: z.record(z.string().min(1), profileSchema),
|
|
27
|
+
ruleSets: z.record(z.string().min(1), z.object({
|
|
28
|
+
rules: z.array(ruleSelectionSchema),
|
|
29
|
+
})),
|
|
30
|
+
whitelist: z
|
|
31
|
+
.array(z.object({
|
|
32
|
+
rule: z.string().min(1),
|
|
33
|
+
path: z.string().min(1),
|
|
34
|
+
reason: z.string().min(1),
|
|
35
|
+
lineNumber: z.number().int().positive().optional(),
|
|
36
|
+
messageIncludes: z.string().min(1).optional(),
|
|
37
|
+
}))
|
|
38
|
+
.optional(),
|
|
39
|
+
outputs: z
|
|
40
|
+
.object({
|
|
41
|
+
defaultFormat: outputFormatSchema.optional(),
|
|
42
|
+
})
|
|
43
|
+
.optional(),
|
|
44
|
+
});
|
|
45
|
+
export function defineGuardConfig(config) {
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
48
|
+
export function parseGuardConfig(input) {
|
|
49
|
+
return configSchema.parse(input);
|
|
50
|
+
}
|
|
51
|
+
export function resolveProfileConfig(input) {
|
|
52
|
+
const profile = input.config.profiles[input.profileName];
|
|
53
|
+
if (!profile) {
|
|
54
|
+
throw new Error(`Unknown guard profile "${input.profileName}".`);
|
|
55
|
+
}
|
|
56
|
+
const chain = resolveProfileChain(input.config, input.profileName);
|
|
57
|
+
const outputs = resolveOutputs(chain, input.config.outputs?.defaultFormat ?? "text");
|
|
58
|
+
const rules = resolveRules(input.config, chain);
|
|
59
|
+
return {
|
|
60
|
+
name: input.profileName,
|
|
61
|
+
outputs,
|
|
62
|
+
rules,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function resolveProfileChain(config, profileName) {
|
|
66
|
+
const visited = new Set();
|
|
67
|
+
const stack = new Set();
|
|
68
|
+
const chain = [];
|
|
69
|
+
const visit = (name) => {
|
|
70
|
+
if (stack.has(name)) {
|
|
71
|
+
throw new Error(`Circular guard profile inheritance detected: ${[...stack, name].join(" -> ")}.`);
|
|
72
|
+
}
|
|
73
|
+
if (visited.has(name)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const profile = config.profiles[name];
|
|
77
|
+
if (!profile) {
|
|
78
|
+
throw new Error(`Unknown guard profile "${name}".`);
|
|
79
|
+
}
|
|
80
|
+
stack.add(name);
|
|
81
|
+
for (const parent of profile.extends ?? []) {
|
|
82
|
+
visit(parent);
|
|
83
|
+
}
|
|
84
|
+
stack.delete(name);
|
|
85
|
+
visited.add(name);
|
|
86
|
+
chain.push({ name, profile });
|
|
87
|
+
};
|
|
88
|
+
visit(profileName);
|
|
89
|
+
return chain;
|
|
90
|
+
}
|
|
91
|
+
function resolveOutputs(chain, fallback) {
|
|
92
|
+
const dedupe = new Set();
|
|
93
|
+
for (const { profile } of chain) {
|
|
94
|
+
for (const output of profile.outputs ?? []) {
|
|
95
|
+
dedupe.add(output);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (dedupe.size === 0) {
|
|
99
|
+
dedupe.add(fallback);
|
|
100
|
+
}
|
|
101
|
+
return [...dedupe];
|
|
102
|
+
}
|
|
103
|
+
function resolveRules(config, chain) {
|
|
104
|
+
const ruleMap = new Map();
|
|
105
|
+
for (const { profile } of chain) {
|
|
106
|
+
for (const ruleSetName of profile.ruleSets) {
|
|
107
|
+
const ruleSet = config.ruleSets[ruleSetName];
|
|
108
|
+
if (!ruleSet) {
|
|
109
|
+
throw new Error(`Unknown guard ruleSet "${ruleSetName}".`);
|
|
110
|
+
}
|
|
111
|
+
for (const selection of ruleSet.rules) {
|
|
112
|
+
const normalized = normalizeRuleSelection(selection);
|
|
113
|
+
if (!normalized.enabled) {
|
|
114
|
+
ruleMap.delete(normalized.id);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
ruleMap.set(normalized.id, {
|
|
118
|
+
id: normalized.id,
|
|
119
|
+
severity: normalized.severity ?? "error",
|
|
120
|
+
options: normalized.options ?? {},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const [ruleId, override] of Object.entries(profile.rules ?? {})) {
|
|
125
|
+
const current = ruleMap.get(ruleId) ??
|
|
126
|
+
{
|
|
127
|
+
id: ruleId,
|
|
128
|
+
severity: "error",
|
|
129
|
+
options: {},
|
|
130
|
+
};
|
|
131
|
+
if (override.enabled === false) {
|
|
132
|
+
ruleMap.delete(ruleId);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
ruleMap.set(ruleId, {
|
|
136
|
+
id: ruleId,
|
|
137
|
+
severity: override.severity ?? current.severity,
|
|
138
|
+
options: override.options ?? current.options,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return [...ruleMap.values()];
|
|
143
|
+
}
|
|
144
|
+
function normalizeRuleSelection(selection) {
|
|
145
|
+
if (typeof selection === "string") {
|
|
146
|
+
return {
|
|
147
|
+
id: selection,
|
|
148
|
+
enabled: true,
|
|
149
|
+
severity: undefined,
|
|
150
|
+
options: undefined,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
id: selection.id,
|
|
155
|
+
enabled: selection.enabled ?? true,
|
|
156
|
+
severity: selection.severity,
|
|
157
|
+
options: selection.options,
|
|
158
|
+
};
|
|
159
|
+
}
|