@arcticdata/dsh-datarc-assistant 0.0.0-stage → 26.39.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.
- package/README.md +46 -2
- package/api-operations.js +404 -0
- package/client.js +475 -0
- package/cordis.patch.yml +4 -0
- package/entry/SKILL.md +34 -0
- package/icon.png +0 -0
- package/index.js +69 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/native-api.mjs +326 -0
- package/native-contracts.js +195 -0
- package/native-execution.js +184 -0
- package/native-runner.mjs +107 -0
- package/native-state.js +67 -0
- package/native-tools.js +241 -0
- package/operations.js +1260 -0
- package/package.json +65 -6
- package/runtime/datarc-access-permissions/SKILL.md +30 -0
- package/runtime/datarc-access-permissions/references/api.md +31 -0
- package/runtime/datarc-access-permissions/references/write-order.md +16 -0
- package/runtime/datarc-analysis-report/SKILL.md +125 -0
- package/runtime/datarc-analysis-report/agents/openai.yaml +6 -0
- package/runtime/datarc-analysis-report/references/analyst-frameworks.md +215 -0
- package/runtime/datarc-analysis-report/references/api-contracts.md +478 -0
- package/runtime/datarc-analysis-report/references/direct-card-fallback-design.md +66 -0
- package/runtime/datarc-analysis-report/references/human-in-the-loop.md +142 -0
- package/runtime/datarc-analysis-report/references/loop-personalization-policy.md +138 -0
- package/runtime/datarc-analysis-report/references/manifest-example.json +779 -0
- package/runtime/datarc-analysis-report/references/narrative-schema.md +160 -0
- package/runtime/datarc-analysis-report/references/question-syntax.md +151 -0
- package/runtime/datarc-analysis-report/scripts/run_analysis_report.py +2225 -0
- package/runtime/datarc-analysis-report/scripts/run_dataseek_cards.py +1914 -0
- package/runtime/datarc-analysis-report/scripts/test_run_analysis_report.py +5295 -0
- package/runtime/datarc-data-search/SKILL.md +243 -0
- package/runtime/datarc-data-search/scripts/calculate.py +116 -0
- package/runtime/datarc-data-search/scripts/data-search.mjs +628 -0
- package/runtime/datarc-data-search/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-data-search/scripts/search-result.mjs +211 -0
- package/runtime/datarc-dataseek-batch-evaluation/SKILL.md +59 -0
- package/runtime/datarc-dataseek-batch-evaluation/references/artifacts.md +36 -0
- package/runtime/datarc-dataseek-batch-evaluation/references/equivalence.md +30 -0
- package/runtime/datarc-dataseek-batch-evaluation/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-dataseek-batch-evaluation/scripts/dataseek-batch-evaluation.mjs +1020 -0
- package/runtime/datarc-dataseek-search/SKILL.md +96 -0
- package/runtime/datarc-dataseek-search/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-dataseek-search/scripts/dataseek-search.mjs +257 -0
- package/runtime/datarc-dataseek-semantic-debugging/SKILL.md +44 -0
- package/runtime/datarc-dataseek-semantic-debugging/agents/openai.yaml +4 -0
- package/runtime/datarc-dataseek-semantic-debugging/evals/evals.json +165 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/dataset.md +77 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/input-and-resolution.md +93 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/interventions.md +64 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/knowledge-and-prompts.md +47 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/rollback.md +11 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/verification-and-rollback.md +95 -0
- package/runtime/datarc-dataseek-semantic-debugging/scripts/semantic-debugging.mjs +29 -0
- package/runtime/datarc-dataseek-testset-generation/SKILL.md +47 -0
- package/runtime/datarc-dataseek-testset-generation/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-dataseek-testset-generation/scripts/dataseek-testset-generation.mjs +526 -0
- package/runtime/datarc-datasource/SKILL.md +97 -0
- package/runtime/datarc-oauth/SKILL.md +50 -0
- package/runtime/datarc-oauth/scripts/auth.mjs +192 -0
- package/runtime/datarc-oauth/scripts/credentials.mjs +237 -0
- package/runtime/datarc-report-add-card/SKILL.md +90 -0
- package/runtime/datarc-report-add-card/agents/openai.yaml +4 -0
- package/runtime/datarc-report-add-card/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-report-add-card/scripts/report-card.mjs +439 -0
- package/runtime/datarc-semantic-alias/SKILL.md +20 -0
- package/runtime/datarc-semantic-alias/scripts/alias-plan.mjs +422 -0
- package/runtime/datarc-semantic-alias/scripts/alias.mjs +11 -0
- package/runtime/datarc-semantic-calibration/SKILL.md +20 -0
- package/runtime/datarc-semantic-calibration/scripts/calibration-plan.mjs +683 -0
- package/runtime/datarc-semantic-calibration/scripts/calibration.mjs +11 -0
- package/runtime/datarc-semantic-core/SKILL.md +12 -0
- package/runtime/datarc-semantic-core/scripts/artifact-journal.mjs +853 -0
- package/runtime/datarc-semantic-core/scripts/canonical.mjs +48 -0
- package/runtime/datarc-semantic-core/scripts/case-model.mjs +608 -0
- package/runtime/datarc-semantic-core/scripts/cli.mjs +180 -0
- package/runtime/datarc-semantic-core/scripts/datarc-client.mjs +180 -0
- package/runtime/datarc-semantic-core/scripts/interpretation-pairs.mjs +57 -0
- package/runtime/datarc-semantic-core/scripts/interventions.mjs +693 -0
- package/runtime/datarc-semantic-core/scripts/live-resolution.mjs +305 -0
- package/runtime/datarc-semantic-core/scripts/model-scope.mjs +49 -0
- package/runtime/datarc-semantic-core/scripts/reproduction.mjs +330 -0
- package/runtime/datarc-semantic-core/scripts/semantic-cli.mjs +799 -0
- package/runtime/datarc-semantic-core/scripts/shared.mjs +312 -0
- package/runtime/datarc-semantic-core/scripts/verification.mjs +1111 -0
- package/runtime/datarc-semantic-dataset/SKILL.md +20 -0
- package/runtime/datarc-semantic-dataset/scripts/dataset-plan.mjs +749 -0
- package/runtime/datarc-semantic-dataset/scripts/dataset-preflight.mjs +813 -0
- package/runtime/datarc-semantic-dataset/scripts/dataset.mjs +11 -0
- package/runtime/datarc-semantic-knowledge/SKILL.md +38 -0
- package/runtime/datarc-semantic-knowledge/references/knowledge-drafts.md +61 -0
- package/runtime/datarc-semantic-knowledge/references/knowledge-generation.json +16 -0
- package/runtime/datarc-semantic-knowledge/scripts/knowledge-draft.mjs +347 -0
- package/runtime/datarc-semantic-knowledge/scripts/knowledge-plan.mjs +848 -0
- package/runtime/datarc-semantic-knowledge/scripts/knowledge.mjs +31 -0
- package/runtime/datarc-semantic-prompt/SKILL.md +20 -0
- package/runtime/datarc-semantic-prompt/scripts/prompt-plan.mjs +598 -0
- package/runtime/datarc-semantic-prompt/scripts/prompt.mjs +15 -0
- package/runtime/datarc-semantic-synonym/SKILL.md +20 -0
- package/runtime/datarc-semantic-synonym/scripts/synonym-plan.mjs +688 -0
- package/runtime/datarc-semantic-synonym/scripts/synonym.mjs +11 -0
- package/runtime/datarc-viz-analysis-report/SKILL.md +108 -0
- package/runtime/datarc-viz-analysis-report/assets/LICENSE-echarts.md +8 -0
- package/runtime/datarc-viz-analysis-report/assets/echarts.min.js +45 -0
- package/runtime/datarc-viz-analysis-report/references/api-contracts.md +163 -0
- package/runtime/datarc-viz-analysis-report/references/derivation-log.md +157 -0
- package/runtime/datarc-viz-analysis-report/references/evidence-framework.md +76 -0
- package/runtime/datarc-viz-analysis-report/references/html-template.md +92 -0
- package/runtime/datarc-viz-analysis-report/references/provenance-format.md +56 -0
- package/runtime/datarc-viz-analysis-report/references/question-syntax.md +151 -0
- package/runtime/datarc-viz-analysis-report/scripts/render_viz_report.py +1708 -0
- package/runtime/datarc-viz-analysis-report/scripts/test_render_viz_report.py +964 -0
- package/runtime/datarc-workspace-configuration/SKILL.md +59 -0
- package/runtime/datarc-workspace-configuration/references/artifacts.md +75 -0
- package/runtime/datarc-workspace-configuration/references/verification.md +20 -0
- package/runtime/datarc-workspace-configuration/scripts/configuration.mjs +722 -0
- package/runtime/datarc-workspace-context/SKILL.md +43 -0
- package/runtime/datarc-workspace-context/agents/openai.yaml +4 -0
- package/runtime/datarc-workspace-context/scripts/datarc-client.mjs +31 -0
- package/runtime/datarc-workspace-context/scripts/query-display.mjs +114 -0
- package/runtime/datarc-workspace-context/scripts/workspace-context.mjs +58 -0
- package/runtime/datarc-workspace-custom-tables/SKILL.md +89 -0
- package/runtime/datarc-workspace-custom-tables/scripts/datarc-client.mjs +165 -0
- package/runtime/datarc-workspace-custom-tables/scripts/workspace-custom-tables.mjs +601 -0
- package/runtime/datarc-workspace-keywords/SKILL.md +197 -0
- package/runtime/datarc-workspace-keywords/agents/openai.yaml +4 -0
- package/runtime/datarc-workspace-keywords/references/api-fields.md +79 -0
- package/runtime/datarc-workspace-keywords/references/derived-measures.md +177 -0
- package/runtime/datarc-workspace-keywords/scripts/datarc-client.mjs +145 -0
- package/runtime/datarc-workspace-keywords/scripts/workspace-keywords.mjs +2421 -0
- package/runtime/datarc-workspace-membership/SKILL.md +29 -0
- package/runtime/datarc-workspace-membership/references/api.md +19 -0
- package/runtime/datarc-workspace-modeling/SKILL.md +209 -0
- package/runtime/datarc-workspace-modeling/agents/openai.yaml +4 -0
- package/runtime/datarc-workspace-modeling/references/join-preview.md +38 -0
- package/runtime/datarc-workspace-modeling/references/model-plan.md +300 -0
- package/runtime/datarc-workspace-modeling/references/model-tags.md +95 -0
- package/runtime/datarc-workspace-modeling/references/modeling-contract.json +29 -0
- package/runtime/datarc-workspace-modeling/references/modeling-fixtures.json +2423 -0
- package/runtime/datarc-workspace-modeling/scripts/datarc-client.mjs +137 -0
- package/runtime/datarc-workspace-modeling/scripts/workspace-model-tags.mjs +238 -0
- package/runtime/datarc-workspace-modeling/scripts/workspace-modeling.mjs +1261 -0
- package/skills-provider.js +51 -0
- package/workflow-index.json +434 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { queryDisplay } from "../../datarc-workspace-context/scripts/query-display.mjs";
|
|
4
|
+
import {
|
|
5
|
+
assertAccess,
|
|
6
|
+
collectCards,
|
|
7
|
+
createClient,
|
|
8
|
+
exportAll,
|
|
9
|
+
parseArgs,
|
|
10
|
+
preview,
|
|
11
|
+
readJson,
|
|
12
|
+
rethrowGlobalError,
|
|
13
|
+
required,
|
|
14
|
+
runCli,
|
|
15
|
+
} from "./datarc-client.mjs";
|
|
16
|
+
|
|
17
|
+
export class DataSeekRunner {
|
|
18
|
+
constructor(client, workspaceId, options = {}) {
|
|
19
|
+
this.client = client;
|
|
20
|
+
this.workspaceId = workspaceId;
|
|
21
|
+
this.intervalMs = Number(options.intervalMs ?? 2000);
|
|
22
|
+
this.maxWaitMs = Number(options.maxWaitMs ?? 600000);
|
|
23
|
+
this.maxDepth = Number(options.maxDepth ?? 5);
|
|
24
|
+
this.maxQuestions = Number(options.maxQuestions ?? 20);
|
|
25
|
+
this.questionCount = 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async ask(question, threadUid, extraData) {
|
|
29
|
+
const thread =
|
|
30
|
+
threadUid ??
|
|
31
|
+
(
|
|
32
|
+
await this.client.request(
|
|
33
|
+
"POST",
|
|
34
|
+
`/api/v3/account-projects/${this.workspaceId}/threads/`,
|
|
35
|
+
{ body: {} }
|
|
36
|
+
)
|
|
37
|
+
).uid;
|
|
38
|
+
const message = await this.createMessage(thread, question, extraData);
|
|
39
|
+
return {
|
|
40
|
+
threadUid: thread,
|
|
41
|
+
messageId: message.id,
|
|
42
|
+
actions: await this.resolveMessage(thread, message.id, 0),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async createMessage(threadUid, message, extraData) {
|
|
47
|
+
this.questionCount += 1;
|
|
48
|
+
if (this.questionCount > this.maxQuestions)
|
|
49
|
+
throw new Error(`子问题总数超过 ${this.maxQuestions}`);
|
|
50
|
+
return this.client.request(
|
|
51
|
+
"POST",
|
|
52
|
+
`/api/v3/account-projects/${this.workspaceId}/threads/${threadUid}/messages/`,
|
|
53
|
+
{ body: { message, ...(extraData ? { extraData } : {}) } }
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async waitMessage(threadUid, messageId) {
|
|
58
|
+
const started = Date.now();
|
|
59
|
+
while (Date.now() - started <= this.maxWaitMs) {
|
|
60
|
+
const message = await this.client.request(
|
|
61
|
+
"GET",
|
|
62
|
+
`/api/v3/account-projects/${this.workspaceId}/threads/${threadUid}/messages/${messageId}/`
|
|
63
|
+
);
|
|
64
|
+
if (message.current?.error) throw new Error(message.current.error);
|
|
65
|
+
if (message.current?.result?.length) return message.current.result;
|
|
66
|
+
await this.client.sleep(this.intervalMs);
|
|
67
|
+
}
|
|
68
|
+
throw new Error("DataSeek 消息轮询超时");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async resolveMessage(threadUid, messageId, depth) {
|
|
72
|
+
if (depth > this.maxDepth) throw new Error(`嵌套深度超过 ${this.maxDepth}`);
|
|
73
|
+
const actions = await this.waitMessage(threadUid, messageId);
|
|
74
|
+
const output = [];
|
|
75
|
+
for (const action of actions)
|
|
76
|
+
output.push(await this.executeAction(threadUid, action, depth));
|
|
77
|
+
return output;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async executeAction(threadUid, action, depth) {
|
|
81
|
+
if (["answer", "search"].includes(action.type))
|
|
82
|
+
return this.executeSearch(action);
|
|
83
|
+
if (action.type === "parallel") {
|
|
84
|
+
const children = [];
|
|
85
|
+
for (const text of action.data?.texts ?? []) {
|
|
86
|
+
try {
|
|
87
|
+
const message = await this.createMessage(threadUid, text, {
|
|
88
|
+
target_step: "pre_rule",
|
|
89
|
+
});
|
|
90
|
+
children.push({
|
|
91
|
+
question: text,
|
|
92
|
+
actions: await this.resolveMessage(
|
|
93
|
+
threadUid,
|
|
94
|
+
message.id,
|
|
95
|
+
depth + 1
|
|
96
|
+
),
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
rethrowGlobalError(error);
|
|
100
|
+
children.push({ question: text, error: { message: error.message } });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { type: "parallel", children };
|
|
104
|
+
}
|
|
105
|
+
if (action.type === "chained")
|
|
106
|
+
return this.executeChain(threadUid, action.data?.chain ?? [], depth + 1);
|
|
107
|
+
if (action.type === "deepseek")
|
|
108
|
+
return {
|
|
109
|
+
type: "deepseek",
|
|
110
|
+
executable: false,
|
|
111
|
+
prompt: action.data?.prompt,
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
type: action.type,
|
|
115
|
+
executable: false,
|
|
116
|
+
message: "该动作需要网页端处理",
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async executeSearch(action) {
|
|
121
|
+
const questions =
|
|
122
|
+
action.type === "answer"
|
|
123
|
+
? action.data?.questions ?? []
|
|
124
|
+
: [action.data?.question];
|
|
125
|
+
const results = [];
|
|
126
|
+
for (const question of questions.filter(Boolean)) {
|
|
127
|
+
const body = { question };
|
|
128
|
+
if (action.data?.tuids) body.tuids = action.data.tuids;
|
|
129
|
+
const answer = assertAccess(
|
|
130
|
+
await this.client.request(
|
|
131
|
+
"POST",
|
|
132
|
+
`/api/v3/account-projects/${this.workspaceId}/ask/`,
|
|
133
|
+
{ body }
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
const cards = answer.cards ?? [];
|
|
137
|
+
results.push({
|
|
138
|
+
question,
|
|
139
|
+
answer,
|
|
140
|
+
queryDisplay: queryDisplay(cards),
|
|
141
|
+
previews: await preview(
|
|
142
|
+
this.client,
|
|
143
|
+
this.workspaceId,
|
|
144
|
+
cards,
|
|
145
|
+
this.pollOptions()
|
|
146
|
+
),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return { type: action.type, results };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async executeChain(threadUid, chain, depth) {
|
|
153
|
+
if (depth > this.maxDepth) throw new Error(`嵌套深度超过 ${this.maxDepth}`);
|
|
154
|
+
if (!chain.length) return { type: "chained", steps: [] };
|
|
155
|
+
const steps = [];
|
|
156
|
+
let prefixTokens;
|
|
157
|
+
for (let index = 0; index < chain.length; index += 1) {
|
|
158
|
+
const item = chain[index];
|
|
159
|
+
const message = await this.createMessage(threadUid, item.text, {
|
|
160
|
+
target_step: "pre_rule",
|
|
161
|
+
...(prefixTokens ? { prefix_tokens: prefixTokens } : {}),
|
|
162
|
+
});
|
|
163
|
+
const rawActions = await this.waitMessage(threadUid, message.id);
|
|
164
|
+
const actions = [];
|
|
165
|
+
for (const action of rawActions)
|
|
166
|
+
actions.push(await this.executeAction(threadUid, action, depth));
|
|
167
|
+
steps.push({ question: item.text, actions });
|
|
168
|
+
if (index === chain.length - 1) continue;
|
|
169
|
+
const tokens = rawActions.find((action) => action.type === "answer")?.data
|
|
170
|
+
?.questions?.[0];
|
|
171
|
+
if (!Array.isArray(tokens) || !tokens.length || !item.dimension?.prop)
|
|
172
|
+
throw new Error(`链式查询第 ${index + 1} 步缺少问题 Token 或维度 prop`);
|
|
173
|
+
const dataset = await this.client.request(
|
|
174
|
+
"POST",
|
|
175
|
+
`/api/v3/account-projects/${this.workspaceId}/datasets/`,
|
|
176
|
+
{
|
|
177
|
+
body: {
|
|
178
|
+
question: tokens,
|
|
179
|
+
content: tokens.map((token) => token.word).join(""),
|
|
180
|
+
columns: [item.dimension.prop],
|
|
181
|
+
},
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
prefixTokens = chainPrefixTokens(dataset.id, item.dimension);
|
|
185
|
+
steps.at(-1).dataset = {
|
|
186
|
+
id: dataset.id,
|
|
187
|
+
columnNames: dataset.columnNames,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return { type: "chained", steps };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
pollOptions() {
|
|
194
|
+
return {
|
|
195
|
+
intervalMs: this.intervalMs,
|
|
196
|
+
maxWaitMs: this.maxWaitMs,
|
|
197
|
+
offset: 0,
|
|
198
|
+
limit: 100,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function chainPrefixTokens(datasetId, dimension) {
|
|
204
|
+
const tokens = [
|
|
205
|
+
{ word: `上文的${dimension.word}`, prop: `ds${datasetId}` },
|
|
206
|
+
{ word: dimension.word, prop: dimension.prop, split: false },
|
|
207
|
+
];
|
|
208
|
+
if (dimension.split === true)
|
|
209
|
+
tokens.push({ word: "每个", prop: "keyword_every" });
|
|
210
|
+
return tokens;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export async function execute(argv, options = {}) {
|
|
214
|
+
const args = parseArgs(argv);
|
|
215
|
+
const command = args._[0];
|
|
216
|
+
const client = options.client ?? createClient(options);
|
|
217
|
+
const workspaceId = required(args, "workspace-id");
|
|
218
|
+
if (["ask", "follow-up"].includes(command)) {
|
|
219
|
+
const runner = new DataSeekRunner(client, workspaceId, {
|
|
220
|
+
intervalMs: args["poll-interval-ms"],
|
|
221
|
+
maxWaitMs: args["max-wait-ms"],
|
|
222
|
+
maxDepth: args["max-depth"],
|
|
223
|
+
maxQuestions: args["max-questions"],
|
|
224
|
+
});
|
|
225
|
+
return runner.ask(
|
|
226
|
+
required(args, "question"),
|
|
227
|
+
command === "follow-up"
|
|
228
|
+
? required(args, "thread-uid")
|
|
229
|
+
: args["thread-uid"]
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
if (["retry", "abort"].includes(command))
|
|
233
|
+
return client.request(
|
|
234
|
+
"POST",
|
|
235
|
+
`/api/v3/account-projects/${workspaceId}/threads/${required(
|
|
236
|
+
args,
|
|
237
|
+
"thread-uid"
|
|
238
|
+
)}/messages/${required(args, "message-id")}/${
|
|
239
|
+
command === "retry" ? "retry" : "abort"
|
|
240
|
+
}/`,
|
|
241
|
+
{ body: {} }
|
|
242
|
+
);
|
|
243
|
+
if (command === "page" || command === "export") {
|
|
244
|
+
const input = await readJson(required(args, "input"));
|
|
245
|
+
const cards = collectCards(input);
|
|
246
|
+
return command === "page"
|
|
247
|
+
? preview(client, workspaceId, cards, {
|
|
248
|
+
offset: args.offset,
|
|
249
|
+
limit: args.limit,
|
|
250
|
+
})
|
|
251
|
+
: exportAll(client, workspaceId, cards, { extension: args.extension });
|
|
252
|
+
}
|
|
253
|
+
throw new Error("命令应为 ask、follow-up、retry、abort、page 或 export");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
257
|
+
await runCli(() => execute(process.argv.slice(2)));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: datarc-dataseek-semantic-debugging
|
|
3
|
+
description: Use when an administrator supplies mapping lists, a current or reported DataSeek mismatch, colloquial or abbreviated field or value terms, fixed semantic bundles, reusable entity sets, or a DataSeek mismatch caused by a contextual rule that may require Knowledge and Prompt bridging.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DataSeek 语义调试
|
|
7
|
+
|
|
8
|
+
工作区尚未确定时,先按 [datarc-workspace-context](../datarc-workspace-context/SKILL.md) 读取可访问工作区名称;不明确时列出名称让用户按名称或序号选择,不要求用户提供工作区 ID。选定后实时校验并内部传入原有 ID 参数;同一服务和账号下已确认的工作区可复用,原有权限检查与写入确认不变。
|
|
9
|
+
|
|
10
|
+
为北极九章(datarc)管理员定位并最小化修正 DataSeek 语义偏差。API 只代表当前管理员权限;他人报告只是管理员重放的文本。
|
|
11
|
+
|
|
12
|
+
## 前置条件
|
|
13
|
+
|
|
14
|
+
- 用 `datarc-oauth` 设置 `DATARC_ENDPOINT`、`DATARC_TOKEN`。
|
|
15
|
+
- 当前账户是目标工作区管理员或负责人。
|
|
16
|
+
- 以 `node scripts/semantic-debugging.mjs --help` 为参数契约来源。
|
|
17
|
+
|
|
18
|
+
## 执行流程(human-in-loop)
|
|
19
|
+
|
|
20
|
+
1. **推荐方向**:用 `direction` 按意图推荐最窄干预(别名/同义词/校准/命名数据集/Knowledge/Prompt 桥接),展示 rationale 与 risk,等待用户确认。
|
|
21
|
+
2. **确认后规划**:按确认的方向调 `plan`,每个 operation 带 kind;跨 kind 输入拆成多个单 kind plan(输出 `<output>.<kind>`);Knowledge 需模板桥接时额外生成依赖它的 prompt plan。用 `--direction <directionHash>` 绑定已确认方向。
|
|
22
|
+
3. **执行**:审阅各 plan artifact 后按依赖序 `apply`(重复 `--input`/`--output`/`--confirm`);一次 apply 只改一类资源;apply 写 API 前持久化进度并重读重验证。
|
|
23
|
+
4. **验证**:每案例在当前管理员独立新线程验证;primary + paraphrase 必选,contrast 仅当该干预可能碰撞时要求(如同义词在别处已有理解、Knowledge 影响现有语料)。词典变更须证明 fresh 普通词典;仅 Dataset 要求全模型 coverage。失败不自动回滚;需要时用 plan/receipt 精确 hash 回滚。见 [verification-and-rollback.md](references/verification-and-rollback.md) 与 [rollback.md](references/rollback.md)。
|
|
24
|
+
|
|
25
|
+
干预与输入细节见 [interventions.md](references/interventions.md)、[dataset.md](references/dataset.md)、[knowledge-and-prompts.md](references/knowledge-and-prompts.md)、[input-and-resolution.md](references/input-and-resolution.md)。
|
|
26
|
+
|
|
27
|
+
## 子 skill 路由
|
|
28
|
+
|
|
29
|
+
确定干预方向后,可直接使用对应子 skill(各自注册本 kind,只依赖 datarc-semantic-core):
|
|
30
|
+
|
|
31
|
+
- `datarc-semantic-alias` / `datarc-semantic-synonym` / `datarc-semantic-calibration` / `datarc-semantic-dataset` / `datarc-semantic-knowledge` / `datarc-semantic-prompt`
|
|
32
|
+
- 单独调整某类资源时,在对应子 skill 目录运行 `node scripts/<kind>.mjs <command> ...`(该 CLI 只注册本 kind;knowledge 与 prompt 相互依赖,均含 prompt_bridge)
|
|
33
|
+
- 跨类型或方向未定时,用本入口的 `direction` 与全功能 CLI
|
|
34
|
+
|
|
35
|
+
## 硬性要求
|
|
36
|
+
|
|
37
|
+
- plan/receipt 是确认与回滚凭据,不承载跨用户语义、不自动生效。
|
|
38
|
+
- 探针只用于本次验收,不得存为 Knowledge、Prompt 或本地回归配置。
|
|
39
|
+
- stdout 只输出紧凑摘要;artifact 写受限文件,不输出 payload、SQL、推理、token、密钥、Prompt/corpus 快照或原始 API 数据。
|
|
40
|
+
- 目标歧义、hash 不符、并发漂移、fresh-sync 不完整或回滚身份不确定时停止。
|
|
41
|
+
|
|
42
|
+
## 配置方案与验收报告
|
|
43
|
+
|
|
44
|
+
复杂或跨资源配置先使用 [配置方案与验收](../datarc-workspace-configuration/SKILL.md) 生成方案文档,用户确认该版本后执行;配置回读及就绪后按方案真实查询并生成验收报告。保留本技能的专门确认和验证门槛。简单明确修改无需额外长方案;缺少相关技能时说明依赖,不把未执行的验证写成通过。
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "datarc-dataseek-semantic-debugging",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "这些右侧名称都是凭记忆写的,可能不准确:市表现 -> 城市经营表现;客单 -> 平均客单价格。请帮我定位并修正当前工作区的 DataSeek 叫法。",
|
|
7
|
+
"expected_output": "先把右侧名称作为模糊候选逐项解析,只有管理员选定精确目标后,才为每项选择一个最窄且可回滚的语义干预。",
|
|
8
|
+
"expectations": [
|
|
9
|
+
"右侧记忆名称允许 exact、contains 和有限编辑距离的模糊 buffer,但只产生候选,不会仅凭近似名称授权写入",
|
|
10
|
+
"每个映射项独立解析并保留一个 authority;精确 id/prop 证据缺失时要求管理员选择后停止",
|
|
11
|
+
"候选定位只读取当前决定所需的紧凑、脱敏元数据,不默认索取 SQL、公式或样例值",
|
|
12
|
+
"不会为了兜底同时增加 Knowledge 或其他重复语义来源"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": 2,
|
|
17
|
+
"prompt": "我刚在当前工作区搜“成单趋势”,DataSeek 把“成单”解析成订单数;这里应是支付订单数。请修正。",
|
|
18
|
+
"expected_output": "先比较当前搜索的紧凑解析证据与管理员更正,确认精确 Measure 后用单字段别名修正,并给出可验证、可回滚的计划。",
|
|
19
|
+
"expectations": [
|
|
20
|
+
"首先检查当前管理员搜索的紧凑 parse/cut 证据,不先扩读公式或模型细节",
|
|
21
|
+
"仅在支付订单数的精确 Measure 身份确认后选择 alias;普通订单数只作为本次验收的 contrast 提问,不持久化为 Knowledge、Prompt、语义配置或可复用本地回归语义源,一次性输入按私有临时文件处理",
|
|
22
|
+
"完整计划包含 before 快照、全部受影响步骤和 planHash;只有精确 APPLY:<planHash> 才授权写入,apply 前回读并拒绝并发漂移",
|
|
23
|
+
"验证套件与该 case authority 一一绑定,并为 primary、paraphrase、contrast 各创建不同的当前管理员新线程",
|
|
24
|
+
"提供含完整 before 状态的 receipt,并能按 receiptHash 精确逆序回滚;真实字典回滚还要等待 fresh taskType 2"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": 3,
|
|
29
|
+
"prompt": "客服转述:小王在 DataSeek 搜“魔都销量”时把“魔都”当成门店,其实应是城市“上海市”。请帮我修好。",
|
|
30
|
+
"expected_output": "把他人报告当作管理员提供的文本,要求当前管理员在自己的会话重放后再诊断,不读取或模拟报告人的账户。",
|
|
31
|
+
"expectations": [
|
|
32
|
+
"不会声称读取小王的账户、权限、线程或历史消息,也不会模拟其角色",
|
|
33
|
+
"要求当前管理员直接在自己的新线程重放案例,并以该重放产生的紧凑结构证据作为诊断输入",
|
|
34
|
+
"只有在城市维度和值的精确身份锁定且无作用域冲突后,才选择单一的维度值同义词干预",
|
|
35
|
+
"若“魔都”也是合法门店值且资源不能安全限定作用域,则停止而不是写入"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": 4,
|
|
40
|
+
"prompt": "当前工作区的用户常说“艾克米”,它应该匹配品牌维度的规范值“ACME”;品牌维度已经确认。请修正 DataSeek 理解。",
|
|
41
|
+
"expected_output": "用 fresh 词典与切词证据锁定规范值后,为该维度值增加一个同义词,并以事务化读回和结构探针验收。",
|
|
42
|
+
"expectations": [
|
|
43
|
+
"选择 dimension-value synonym,而不是字段 alias、Knowledge 或语义校准",
|
|
44
|
+
"写入前要求当前工作区 fresh 成功词典证据,以及同一规范值带等号的精确 cut prop",
|
|
45
|
+
"发现同义词归属冲突或规范值身份不唯一时停止",
|
|
46
|
+
"计划经 planHash 确认、写前回读拒绝漂移,写后证明原同义词未丢失且新同义词存在",
|
|
47
|
+
"fresh 普通词典和一一绑定的 primary/paraphrase/contrast 结构验证均通过后才完成;contrast 不持久化为反例"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": 5,
|
|
52
|
+
"prompt": "公司内部“市表现”固定指“市 + 营业额 + 利润 + 退款额”,每次都要按这四部分理解,不是一个字段。请让 DataSeek 稳定识别。",
|
|
53
|
+
"expected_output": "将固定多 token 短语路由到一个语义校准资源,使用 fresh 解析出的四部分 token,避免伪装成单字段或成员集。",
|
|
54
|
+
"expectations": [
|
|
55
|
+
"选择 semantic calibration,明确拒绝用单字段 alias、Dataset 或 Knowledge 表达该固定 bundle",
|
|
56
|
+
"校准包含多于一个且由当前工作区 fresh 解析确认的 expected tokens,不照抄占位 prop",
|
|
57
|
+
"“市表现”只对应这一项 authority,不额外创建并行语义来源",
|
|
58
|
+
"相同 originText 的替换纳入完整 planHash、before 快照和可逆 receipt",
|
|
59
|
+
"该 case 的 suite 与 plan authority 一一绑定,三个探针各用不同的新当前管理员线程;探针不写入 Knowledge、Prompt、语义配置或本地回归文件"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": 6,
|
|
64
|
+
"prompt": "当前工作区的“有效客户”固定指执行当天向前滚动 30 天有交易、且当前状态不是注销的去重客户。需要在 DataSeek 里反复使用这批客户,请配置。",
|
|
65
|
+
"expected_output": "创建一个以已确认客户 ID 为唯一输出列、时间窗随每次执行日滚动的命名数据集,并先验证身份、时间、连接和基数安全。",
|
|
66
|
+
"expectations": [
|
|
67
|
+
"选择 named Dataset,而不是 alias、Knowledge 或静态语义校准",
|
|
68
|
+
"恰好输出一个管理员确认的客户 ID 维度列,并拒绝缺失身份列、危险连接以及不在 1..9999 范围内的结果",
|
|
69
|
+
"计划将 timePolicy 固定为 internal_fixed,使用内部相对 30 天 token,并说明每次执行时按当日重算",
|
|
70
|
+
"使用 fresh questionText/cut、模型详情以及 count-detail-recount 锁定交易条件、当前状态、身份和执行日;支持被模型证据严格证明的 fact 或 dimension_table topology",
|
|
71
|
+
"明确说明 preflight 只证明当前管理员权限,且 plan/noop 都会不可避免地留下 taskType 8 AsyncTask 记录",
|
|
72
|
+
"写后在新线程验证 ds token 与消息结构;成员数边界已由写前 count-detail-recount 门禁证明,额外边界查询只作为人工或外部对账选项",
|
|
73
|
+
"receipt 支持按精确 hash 逆序恢复全部变化"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": 7,
|
|
78
|
+
"prompt": "“财务月”定义为每月 26 日到次月 25 日,需要 DataSeek 按这个口径理解。工作区中英文 Prompt 都非空,但都还没有 Knowledge 插槽,请配置。",
|
|
79
|
+
"expected_output": "用一个 Knowledge 资源表达口径,并只因两个非空有效 Prompt 缺槽而在同一事务中各追加一次 workspace Knowledge 桥接。",
|
|
80
|
+
"expectations": [
|
|
81
|
+
"选择一个 Knowledge authority,以完整分页和 exact id/name 检查目标 scene 的 active corpus 与影响范围;同目标相同 desired 合并、冲突停止、已一致 noop",
|
|
82
|
+
"Prompt bridge 只作为该 Knowledge operation 的内部步骤,不新增 caseId 或第二个 authority;全部 Knowledge 先完成,bridge 写前再回读关联 Knowledge 的 exact target",
|
|
83
|
+
"仅当 effective override/default Prompt 缺槽时,对缺槽的非空 zh/en 模板在末尾追加一个 workspace_knowledge 槽;空模板不改、重复槽立即停止",
|
|
84
|
+
"每个实际变化的语言都先 dry-run,管理员审阅影响后才进入同一个 hash-confirmed plan",
|
|
85
|
+
"回读证明 Knowledge 一致且每个非空语言恰好一个槽;回滚按 Prompt 后 Knowledge 的逆序恢复",
|
|
86
|
+
"最后由当前管理员直接发起三个新搜索;CLI 只证明消息完成及可选结构检查,并返回待人工确认,管理员或执行 Agent 查看答案后才能判断 Knowledge 生效"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": 8,
|
|
91
|
+
"prompt": "“UV”可能是独立访客,也可能是电压,我只记得系统里有这两个候选。请直接把 UV 配好给 DataSeek 用。",
|
|
92
|
+
"expected_output": "返回紧凑候选并要求管理员明确选择精确资源;歧义未解除前不生成可执行计划或写入。",
|
|
93
|
+
"expectations": [
|
|
94
|
+
"把两个名称都保持为不可写候选,不依据相似度、常见含义或猜测自动选择",
|
|
95
|
+
"要求管理员选择精确 id/prop 与资源类型,且不会把候选名称当作身份事实",
|
|
96
|
+
"歧义未解除时不生成 apply 确认、不修改 alias、Knowledge 或其他配置",
|
|
97
|
+
"候选摘要脱敏且只包含当前选择需要的信息"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": 9,
|
|
102
|
+
"prompt": "帮我在 DataSeek 查当前工作区今年每月营业额和利润趋势,并解释异常月份;只读,不改任何配置。",
|
|
103
|
+
"expected_output": "把普通只读查询交给 datarc-dataseek-search 执行,不进入语义调试或配置变更流程。",
|
|
104
|
+
"expectations": [
|
|
105
|
+
"路由到 datarc-dataseek-search,而不是本语义调试 Skill",
|
|
106
|
+
"不会创建语义 plan、receipt、映射资源、Knowledge 或 Prompt 变更",
|
|
107
|
+
"只围绕查询范围、结果和解释开展只读 DataSeek 搜索"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": 10,
|
|
112
|
+
"prompt": "我们要新增一个销售模型,绑定订单事实表,建设营业额、利润和城市字段;目前没有发现 DataSeek 语义偏差。请给建模方案。",
|
|
113
|
+
"expected_output": "把没有既有语义偏差的模型与字段建设交给 datarc-workspace-modeling,不创建词汇或 Prompt 补丁。",
|
|
114
|
+
"expectations": [
|
|
115
|
+
"路由到 datarc-workspace-modeling,而不是本语义调试 Skill",
|
|
116
|
+
"不会把新模型建设伪装成 alias、同义词、校准、Dataset 或 Knowledge 修复",
|
|
117
|
+
"不会创建语义调试 plan、apply 确认或 rollback receipt"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": 11,
|
|
122
|
+
"prompt": "当前工作区同时有两项更正:‘成单’应是支付订单数,‘魔都’应是城市值上海市。请一起调好并验证。",
|
|
123
|
+
"expected_output": "把两项更正建成两个互不串线的 case authority,并分别验证各自的三探针套件。",
|
|
124
|
+
"expectations": [
|
|
125
|
+
"两个 caseId 各自绑定 exact target 和唯一干预,不允许交换相同 kind 的目标或共用一个泛化 authority",
|
|
126
|
+
"verification suites 与 plan authorities 按 caseId 完全一致,不得遗漏或额外添加",
|
|
127
|
+
"每个 suite 恰好包含 primary、paraphrase、contrast,六个 probe 各自创建新的当前管理员线程",
|
|
128
|
+
"同步目标从 plan/receipt 派生,拒绝调用者自报 syncTargets"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": 12,
|
|
133
|
+
"prompt": "我想把‘艾克米’设为 ACME 的同义词,但工作区里看起来可能已经正确配置并能搜到了。请先确认。",
|
|
134
|
+
"expected_output": "完整分页和 fresh 搜索证据确认 desired 已一致时返回 noop,不为制造变更而重复写入。",
|
|
135
|
+
"expectations": [
|
|
136
|
+
"读取完整分页而非只看第一页,并按 exact canonical/synonym owner 判断",
|
|
137
|
+
"现状已等于 desired 时生成 noop summary,不 POST 或 PUT 资源",
|
|
138
|
+
"若只是搜索暂时命中但资源归属冲突,停止并报告冲突,不叠加 Knowledge 兜底",
|
|
139
|
+
"noop 不伪造 dictionary mutation 或 fresh 同步完成证明"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": 13,
|
|
144
|
+
"prompt": "大家把‘下单’既用于订单数,也用于支付订单数;不同团队说法不一样。请全局配成支付订单数。",
|
|
145
|
+
"expected_output": "识别跨作用域歧义,在无法安全限定作用域时停止全局别名修改并建议工作区建模或先澄清范围。",
|
|
146
|
+
"expectations": [
|
|
147
|
+
"不会把口头频率或管理员偏好当作 exact target 和安全作用域证据",
|
|
148
|
+
"发现同一叫法存在两个合法 owner 或会破坏另一团队语义时停止",
|
|
149
|
+
"不会同时写 alias、Knowledge 和 Prompt 来掩盖冲突",
|
|
150
|
+
"将核心高频且现有资源无法忠实表达的问题交给 datarc-workspace-modeling"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"id": 14,
|
|
155
|
+
"prompt": "我重搜‘华南营业额’,cut 已经是正确的地区和营业额 prop,但最后选错了模型和卡片。请继续调语义词典。",
|
|
156
|
+
"expected_output": "确认偏差不在词语解析层后停止词典干预,把模型/卡片匹配问题交给工作区建模诊断。",
|
|
157
|
+
"expectations": [
|
|
158
|
+
"区分 cut 解析正确与下游模型/卡片选择错误,不把所有搜索失败都归因于叫法",
|
|
159
|
+
"不创建 alias、同义词、校准、Dataset、Knowledge 或 Prompt bridge",
|
|
160
|
+
"保留紧凑结构证据并交给 datarc-workspace-modeling,而不是修改本地反例文件",
|
|
161
|
+
"不会为了验证而读取或模拟其他用户角色"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Dataset:可执行复用成员集
|
|
2
|
+
|
|
3
|
+
```json
|
|
4
|
+
{
|
|
5
|
+
"caseId": "current_search_correction:0",
|
|
6
|
+
"kind": "dataset",
|
|
7
|
+
"name": "有效客户",
|
|
8
|
+
"content": "近30天有交易且当前状态不为注销的客户",
|
|
9
|
+
"tuids": ["model-uid"],
|
|
10
|
+
"columns": ["d31"],
|
|
11
|
+
"metadata": { "timePolicy": "internal_fixed", "anchoredOn": "2026-08-25" },
|
|
12
|
+
"modelingEvidence": {
|
|
13
|
+
"executionDate": "2026-08-25",
|
|
14
|
+
"timeZone": "Asia/Shanghai",
|
|
15
|
+
"modelSnapshotHash": "fresh-admin-model-detail-sha256",
|
|
16
|
+
"semantics": {
|
|
17
|
+
"rollingWindow": {
|
|
18
|
+
"kind": "rolling_days",
|
|
19
|
+
"days": 30,
|
|
20
|
+
"tokenProp": "dateBefore_30d",
|
|
21
|
+
"anchor": "execution_date"
|
|
22
|
+
},
|
|
23
|
+
"activity": {
|
|
24
|
+
"kind": "measure_threshold",
|
|
25
|
+
"measureProp": "m8",
|
|
26
|
+
"operatorProp": "$gt",
|
|
27
|
+
"threshold": 0,
|
|
28
|
+
"valueProp": "value_zero"
|
|
29
|
+
},
|
|
30
|
+
"currentStatus": {
|
|
31
|
+
"kind": "dimension_exclusion",
|
|
32
|
+
"sourceKind": "dimension_table",
|
|
33
|
+
"dimensionTableUid": "customer-table-uid",
|
|
34
|
+
"dimensionProp": "d32",
|
|
35
|
+
"operatorProp": "$ne",
|
|
36
|
+
"excludedValue": "注销",
|
|
37
|
+
"valueProp": "value_cancelled",
|
|
38
|
+
"temporalScope": "current"
|
|
39
|
+
},
|
|
40
|
+
"customerIdentity": {
|
|
41
|
+
"kind": "dimension_grouping",
|
|
42
|
+
"dimensionProp": "d31",
|
|
43
|
+
"level": 1,
|
|
44
|
+
"uniqueness": "runtime_count_detail_recount"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"topology": {
|
|
48
|
+
"modelUids": ["model-uid"],
|
|
49
|
+
"joins": [
|
|
50
|
+
{
|
|
51
|
+
"dimensionTableUid": "customer-table-uid",
|
|
52
|
+
"relationship": "many_to_one",
|
|
53
|
+
"dimensionKeyConstraint": "unique",
|
|
54
|
+
"fanout": "forbidden"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"identity": {
|
|
58
|
+
"sourceKind": "dimension_table",
|
|
59
|
+
"dimensionProp": "d31",
|
|
60
|
+
"dimensionId": 31,
|
|
61
|
+
"dimensionTableUid": "customer-table-uid",
|
|
62
|
+
"grouping": "single_identity"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
可选 `id` 只更新指定对象。输入不再接受 `question`、`identityEvidence` 或 `timeEvidence`;这些 caller-provided token、prop 或布尔值不能证明运行时语义,出现即在任何 API 前停止。`content` 是必填且不超过 256 个 Unicode 字符的原始 `questionText`;`tuids` 必须恰好一个模型 UID,`columns` 必须恰好一个 `dN` identity prop。`metadata.timePolicy` 只能是 `internal_fixed`,`anchoredOn` 必须等于本次按显式时区计算的执行日。默认时区为 `Asia/Shanghai`;无效时区、过期日期或结构化证据矛盾均在写入前停止。
|
|
70
|
+
|
|
71
|
+
`modelingEvidence` 必须绑定本次管理员端模型详情的完整 snapshot hash,并逐项证明:30 日滚动窗口、活动指标大于 0、当前状态不等于注销、唯一客户身份分组、单模型以及必要的 many-to-one/唯一维表键/禁止 fanout。identity 与 currentStatus 都要声明 `sourceKind=fact|dimension_table`:`fact` 必须由 fresh `model.dimensions` 直接证明,不带 `dimensionTableUid`,也不要求 identity join;`dimension_table` 必须由 fresh `model.dimensionIds`、模型中的对应维度表引用和非空 `joinFields` 共同证明,并声明对应 `dimensionTableUid`。若 model detail 不能把非事实表维度映射到单个引用,必须覆盖所有可能引用的 join;任何声明的 join 都必须确实存在于模型引用中。单个布尔确认不能替代这些字段。示例中的 prop、UID、值 prop 和 snapshot hash 都是结构说明,实际值必须来自当前工作区,不可照抄。
|
|
72
|
+
|
|
73
|
+
plan 从 `content` 构造 hash 自洽的私有 preflight input,以 fresh `questionText` 依次执行当前管理员模型详情、`/cut/`、限定单模型的 `/card/`,再通过当前管理员的 taskType 8 AsyncTask 做 count → `limit=count+1` detail → recount。只接受 1–9999 行、唯一非空身份值且前后 count 不漂移;该权限证据只覆盖当前管理员,不能证明未来请求者的行权限。taskType 8 会留下 AsyncTask 记录,这是 plan/noop 都无法避免的 read-computation side effect;安全结果固定标识 `unavoidableReadTaskSideEffect=true`,并必须在 plan warning 中披露。
|
|
74
|
+
|
|
75
|
+
全部门禁完成后,preflight 只在内存回传 fresh ordered `{word,prop}`;Dataset `after.question` 只能取自该回传,安全结果仍不保存词、qKey、nonce、SQL、原始行或客户 ID。Dataset 后端会对 `name` 执行 Python `lower().strip()`,并把每个 `question.word` 转为小写;plan 在生成 authority、查询身份和 desired state 前应用同一规范化(包括 Python 与 JavaScript 空白字符边界差异),确保 apply 回读、重试与 rollback 均绑定服务端真实状态。step 的 hash-covered `preconditions` 同时保存 `{executionDate,timeZone}`、完整私有 preflight input、安全结果和 pairs hash;step 还必须保存 `caseIds` 且 `dictionarySyncRequired=true`。
|
|
76
|
+
|
|
77
|
+
现有 Dataset 使用完整分页和 exact name/id identity 定位;多条 exact 命中停止,完整 desired 已一致则 noop。apply 在 pending journal、Dataset 读取和任何写入之前重新运行整套 preflight;模型 snapshot、日期、语义、row/identity count、安全结果或 ordered pairs 任一变化都零 mutation。无漂移后才按 exact identity 重读,更新 PUT item 或创建 POST collection,并完整分页回读验证。完成条件:回读 name、content、fresh question、单模型、身份列和固定时间策略全部一致,再在真实目标用途验证成员集。
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# 输入规范化与目标解析
|
|
2
|
+
|
|
3
|
+
## 定义与完成条件
|
|
4
|
+
|
|
5
|
+
输入只来自当前管理员:映射清单、当前会话中看到的偏差,或他人报告后由当前管理员提供并重放的文本。CLI 不读取其他账户、线程或消息。完成条件是案例无重复/冲突,且每个拟写目标由精确标识或管理员选择唯一解析;名称证据只能产生候选。
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
node scripts/semantic-debugging.mjs diagnose --input - --output /private/tmp/semantic-cases.json
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Adapter JSON
|
|
12
|
+
|
|
13
|
+
`diagnose` 外层固定为:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{ "sourceType": "mapping_list", "input": { "mappings": [] } }
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
三种 `sourceType` 与其 `input`:
|
|
20
|
+
|
|
21
|
+
- `mapping_list`:数组,或 `{"mappings":[...]}`。每项为 `{"from":"口语词","to":"标准词","kind":"dimension","target":{"id":3,"prop":"d3","name":"名称","kind":"dimension"}}`。`lhs/rhs` 可分别替代 `from/to`;外层 `kind` 在 `target.kind` 缺失时使用;`target.name` 缺失时使用 `to`。
|
|
22
|
+
- `current_search_correction`:`{"question":"...","actual":"...","correction":"...","target":{"id":3,"prop":"d3","name":"名称","kind":"dimension"}}`。`observed` 可替代 `actual`,`expected` 可替代 `correction`。
|
|
23
|
+
- `reported_search_correction`:`{"reportedQuestion":"...","reportedResult":"...","correction":"...","target":{...}}`。兼容键依次为 `question`、`actual|observed`、`expected`。这些字段仍只是管理员输入的文本,不是系统回查结果。
|
|
24
|
+
|
|
25
|
+
每个 `target` 必须至少有 `id`、`prop`、`name` 之一。类型规范为 `dimension`、`measure`、`time_series`、`dataset`、`knowledge`、`model`;复数以及 `timeseries/timeSeries` 会规范化。
|
|
26
|
+
|
|
27
|
+
## 当前管理员新线程复现
|
|
28
|
+
|
|
29
|
+
`reproduce` 只接受当前管理员提供的当前更正或转述更正,并在当前工作区创建一条普通新线程和消息:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
node scripts/semantic-debugging.mjs reproduce --input /private/tmp/reproduction-input.json --output /private/tmp/reproduction.journal
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
输入严格为:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"workspaceId": 7,
|
|
40
|
+
"caseId": "current_search_correction:0",
|
|
41
|
+
"sourceType": "current_search_correction",
|
|
42
|
+
"question": "管理员要复现的问题"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`sourceType` 仅可为 `current_search_correction` 或 `reported_search_correction`;`mapping_list`、未知字段以及 `threadUid/messageId/accountId/extraData` 都会被拒绝。`workspaceId` 必须为正整数,`caseId/question` trim 后不能为空。
|
|
47
|
+
|
|
48
|
+
`--output` 必填且必须是未占用的新路径。CLI 会先以 `0600` checksum journal 持久化 `reserved`、同步父目录,再持久化 `running`,之后才校验当前 token 的工作区管理员身份、创建新线程、执行 cut、发送原问题并轮询该条消息。它不会读取或复用既有线程,但创建的是普通搜索记录,会保留在当前管理员的搜索历史中;需要无痕测试时不要使用此命令。
|
|
49
|
+
|
|
50
|
+
journal 的 request 只保存 `workspaceId/caseId/sourceType/questionHash`,`inputHash` 则绑定完整输入,不保存独立的 `question` 字段;输入文件和北极九章(datarc)新消息包含原文,必须私密处理。completed artifact 只保存安全身份、时间、cut/解释的 word-prop 对和动作计数,不保存 raw `current/history/result/error`、SQL、Prompt、reasoning、cards 或 secrets。产品消息的非空 `error` 会完成为 `state=failed` 的复现证据;网络、协议和超时失败保留可审计的 running journal,并通过 artifact 路径安全报错。
|
|
51
|
+
|
|
52
|
+
## Catalog 与 resolve
|
|
53
|
+
|
|
54
|
+
### 当前工作区 live candidates
|
|
55
|
+
|
|
56
|
+
映射清单的 RHS 只是管理员记忆中的系统名时,先用 `diagnose` 得到 cases,再对当前管理员工作区执行:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
node scripts/semantic-debugging.mjs resolve-live --input /private/tmp/live-resolution-input.json --output /private/tmp/live-resolution.journal
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
输入外层严格为 `{"workspaceId":7,"cases":[],"selections":[]}`;`workspaceId` 必须是正整数,cases 继续遵循上文案例契约,`selections[index]` 与本地 `resolve` 相同。未提供 `caseId` 时按 `sourceType:sourceIndex` 生成;若提供则 trim 后必须非空且唯一。
|
|
63
|
+
|
|
64
|
+
命令只按案例中明确的 kind 读取必要目录;kind 缺失时读取全部支持类型。dimension、measure、time series、model 使用当前管理员的 v2 列表,Dataset 与 Knowledge 使用 v3 管理员列表的 count + offset/limit 完整分页。每个 v3 page 返回后、请求下一页前就压缩,只在内存累计安全身份和名称:字段派生 `d{id}/m{id}/t{id}`,Dataset 派生 `ds{id}`,Knowledge 只保留 id/name,model 只保留 uid/name。名称按服务端字符数契约校验:字段与 model 最多 255 个 Unicode code point,Dataset 最多 120 且遵循关键词字符规则,Knowledge 最多 256。非数组、分页不完整、非法 id/name 或重复精确身份都会停止;formula、table、content、question、corpus、SQL 和其他资源 payload 不进入累计结果。
|
|
65
|
+
|
|
66
|
+
名称 exact/contains/edit fuzzy 都只返回 compact candidates,永不授权写入。管理员审阅候选后,将精确 `selectedId` 或 `selectedProp` 写入对应 selection 并重新运行;只有唯一管理员 selection 或案例原有的唯一精确 id/prop 才能得到 `mutationAllowed=true`。短流程固定为:mapping RHS → `resolve-live` 候选 → 管理员选择 exact id/prop → 再进入 plan。
|
|
67
|
+
|
|
68
|
+
`--output` 必须是新路径。CLI 在任何目录 API 前持久化并同步 `0600` reserved/running journal;request 只保存 workspace、case 数量、每个 case 的 caseId/source/kind 和 `targetHintHash`,`inputHash` 绑定完整输入但 request 不保存 observed/expected/question/name。completed artifact 只含 workspaceId 及各 case 的 sourceIndex/caseId/compact resolution;stdout 只给 artifact 和计数。
|
|
69
|
+
|
|
70
|
+
### 离线 catalog
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
node scripts/semantic-debugging.mjs resolve --input /private/tmp/resolution-input.json --output /private/tmp/resolution.json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
输入为:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"cases": [],
|
|
81
|
+
"catalog": {
|
|
82
|
+
"dimensions": [{ "id": 3, "names": ["品牌", "Brand"], "prop": "d3" }],
|
|
83
|
+
"datasets": [{ "uid": "active-customers", "name": "有效客户" }]
|
|
84
|
+
},
|
|
85
|
+
"selections": [{ "selectedId": 3, "selectedProp": "d3", "allowedKinds": ["dimension"] }]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`catalog` 可为带 `resources` 的数组、直接数组,或按类型分组的数组;资源需要 `id|uid`、`name|names`,`prop` 可选。`selections[index]` 对应 `cases[index]`。
|
|
90
|
+
|
|
91
|
+
解析优先级:管理员 `selectedId/selectedProp` → 输入中的精确 `id/prop` → NFKC、空白折叠和不区分大小写的精确名称 → 名称包含。只有前两级的唯一一致结果返回 `mutationAllowed=true`。`id` 与 `prop` 矛盾、多个候选、缺失目标、重复案例或同一 observed 指向不同 expected 时停止;不要把 RHS 名称当作身份事实。
|
|
92
|
+
|
|
93
|
+
进入 plan 时为每个规范化案例分配稳定、非空的 `caseId`,例如映射行依次使用 `mapping_list:0`、`mapping_list:1`。同一 plan 中一个 `caseId` 只能授权一个输入 operation;不同映射行必须使用不同 `caseId`。Knowledge 自动生成的 Prompt bridge 仍属于该 Knowledge operation 的同一 authority,不另建 `caseId`。
|