@unson/brainbase-mcp 0.50.29 → 0.50.30

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.
Files changed (37) hide show
  1. package/contracts/brainbase-public-contract.v1.json +1 -0
  2. package/dist/antigravity-judgment-hook.d.ts +191 -0
  3. package/dist/antigravity-judgment-hook.js +2042 -0
  4. package/dist/claude-code-judgment-hook.d.ts +23 -0
  5. package/dist/claude-code-judgment-hook.js +8 -5
  6. package/dist/cli.js +273 -6
  7. package/dist/graph-retrieval.d.ts +4 -0
  8. package/dist/graph-retrieval.js +4 -0
  9. package/dist/judgment-event-adapter.d.ts +37 -2
  10. package/dist/judgment-event-adapter.js +88 -3
  11. package/dist/judgment-event-outbox.d.ts +9 -1
  12. package/dist/judgment-event-outbox.js +45 -8
  13. package/dist/judgment-execution-outcome.d.ts +2 -1
  14. package/dist/judgment-execution-outcome.js +2 -1
  15. package/dist/judgment-frame.d.ts +26 -4
  16. package/dist/judgment-frame.js +190 -15
  17. package/dist/judgment-host.d.ts +30 -0
  18. package/dist/judgment-host.js +170 -22
  19. package/dist/judgment-model-outcome.d.ts +29 -1
  20. package/dist/judgment-model-outcome.js +69 -1
  21. package/dist/judgment-offline-binary-audit.d.ts +360 -0
  22. package/dist/judgment-offline-binary-audit.js +555 -0
  23. package/dist/judgment-project-binding.d.ts +1 -1
  24. package/dist/judgment-project-binding.js +2 -1
  25. package/dist/judgment-reasoning-audit.d.ts +115 -0
  26. package/dist/judgment-reasoning-audit.js +623 -0
  27. package/dist/judgment-reasoning-gate-prompt.d.ts +42 -0
  28. package/dist/judgment-reasoning-gate-prompt.js +83 -0
  29. package/dist/judgment-runtime-resolution.d.ts +2 -2
  30. package/dist/judgment-runtime-resolution.js +2 -2
  31. package/dist/judgment-runtime-resolution.public.d.ts +2 -2
  32. package/dist/judgment-session-world-model.d.ts +163 -0
  33. package/dist/judgment-session-world-model.js +408 -0
  34. package/dist/organization-graph.js +9 -1
  35. package/dist/remote-judgment-hook-http.d.ts +36 -3
  36. package/dist/remote-judgment-hook-http.js +94 -15
  37. package/package.json +10 -2
@@ -0,0 +1,115 @@
1
+ import { type JudgmentFrameCatalog, type JudgmentFrameRecord } from './judgment-frame.js';
2
+ import { type JudgmentModelOutcomeStoredRecord } from './judgment-model-outcome.js';
3
+ import type { JudgmentNodeResult } from './judgment-node-evidence.js';
4
+ import type { GraphRetrievalResponse } from './graph-retrieval.js';
5
+ import type { LearningCandidate } from './company-os-learning-adoption.js';
6
+ import type { JudgmentDAGOutcomeObservation } from './judgment-dag-replay-evaluation.js';
7
+ import { type JudgmentDAGBinaryAuditObservationOptions, type OfflineBinaryAuditEvaluationResult, type PollJuryResult } from './judgment-offline-binary-audit.js';
8
+ /**
9
+ * Deterministic structural audit and shared rubric for the five canonical
10
+ * reasoning-distortion patterns.
11
+ *
12
+ * Design boundary:
13
+ * - This module evaluates ONLY structural fields (escalations, claim scopes,
14
+ * representativeness, population/support/counter balance fields, retrieval
15
+ * counts/coverage, option/catalog structure, verify node evidence IDs, and
16
+ * world-model refutation/learning-candidate links).
17
+ * - It deliberately avoids free-text regex heuristics. Semantic assessment of
18
+ * free-text reasoning belongs to offline LLM-as-a-Judge evaluation using the
19
+ * co-exported `JUDGMENT_REASONING_DISTORTION_RUBRIC_V1` vocabulary.
20
+ * - Side-effect free: never mutates inputs or performs I/O.
21
+ */
22
+ export declare const JUDGMENT_REASONING_AUDIT_SCHEMA_VERSION: "judgment-reasoning-audit.v1";
23
+ export declare const JUDGMENT_REASONING_DISTORTION_RUBRIC_VERSION: "judgment-reasoning-distortion-rubric.v1";
24
+ export declare const JUDGMENT_REASONING_DISTORTION_PATTERNS: readonly ["counterexample_scope_mismatch", "base_rate_neglect", "layer_conflation", "conclusion_lock_cherry_picking", "local_patch_without_model_update"];
25
+ export type JudgmentReasoningDistortionPattern = typeof JUDGMENT_REASONING_DISTORTION_PATTERNS[number];
26
+ export type JudgmentReasoningPatternStatus = 'pass' | 'warn' | 'fail' | 'not_applicable';
27
+ export type JudgmentReasoningOverallStatus = 'pass' | 'warn' | 'fail';
28
+ export type JudgmentReasoningPatternScore = 0 | 0.5 | 1;
29
+ export type JudgmentReasoningLearningCandidate = LearningCandidate & {
30
+ readonly addressedRefutationIds?: readonly string[];
31
+ };
32
+ export type JudgmentReasoningRetrievalSample = Pick<GraphRetrievalResponse, 'coverage' | 'returnedCount' | 'totalScopedCount'>;
33
+ export interface JudgmentReasoningAuditInput {
34
+ readonly frame: JudgmentFrameRecord;
35
+ readonly catalog: JudgmentFrameCatalog;
36
+ readonly outcomes?: readonly JudgmentModelOutcomeStoredRecord[];
37
+ readonly nodeResults?: readonly JudgmentNodeResult[];
38
+ readonly retrieval?: readonly JudgmentReasoningRetrievalSample[];
39
+ readonly learningCandidates?: readonly JudgmentReasoningLearningCandidate[];
40
+ }
41
+ export interface JudgmentReasoningPatternResult {
42
+ readonly pattern: JudgmentReasoningDistortionPattern;
43
+ readonly status: JudgmentReasoningPatternStatus;
44
+ readonly score: JudgmentReasoningPatternScore;
45
+ readonly signals: readonly string[];
46
+ readonly evidence_paths: readonly string[];
47
+ }
48
+ export interface JudgmentReasoningAuditResult {
49
+ readonly schema_version: typeof JUDGMENT_REASONING_AUDIT_SCHEMA_VERSION;
50
+ readonly overall_status: JudgmentReasoningOverallStatus;
51
+ readonly overall_score: number;
52
+ readonly patterns: Readonly<Record<JudgmentReasoningDistortionPattern, JudgmentReasoningPatternResult>>;
53
+ }
54
+ export interface JudgmentReasoningDistortionRubricEntry {
55
+ readonly pattern: JudgmentReasoningDistortionPattern;
56
+ readonly title: string;
57
+ readonly definition: string;
58
+ readonly pass_criteria: string;
59
+ readonly warn_criteria: string;
60
+ readonly fail_criteria: string;
61
+ readonly positive_anchor: string;
62
+ readonly negative_anchor: string;
63
+ }
64
+ export interface JudgmentDAGDistortionObservationOptions {
65
+ /**
66
+ * Optional node ID in the target Judgment DAG to also emit node-scoped
67
+ * observations so `evaluateJudgmentDAGVersions` can compute `node_calibration`.
68
+ */
69
+ readonly nodeId?: string;
70
+ /**
71
+ * Optional per-pattern node IDs for finer-grained `node_calibration`.
72
+ * Overrides `nodeId` for the specified patterns.
73
+ */
74
+ readonly patternNodeIds?: Readonly<Partial<Record<JudgmentReasoningDistortionPattern, string>>>;
75
+ }
76
+ export declare const JUDGMENT_REASONING_DISTORTION_RUBRIC_V1: Readonly<Record<JudgmentReasoningDistortionPattern, JudgmentReasoningDistortionRubricEntry>>;
77
+ /**
78
+ * Audit a judgment frame and its optional surrounding evidence (model outcomes,
79
+ * node results, retrieval samples, and learning candidates) against the five
80
+ * canonical reasoning-distortion patterns using purely structural checks.
81
+ */
82
+ export declare function auditJudgmentReasoning(input: JudgmentReasoningAuditInput): JudgmentReasoningAuditResult;
83
+ /**
84
+ * Convert a `JudgmentReasoningAuditResult` into `JudgmentDAGOutcomeObservation[]`
85
+ * consumable directly by `createJudgmentDAGOutcomeAttachment` and
86
+ * `evaluateJudgmentDAGVersions` in `src/judgment-dag-replay-evaluation.ts`.
87
+ *
88
+ * Emits 5 per-pattern numeric scores (`distortion.<pattern>`, range 0..1) and
89
+ * 1 overall boolean pass indicator (`distortion.overall_pass`) at run scope.
90
+ * When `options.nodeId` or `options.patternNodeIds` is provided, matching
91
+ * node-scoped observations are appended to enable `node_calibration`.
92
+ */
93
+ export declare function toJudgmentDAGDistortionObservations(audit: JudgmentReasoningAuditResult, options?: JudgmentDAGDistortionObservationOptions): readonly JudgmentDAGOutcomeObservation[];
94
+ /**
95
+ * Convenience wrapper building a graded LLM-as-a-Judge prompt using the canonical
96
+ * `JUDGMENT_REASONING_DISTORTION_RUBRIC_V1` with explicit higher-is-better score polarity
97
+ * (`1 = pass / 歪みなし, 0.5 = warn, 0 = fail / 歪みあり`).
98
+ */
99
+ export declare function buildJudgmentReasoningGradedJudgePrompt(input: {
100
+ readonly userPrompt: string;
101
+ readonly draftResponse: string;
102
+ readonly confirmedContext?: string;
103
+ }): string;
104
+ /**
105
+ * Combine deterministic structural distortion observations and offline 7-item PoLL
106
+ * binary audit observations into a single immutable observation array for Replay Eval
107
+ * (`createJudgmentDAGOutcomeAttachment` / `evaluateJudgmentDAGVersions`).
108
+ */
109
+ export declare function toCombinedJudgmentDAGAuditObservations(input: {
110
+ readonly structuralAudit: JudgmentReasoningAuditResult;
111
+ readonly binaryAudit: PollJuryResult | OfflineBinaryAuditEvaluationResult;
112
+ readonly structuralOptions?: JudgmentDAGDistortionObservationOptions;
113
+ readonly binaryOptions?: JudgmentDAGBinaryAuditObservationOptions;
114
+ }): readonly JudgmentDAGOutcomeObservation[];
115
+ export { OFFLINE_BINARY_AUDIT_DEFECT_CODES, OFFLINE_BINARY_AUDIT_EVALUATION_SCHEMA_VERSION, OFFLINE_BINARY_AUDIT_ITEMS, OFFLINE_BINARY_AUDIT_JUDGE_SCHEMA_ID, OFFLINE_BINARY_AUDIT_JUDGE_SCHEMA_V1, OFFLINE_BINARY_AUDIT_RUBRIC_V1, OFFLINE_BINARY_AUDIT_RUBRIC_VERSION, OFFLINE_BINARY_VERDICT_POLARITY_GUIDE, OFFLINE_GRADED_DISTORTION_JUDGE_SCHEMA_ID, OFFLINE_GRADED_DISTORTION_JUDGE_SCHEMA_V1, OFFLINE_GRADED_SCORE_POLARITY_GUIDE, aggregatePollJuryVerdict, buildOfflineBinaryAuditJudgePrompt, buildOfflineGradedDistortionJudgePrompt, evaluateOfflineBinaryAudit, parseBinaryAuditJudgeOutput, parseGradedDistortionJudgeOutput, toJudgmentDAGBinaryAuditObservations, type BinaryAuditVerdict, type GradedRubricPromptEntry, type JudgmentDAGBinaryAuditObservationOptions, type OfflineBinaryAuditDefectCode, type OfflineBinaryAuditEvaluationInput, type OfflineBinaryAuditEvaluationResult, type OfflineBinaryAuditItemDefinition, type OfflineBinaryAuditItemNumber, type OfflineBinaryAuditJudgeOutput, type OfflineBinaryAuditJudgePromptInput, type OfflineGradedDistortionJudgeOutput, type OfflineGradedDistortionJudgePromptInput, type OfflineGradedPatternJudgeScore, type PollJuryResult, type ProviderAuditVote, } from './judgment-offline-binary-audit.js';