dsh-flakefinder 0.4.3 → 0.4.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/CHANGELOG.md +4 -0
- package/docs/USAGE.en.md +4 -0
- package/docs/USAGE.md +4 -0
- package/docs/VALIDATION.md +4 -0
- package/docs/validation-0.4.4.md +5 -0
- package/lib/approval.d.ts +13 -0
- package/lib/approval.js +18 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +9 -0
- package/lib/update-client.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/docs/USAGE.en.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# dsh-flakefinder usage guide
|
|
2
2
|
|
|
3
|
+
## Confirmation in Full Access
|
|
4
|
+
|
|
5
|
+
The plugin keeps its confirmation requirement. With approval policy `never`, it reports that confirmation is unavailable and performs no write. Switch to a mode that can ask, or explicitly set `writeApproval: false` yourself. Host denials still apply.
|
|
6
|
+
|
|
3
7
|
[Overview](../README.en.md) · [Changelog](../CHANGELOG.md) · [Validation](VALIDATION.md)
|
|
4
8
|
|
|
5
9
|
## Current improvements
|
package/docs/USAGE.md
CHANGED
package/docs/VALIDATION.md
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Read the effective Host policy without importing a second copy of its services. */
|
|
2
|
+
export type ApprovalPolicy = 'ask' | 'never' | 'unknown';
|
|
3
|
+
export interface ApprovalContext {
|
|
4
|
+
get?(name: string): unknown;
|
|
5
|
+
approval?: {
|
|
6
|
+
config?: {
|
|
7
|
+
policy?: unknown;
|
|
8
|
+
};
|
|
9
|
+
overrideOf?(session: unknown): unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function approvalPolicy(ctx: ApprovalContext, execution: unknown): ApprovalPolicy;
|
|
13
|
+
export declare function approvalProblem(policy: ApprovalPolicy, setting: string): string | undefined;
|
package/lib/approval.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function approvalPolicy(ctx, execution) {
|
|
2
|
+
try {
|
|
3
|
+
const service = (ctx.get ? ctx.get('approval') : ctx.approval);
|
|
4
|
+
const session = execution?.agent?.session;
|
|
5
|
+
const policy = (session === undefined ? undefined : service?.overrideOf?.(session)) ?? service?.config?.policy;
|
|
6
|
+
return policy === 'ask' || policy === 'never' ? policy : 'unknown';
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return 'unknown';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function approvalProblem(policy, setting) {
|
|
13
|
+
if (policy === 'ask')
|
|
14
|
+
return undefined;
|
|
15
|
+
if (policy === 'never')
|
|
16
|
+
return '插件要求确认,但当前会话审批策略 never 不允许询问,操作未执行。请切换到可询问模式,或由用户明确设置 ' + setting + '=false / Confirmation is required but this session cannot ask; no action was performed.';
|
|
17
|
+
return '无法读取宿主审批策略,操作未执行。请检查 DSH 审批服务或插件配置 / Host approval policy unavailable; no action was performed.';
|
|
18
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
import { type FlakeConfig } from './config.js';
|
|
11
11
|
import { type SubprocessSpawnLike } from './runner.js';
|
|
12
12
|
import { type FlakeToolDefinition } from './tools.js';
|
|
13
|
+
import { type ApprovalContext } from './approval.js';
|
|
13
14
|
/** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
|
|
14
15
|
export declare const name = "flakefinder";
|
|
15
16
|
export declare const inject: string[];
|
|
16
17
|
/** 插件所需的最小 ctx 面。 */
|
|
17
|
-
export interface FlakePluginContext {
|
|
18
|
+
export interface FlakePluginContext extends ApprovalContext {
|
|
18
19
|
subprocess: {
|
|
19
20
|
spawn: SubprocessSpawnLike;
|
|
20
21
|
};
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { resolveConfig } from './config.js';
|
|
|
12
12
|
import { createSubprocessRunner } from './runner.js';
|
|
13
13
|
import { createStore } from './store.js';
|
|
14
14
|
import { buildFlakeTools } from './tools.js';
|
|
15
|
+
import { approvalPolicy, approvalProblem } from './approval.js';
|
|
15
16
|
/** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
|
|
16
17
|
export const name = 'flakefinder';
|
|
17
18
|
export const inject = ['subprocess', 'tools'];
|
|
@@ -38,6 +39,14 @@ export function apply(ctx, config) {
|
|
|
38
39
|
if (typeof ctx.on === 'function') {
|
|
39
40
|
if (cfg.writeApproval) {
|
|
40
41
|
ctx.on('tools/pre-execute', async (exec, next) => {
|
|
42
|
+
if (exec.name !== 'flaky_quarantine' && exec.name !== 'flaky_clear')
|
|
43
|
+
return next();
|
|
44
|
+
const downstream = await next();
|
|
45
|
+
if (downstream?.kind === 'deny')
|
|
46
|
+
return downstream;
|
|
47
|
+
const problem = approvalProblem(approvalPolicy(ctx, exec), 'writeApproval');
|
|
48
|
+
if (problem)
|
|
49
|
+
return { kind: 'deny', reason: problem };
|
|
41
50
|
if (exec.name === 'flaky_quarantine')
|
|
42
51
|
return { kind: 'ask', reason: '把测试用例写入 .flakefinder.json 隔离清单' };
|
|
43
52
|
if (exec.name === 'flaky_clear')
|
package/lib/update-client.js
CHANGED
|
@@ -437,7 +437,7 @@ function __stardustUpdatesClient(ctx, React, require, shared) {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
/* STARDUSTLC_UPDATE_CLIENT_BODY_START */
|
|
440
|
-
window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"dsh-flakefinder",factory:require=>({apply(){}})},{"name":"dsh-flakefinder","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.4.
|
|
440
|
+
window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"dsh-flakefinder",factory:require=>({apply(){}})},{"name":"dsh-flakefinder","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.4.4","label":"不稳定测试排查","labelEn":"Flakefinder","suiteComponent":true}));
|
|
441
441
|
|
|
442
442
|
/* STARDUSTLC_UPDATE_CLIENT_BODY_END */
|
|
443
443
|
})();
|