thumbgate 1.39.0 → 1.40.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/.agents/skills/craft-playbook-gate/SKILL.md +51 -0
- package/.agents/skills/qwenwork-policy-group-honesty-not-clone/SKILL.md +36 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/llms.txt +2 -2
- package/.well-known/mcp/server-card.json +1 -1
- package/README.md +11 -5
- package/adapters/claude/.mcp.json +6 -2
- package/adapters/codex/config.toml +5 -0
- package/adapters/forge/forge.yaml +4 -4
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/mcp/server-stdio.js +104 -7
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/strands-middleware.js +31 -4
- package/bin/cli.js +191 -54
- package/config/brand-standards.json +131 -0
- package/config/gates/default.json +18 -1
- package/config/github-about.json +1 -1
- package/config/mcp-allowlists.json +16 -3
- package/config/merge-quality-checks.json +3 -1
- package/config/post-deploy-marketing-pages.json +4 -4
- package/config/schemas/task-outcome-receipt.schema.json +9 -0
- package/hooks/hooks.json +24 -0
- package/openapi/openapi.yaml +7 -3
- package/package.json +87 -33
- package/public/about.html +2 -2
- package/public/admin.html +771 -0
- package/public/agent-manager.html +3 -3
- package/public/agents-cost-savings.html +1 -1
- package/public/ai-malpractice-prevention.html +12 -12
- package/public/architecture.html +0 -1
- package/public/assets/diagrams/decision.svg +3 -3
- package/public/assets/diagrams/hero-thumbs.svg +2 -4
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
- package/public/blog/git-at-agent-scale.html +2 -2
- package/public/blog/inside-your-boundary.html +1 -1
- package/public/blog/process-over-outcome-gates.html +1 -1
- package/public/case-studies.html +5 -6
- package/public/codex-enterprise.html +1 -1
- package/public/codex-plugin.html +1 -1
- package/public/dashboard.html +775 -483
- package/public/diagnostic.html +15 -10
- package/public/enterprise-governance.html +26 -174
- package/public/eval-scorecard.html +3 -4
- package/public/eval-scorecard.json +2 -2
- package/public/evaluations.html +0 -1
- package/public/founders.html +3 -3
- package/public/gaming-playbook.html +4 -4
- package/public/guide.html +3 -5
- package/public/index.html +302 -97
- package/public/install.html +16 -10
- package/public/js/buyer-intent.js +49 -8
- package/public/lessons.html +246 -83
- package/public/numbers.html +32 -33
- package/public/operator-framework.html +44 -72
- package/public/peter.html +3 -3
- package/public/platform-partners.html +1 -1
- package/public/pricing.html +163 -66
- package/public/pro.html +3 -1
- package/public/project-switcher.js +76 -0
- package/public/whitepaper.html +1 -2
- package/scripts/action-receipts.js +393 -0
- package/scripts/activation-quickstart.js +15 -3
- package/scripts/activation-tracker.js +280 -3
- package/scripts/agent-action-inventory.js +235 -143
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-readiness.js +36 -6
- package/scripts/agentic-prompt-pipelines.js +901 -0
- package/scripts/analytics-window.js +7 -1
- package/scripts/async-job-runner.js +66 -11
- package/scripts/audit-trail.js +37 -24
- package/scripts/auto-promote-gates.js +37 -27
- package/scripts/auto-wire-hooks.js +64 -25
- package/scripts/backfill-lesson-scopes.js +122 -0
- package/scripts/billing.js +889 -132
- package/scripts/bot-detection.js +112 -0
- package/scripts/brand-standards-gate.js +571 -0
- package/scripts/chatgpt-ads-readiness-pack.js +1 -1
- package/scripts/cli-demo.js +5 -27
- package/scripts/cli-schema.js +25 -1
- package/scripts/commercial-offer.js +2 -2
- package/scripts/contextfs.js +9 -3
- package/scripts/craft-playbook-gate.js +550 -0
- package/scripts/cross-encoder-reranker.js +4 -0
- package/scripts/dashboard-chat.js +11 -0
- package/scripts/dashboard.js +574 -167
- package/scripts/decision-journal.js +7 -4
- package/scripts/docker-sandbox-planner.js +3 -3
- package/scripts/export-dpo-pairs.js +12 -7
- package/scripts/failure-diagnostics.js +11 -0
- package/scripts/feedback-aggregate.js +4 -0
- package/scripts/feedback-attribution.js +6 -4
- package/scripts/feedback-history-distiller.js +18 -6
- package/scripts/feedback-loop.js +255 -89
- package/scripts/feedback-paths.js +8 -1
- package/scripts/feedback-sanitizer.js +5 -0
- package/scripts/feedback-scope.js +106 -0
- package/scripts/feedback-session.js +8 -2
- package/scripts/filesystem-search.js +13 -8
- package/scripts/financial-control-plane.js +707 -45
- package/scripts/gate-stats.js +38 -5
- package/scripts/gates-engine.js +1326 -240
- package/scripts/generate-eval-scorecard.js +0 -1
- package/scripts/gitlab-sdlc-prompts.js +397 -0
- package/scripts/harness-tool-names.js +31 -5
- package/scripts/hook-runtime.js +10 -0
- package/scripts/hybrid-feedback-context.js +7 -2
- package/scripts/intervention-policy.js +2 -1
- package/scripts/lesson-canonical.js +2 -2
- package/scripts/lesson-db.js +55 -14
- package/scripts/lesson-graph.js +2 -1
- package/scripts/lesson-retrieval.js +95 -9
- package/scripts/lesson-search.js +86 -22
- package/scripts/lesson-synthesis.js +21 -5
- package/scripts/mabl-failure-honesty.js +273 -0
- package/scripts/mailer/index.js +17 -1
- package/scripts/mailer/resend-mailer.js +213 -179
- package/scripts/migrate-project-scope.js +209 -0
- package/scripts/model-distress-detector.js +3 -3
- package/scripts/operational-integrity.js +436 -3
- package/scripts/override-audit.js +2 -0
- package/scripts/owner-admin.js +338 -0
- package/scripts/pr-manager.js +194 -1
- package/scripts/product-feedback.js +35 -0
- package/scripts/progressive-signoff.js +260 -0
- package/scripts/project-catalog.js +243 -0
- package/scripts/project-dashboard.js +61 -0
- package/scripts/project-evidence.js +172 -0
- package/scripts/project-identity.js +182 -0
- package/scripts/project-scope.js +381 -0
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prompt-guard.js +446 -52
- package/scripts/proof-report.js +232 -0
- package/scripts/provider-action-normalizer.js +14 -6
- package/scripts/qwenwork-policy-group.js +413 -0
- package/scripts/rate-limiter.js +41 -0
- package/scripts/secret-redaction.js +171 -25
- package/scripts/secret-scanner.js +101 -42
- package/scripts/self-protection.js +2 -2
- package/scripts/seo-gsd.js +14 -14
- package/scripts/session-context-dedupe.js +66 -0
- package/scripts/settings-hierarchy.js +4 -2
- package/scripts/statusline-meta.js +34 -23
- package/scripts/tailscale-october-access.js +416 -0
- package/scripts/task-outcomes.js +58 -2
- package/scripts/telemetry-analytics.js +260 -16
- package/scripts/thumbgate-search.js +23 -9
- package/scripts/tool-kpi-tracker.js +5 -2
- package/scripts/tool-registry.js +42 -1
- package/scripts/triage-savings-calculator.js +1 -1
- package/scripts/vector-store.js +4 -1
- package/scripts/verified-lessons.js +270 -0
- package/scripts/verify-marketing-pages-deployed.js +2 -2
- package/scripts/workflow-sentinel.js +29 -10
- package/server.json +2 -2
- package/src/api/server.js +2478 -470
- package/src/feedback.js +21 -0
- package/src/hermes-sync-plane.js +2 -1
- package/src/index.js +2 -0
- package/src/lesson-search.js +9 -0
- package/src/mckinsey-top-company-ai-coding.js +493 -0
- package/src/mcp/email-triage-server/index.js +973 -0
- package/src/mcp/email-triage-server/package.json +12 -0
- package/src/mcp/server.js +3 -0
- package/src/mcp-writeguard.js +772 -11
- package/src/openshell-lovable-engine.js +1475 -0
- package/src/task-outcome.js +3 -0
- package/config/evals/agent-safety-eval.json +0 -447
- package/config/evals/retrieval-ranking-golden.json +0 -522
- package/config/progressive/01-wire-only.json +0 -11
- package/config/progressive/02-dashboard-empty-ok.json +0 -10
- package/config/progressive/03-one-lesson.json +0 -10
- package/config/progressive/04-warn-fires.json +0 -11
- package/config/progressive/05-strict-optional.json +0 -11
- package/config/progressive/README.md +0 -15
- package/public/assets/diagrams/agent-integration.png +0 -0
- package/public/assets/diagrams/thumbgate-architecture.png +0 -0
|
@@ -114,6 +114,7 @@ function recordDecisionEvaluation(report, params = {}, options = {}) {
|
|
|
114
114
|
? report.blastRadius.affectedFiles.slice()
|
|
115
115
|
: [];
|
|
116
116
|
const record = {
|
|
117
|
+
...require('./project-identity').projectForRecord({ ...params, ...options }),
|
|
117
118
|
recordType: 'evaluation',
|
|
118
119
|
actionId,
|
|
119
120
|
timestamp: params.timestamp || new Date().toISOString(),
|
|
@@ -142,7 +143,7 @@ function recordDecisionOutcome(params = {}, options = {}) {
|
|
|
142
143
|
const entries = readDecisionLog(getDecisionLogPath(options.feedbackDir));
|
|
143
144
|
const evaluation = [...entries]
|
|
144
145
|
.reverse()
|
|
145
|
-
.find((entry) => entry && entry.recordType === 'evaluation' && entry.actionId === actionId) || null;
|
|
146
|
+
.find((entry) => entry && entry.recordType === 'evaluation' && entry.actionId === actionId && require('./project-identity').matchesProject(entry, options.projectKey)) || null;
|
|
146
147
|
const outcome = normalizeOutcome(params.outcome);
|
|
147
148
|
const timestamp = params.timestamp || new Date().toISOString();
|
|
148
149
|
const latencyMs = Number.isFinite(params.latencyMs)
|
|
@@ -151,6 +152,7 @@ function recordDecisionOutcome(params = {}, options = {}) {
|
|
|
151
152
|
? Math.max(0, new Date(timestamp).getTime() - new Date(evaluation.timestamp).getTime())
|
|
152
153
|
: null;
|
|
153
154
|
const record = {
|
|
155
|
+
...require('./project-identity').projectForRecord({ ...params, ...options }),
|
|
154
156
|
recordType: 'outcome',
|
|
155
157
|
actionId,
|
|
156
158
|
timestamp,
|
|
@@ -172,10 +174,11 @@ function collapseDecisionTimeline(records) {
|
|
|
172
174
|
const actions = new Map();
|
|
173
175
|
for (const record of records) {
|
|
174
176
|
if (!record || !record.actionId) continue;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
const scopedId = require('./project-identity').projectForRecord(record).projectKey + ':' + record.actionId;
|
|
178
|
+
if (!actions.has(scopedId)) {
|
|
179
|
+
actions.set(scopedId, { actionId: record.actionId, evaluation: null, outcomes: [] });
|
|
177
180
|
}
|
|
178
|
-
const bucket = actions.get(
|
|
181
|
+
const bucket = actions.get(scopedId);
|
|
179
182
|
if (record.recordType === 'evaluation') {
|
|
180
183
|
bucket.evaluation = record;
|
|
181
184
|
} else if (record.recordType === 'outcome') {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
|
|
6
|
-
const { classifyCommand } = require('./operational-integrity');
|
|
6
|
+
const { classifyCommand, isDestructiveDeleteCommand } = require('./operational-integrity');
|
|
7
7
|
const { classifyHostRole } = require('./agent-egress-policy');
|
|
8
8
|
|
|
9
9
|
const HIGH_RISK_ACTION_TYPES = new Set([
|
|
@@ -109,7 +109,7 @@ function buildWhy({
|
|
|
109
109
|
lines.push('The current action does not need a dedicated Docker sandbox boundary.');
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
if (command &&
|
|
112
|
+
if (command && isDestructiveDeleteCommand(command)) {
|
|
113
113
|
lines.push('Recursive delete commands are safer when the filesystem boundary lives inside a disposable microVM.');
|
|
114
114
|
}
|
|
115
115
|
if (command && /\bgit\s+push\b.*(?:--force|-f)\b/i.test(command)) {
|
|
@@ -143,7 +143,7 @@ function buildDockerSandboxPlan(input = {}) {
|
|
|
143
143
|
? Number(Number(input.riskScore).toFixed(4))
|
|
144
144
|
: null;
|
|
145
145
|
const commandInfo = classifyCommand(command);
|
|
146
|
-
const destructiveCommand =
|
|
146
|
+
const destructiveCommand = commandInfo.isDestructiveDelete
|
|
147
147
|
|| /\bgit\s+push\b.*(?:--force|-f)\b/i.test(command)
|
|
148
148
|
|| /\bgh\s+pr\s+merge\b.*--admin\b/i.test(command);
|
|
149
149
|
const governedCommand = Boolean(
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const fs = require('fs');
|
|
9
|
+
const { projectForRecord, matchesProject } = require('./project-identity');
|
|
9
10
|
const path = require('path');
|
|
10
11
|
const { traceForDpoPair, aggregateTraces } = require('./code-reasoning');
|
|
11
12
|
const { resolveFeedbackDir } = require('./feedback-paths');
|
|
@@ -102,7 +103,7 @@ function buildRubricDelta(error, learning) {
|
|
|
102
103
|
function findDistractors(learning, errorKeys, usedErrorId, maxDistractors) {
|
|
103
104
|
const learningKeys = extractDomainKeys(learning);
|
|
104
105
|
return errorKeys
|
|
105
|
-
.filter((err) => err.memory.id !== usedErrorId)
|
|
106
|
+
.filter((err) => err.memory.id !== usedErrorId && matchesProject(err.memory, projectForRecord(learning).projectKey))
|
|
106
107
|
.map((err) => {
|
|
107
108
|
const overlap = domainOverlap(err.keys, learningKeys);
|
|
108
109
|
return { memory: err.memory, overlap };
|
|
@@ -119,6 +120,7 @@ function findDistractors(learning, errorKeys, usedErrorId, maxDistractors) {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
function buildDpoPairs(errors, learnings, { maxDistractors = 2 } = {}) {
|
|
123
|
+
const identity = (row) => projectForRecord(row).projectKey + ':' + row.id;
|
|
122
124
|
const pairs = [];
|
|
123
125
|
const usedErrors = new Set();
|
|
124
126
|
const usedLearnings = new Set();
|
|
@@ -132,7 +134,8 @@ function buildDpoPairs(errors, learnings, { maxDistractors = 2 } = {}) {
|
|
|
132
134
|
let bestOverlap = 0;
|
|
133
135
|
|
|
134
136
|
for (const learn of learningKeys) {
|
|
135
|
-
if (
|
|
137
|
+
if (!matchesProject(learn.memory, projectForRecord(err.memory).projectKey)) continue;
|
|
138
|
+
if (usedLearnings.has(identity(learn.memory))) continue;
|
|
136
139
|
const overlap = domainOverlap(err.keys, learn.keys);
|
|
137
140
|
const rubric = buildRubricDelta(err.memory, learn.memory);
|
|
138
141
|
const rubricDelta = rubric && rubric.weightedDelta != null ? rubric.weightedDelta : 0;
|
|
@@ -147,6 +150,7 @@ function buildDpoPairs(errors, learnings, { maxDistractors = 2 } = {}) {
|
|
|
147
150
|
if (best && bestScore > 0 && bestOverlap > 0) {
|
|
148
151
|
const distractors = findDistractors(best.memory, errorKeys, err.memory.id, maxDistractors);
|
|
149
152
|
pairs.push({
|
|
153
|
+
...projectForRecord(err.memory),
|
|
150
154
|
prompt: inferPrompt(err.memory, best.memory),
|
|
151
155
|
chosen: best.memory.content,
|
|
152
156
|
rejected: err.memory.content,
|
|
@@ -163,15 +167,15 @@ function buildDpoPairs(errors, learnings, { maxDistractors = 2 } = {}) {
|
|
|
163
167
|
distractorCount: distractors.length,
|
|
164
168
|
},
|
|
165
169
|
});
|
|
166
|
-
usedErrors.add(err.memory
|
|
167
|
-
usedLearnings.add(best.memory
|
|
170
|
+
usedErrors.add(identity(err.memory));
|
|
171
|
+
usedLearnings.add(identity(best.memory));
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
return {
|
|
172
176
|
pairs,
|
|
173
|
-
unpairedErrors: errors.filter((e) => !usedErrors.has(e
|
|
174
|
-
unpairedLearnings: learnings.filter((l) => !usedLearnings.has(l
|
|
177
|
+
unpairedErrors: errors.filter((e) => !usedErrors.has(identity(e))),
|
|
178
|
+
unpairedLearnings: learnings.filter((l) => !usedLearnings.has(identity(l))),
|
|
175
179
|
};
|
|
176
180
|
}
|
|
177
181
|
|
|
@@ -179,7 +183,8 @@ function toJSONL(pairs) {
|
|
|
179
183
|
return `${pairs.map((p) => JSON.stringify(p)).join('\n')}\n`;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
function exportDpoFromMemories(memories) {
|
|
186
|
+
function exportDpoFromMemories(memories, options = {}) {
|
|
187
|
+
memories = memories.filter((row) => matchesProject(row, options.projectKey));
|
|
183
188
|
// Paid-feature gate: DPO export is a commercial (Pro+) capability. Advisory by
|
|
184
189
|
// default; enforced when THUMBGATE_ENFORCE_ENTITLEMENTS=1 (then this throws).
|
|
185
190
|
const _ent = require('./entitlement').requireEntitlement('data-export');
|
|
@@ -505,6 +505,8 @@ function diagnoseFailure(options = {}) {
|
|
|
505
505
|
function aggregateFailureDiagnostics(entries) {
|
|
506
506
|
const result = {
|
|
507
507
|
totalDiagnosed: 0,
|
|
508
|
+
diagnosticLogCount: 0,
|
|
509
|
+
feedbackDiagnosedCount: 0,
|
|
508
510
|
categories: [],
|
|
509
511
|
criticalFailureSteps: [],
|
|
510
512
|
repeatedViolations: [],
|
|
@@ -512,12 +514,21 @@ function aggregateFailureDiagnostics(entries) {
|
|
|
512
514
|
const categoryBuckets = new Map();
|
|
513
515
|
const stepBuckets = new Map();
|
|
514
516
|
const violationBuckets = new Map();
|
|
517
|
+
const seenIds = new Set();
|
|
515
518
|
|
|
516
519
|
for (const entry of entries || []) {
|
|
517
520
|
const diagnosis = entry && entry.diagnosis ? entry.diagnosis : null;
|
|
518
521
|
if (!diagnosis || !diagnosis.rootCauseCategory) continue;
|
|
522
|
+
const entryId = entry && (entry.id || entry.feedbackId) ? String(entry.id || entry.feedbackId) : null;
|
|
523
|
+
if (entryId && seenIds.has(entryId)) continue;
|
|
524
|
+
if (entryId) seenIds.add(entryId);
|
|
519
525
|
|
|
520
526
|
result.totalDiagnosed += 1;
|
|
527
|
+
if (entry && (entry.signal === 'positive' || entry.signal === 'negative' || String(entryId || '').startsWith('fb_'))) {
|
|
528
|
+
result.feedbackDiagnosedCount += 1;
|
|
529
|
+
} else {
|
|
530
|
+
result.diagnosticLogCount += 1;
|
|
531
|
+
}
|
|
521
532
|
categoryBuckets.set(
|
|
522
533
|
diagnosis.rootCauseCategory,
|
|
523
534
|
(categoryBuckets.get(diagnosis.rootCauseCategory) || 0) + 1,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
const { tenantDataScope, assertScopedDataPath } = require('./feedback-scope');
|
|
5
|
+
|
|
4
6
|
const fs = require('node:fs');
|
|
5
7
|
const os = require('node:os');
|
|
6
8
|
const path = require('node:path');
|
|
@@ -94,6 +96,8 @@ function ancestorProjectFeedbackDirs(projectDir, options = {}) {
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
function listFeedbackStoreDirs(options = {}) {
|
|
99
|
+
const scope = tenantDataScope();
|
|
100
|
+
if (scope) return [assertScopedDataPath(scope.feedbackDir)];
|
|
97
101
|
const env = options.env || process.env;
|
|
98
102
|
const projectDir = resolveProjectDir({ cwd: options.cwd, env, projectDir: options.projectDir });
|
|
99
103
|
const home = getHomeDir({ env });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
const { tenantDataScope } = require('./feedback-scope');
|
|
5
|
+
|
|
4
6
|
const fs = require('fs');
|
|
5
7
|
const path = require('path');
|
|
6
8
|
const { resolveFeedbackDir } = require('./feedback-paths');
|
|
@@ -150,7 +152,7 @@ function scoreCandidate(action, feedbackNormalized, feedbackTokens, nowMs) {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
function recordAction(toolName, toolInput, opts = {}) {
|
|
153
|
-
const actionLogPath = opts.actionLogPath || process.env.THUMBGATE_ACTION_LOG || getAttributionPaths(opts).actionLog;
|
|
155
|
+
const actionLogPath = tenantDataScope() ? getAttributionPaths().actionLog : (opts.actionLogPath || process.env.THUMBGATE_ACTION_LOG || getAttributionPaths(opts).actionLog);
|
|
154
156
|
const tool = String(toolName || 'unknown');
|
|
155
157
|
const inputSummary = summarizeToolInput(tool, toolInput);
|
|
156
158
|
const normalized = normalize(inputSummary);
|
|
@@ -171,9 +173,9 @@ function recordAction(toolName, toolInput, opts = {}) {
|
|
|
171
173
|
function attributeFeedback(signal, feedbackContext, opts = {}) {
|
|
172
174
|
const sig = String(signal || '').toLowerCase().trim();
|
|
173
175
|
const paths = getAttributionPaths(opts);
|
|
174
|
-
const actionLogPath = opts.actionLogPath || process.env.THUMBGATE_ACTION_LOG || paths.actionLog;
|
|
175
|
-
const attributionsPath = opts.attributionsPath || process.env.THUMBGATE_FEEDBACK_ATTRIBUTIONS || paths.attributions;
|
|
176
|
-
const attributedFeedbackPath = opts.attributedFeedbackPath || process.env.THUMBGATE_ATTRIBUTED_FEEDBACK || paths.attributedFeedback;
|
|
176
|
+
const actionLogPath = tenantDataScope() ? paths.actionLog : (opts.actionLogPath || process.env.THUMBGATE_ACTION_LOG || paths.actionLog);
|
|
177
|
+
const attributionsPath = tenantDataScope() ? paths.attributions : (opts.attributionsPath || process.env.THUMBGATE_FEEDBACK_ATTRIBUTIONS || paths.attributions);
|
|
178
|
+
const attributedFeedbackPath = tenantDataScope() ? paths.attributedFeedback : (opts.attributedFeedbackPath || process.env.THUMBGATE_ATTRIBUTED_FEEDBACK || paths.attributedFeedback);
|
|
177
179
|
|
|
178
180
|
if (sig !== 'negative' && sig !== 'positive') {
|
|
179
181
|
return { ok: true, skipped: true, reason: 'signal_not_supported' };
|
|
@@ -113,6 +113,7 @@ function recordConversationEntry(entry, options = {}) {
|
|
|
113
113
|
return { recorded: false, reason: 'empty_text', conversationLogPath };
|
|
114
114
|
}
|
|
115
115
|
const record = {
|
|
116
|
+
...require('./project-identity').projectForCapture(entry || {}, options),
|
|
116
117
|
...normalized,
|
|
117
118
|
timestamp: normalized.timestamp || new Date().toISOString(),
|
|
118
119
|
};
|
|
@@ -123,7 +124,7 @@ function recordConversationEntry(entry, options = {}) {
|
|
|
123
124
|
function readRecentConversationWindow(options = {}) {
|
|
124
125
|
const limit = Number(options.limit || DEFAULT_HISTORY_LIMIT);
|
|
125
126
|
const { conversationLogPath } = getConversationPaths(options.feedbackDir);
|
|
126
|
-
return readJsonlTail(conversationLogPath, limit)
|
|
127
|
+
return (options.projectKey != null ? require('./project-catalog').readProjectRows(path.dirname(conversationLogPath), 'conversation-window.jsonl', options).slice(-limit) : readJsonlTail(conversationLogPath, limit))
|
|
127
128
|
.map((entry) => normalizeChatHistory([entry])[0])
|
|
128
129
|
.filter(Boolean);
|
|
129
130
|
}
|
|
@@ -131,7 +132,7 @@ function readRecentConversationWindow(options = {}) {
|
|
|
131
132
|
function findFeedbackEventById(feedbackId, options = {}) {
|
|
132
133
|
if (!feedbackId) return null;
|
|
133
134
|
const { feedbackLogPath } = getConversationPaths(options.feedbackDir);
|
|
134
|
-
const matches = readJsonlTail(feedbackLogPath, Number(options.searchLimit || 200));
|
|
135
|
+
const matches = options.projectKey != null ? require('./project-catalog').readProjectRows(path.dirname(feedbackLogPath), 'feedback-log.jsonl', options).slice(-Number(options.searchLimit || 200)) : readJsonlTail(feedbackLogPath, Number(options.searchLimit || 200));
|
|
135
136
|
for (let index = matches.length - 1; index >= 0; index -= 1) {
|
|
136
137
|
if (matches[index] && matches[index].id === feedbackId) {
|
|
137
138
|
return matches[index];
|
|
@@ -216,16 +217,26 @@ function buildRuleSuggestion(correctionMessage, signal) {
|
|
|
216
217
|
return `Repeat the successful pattern: ${text}`;
|
|
217
218
|
}
|
|
218
219
|
|
|
220
|
+
function isCaptureFragment(text) {
|
|
221
|
+
const raw = String(text || '').trim();
|
|
222
|
+
if (!raw) return false;
|
|
223
|
+
const { isTranscriptShaped } = require('./project-scope');
|
|
224
|
+
return isTranscriptShaped(raw);
|
|
225
|
+
}
|
|
226
|
+
|
|
219
227
|
function inferNegativeDistillation(messages, params) {
|
|
220
228
|
const correctionMessage = chooseMessage(messages, (entry) => {
|
|
221
229
|
const text = normalizeText(entry.text);
|
|
222
|
-
return Boolean(text) && matchesAny(text, CORRECTION_PATTERNS);
|
|
230
|
+
return Boolean(text) && !isCaptureFragment(text) && matchesAny(text, CORRECTION_PATTERNS);
|
|
223
231
|
});
|
|
224
232
|
|
|
225
233
|
const failureMessage = chooseMessage(messages, (entry) => {
|
|
226
234
|
const text = normalizeText(entry.text);
|
|
227
|
-
return Boolean(text) && matchesAny(text, FAILURE_PATTERNS);
|
|
228
|
-
}) ||
|
|
235
|
+
return Boolean(text) && !isCaptureFragment(text) && matchesAny(text, FAILURE_PATTERNS);
|
|
236
|
+
}) || (() => {
|
|
237
|
+
const fallback = buildLastActionMessage(params.lastAction);
|
|
238
|
+
return fallback && !isCaptureFragment(fallback.text) ? fallback : null;
|
|
239
|
+
})();
|
|
229
240
|
|
|
230
241
|
if (!correctionMessage && !failureMessage) {
|
|
231
242
|
return {
|
|
@@ -305,10 +316,11 @@ function distillFeedbackHistory(params = {}) {
|
|
|
305
316
|
const historyLimit = Number(params.historyLimit || DEFAULT_HISTORY_LIMIT);
|
|
306
317
|
const explicitHistory = normalizeChatHistory(params.chatHistory || params.messages || []);
|
|
307
318
|
const fallbackHistory = params.allowLocalConversationFallback
|
|
308
|
-
? readRecentConversationWindow({ feedbackDir: params.feedbackDir, limit: historyLimit })
|
|
319
|
+
? readRecentConversationWindow({ feedbackDir: params.feedbackDir, projectKey: params.projectKey, limit: historyLimit })
|
|
309
320
|
: [];
|
|
310
321
|
const relatedEvent = findFeedbackEventById(params.relatedFeedbackId, {
|
|
311
322
|
feedbackDir: params.feedbackDir,
|
|
323
|
+
projectKey: params.projectKey,
|
|
312
324
|
searchLimit: params.searchLimit,
|
|
313
325
|
});
|
|
314
326
|
|