0xray 2.1.3 → 2.2.0
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/.opencode/codex.codex +1 -1
- package/.opencode/commands/dependency-audit.md +3 -3
- package/.opencode/enforcer-config.json +2 -2
- package/README.md +3 -3
- package/dist/CHANGELOG.md +43 -0
- package/dist/README.md +3 -3
- package/dist/analytics/routing-refiner.js +1 -1
- package/dist/cli/commands/govern.d.ts +29 -0
- package/dist/cli/commands/govern.js +152 -0
- package/dist/cli/index.js +29 -216
- package/dist/core/boot-orchestrator.js +1 -1
- package/dist/core/features-config.js +1 -1
- package/dist/core/framework-logger.js +30 -1
- package/dist/delegation/index.d.ts +1 -2
- package/dist/delegation/index.js +1 -2
- package/dist/enforcement/enforcer-tools.js +1 -1
- package/dist/execution/proposal-applier.d.ts +1 -9
- package/dist/execution/proposal-applier.js +18 -173
- package/dist/governance/codex-policy.service.d.ts +7 -25
- package/dist/governance/codex-policy.service.js +8 -26
- package/dist/governance/governance-core.d.ts +22 -28
- package/dist/governance/governance-core.js +31 -101
- package/dist/governance/governance-service.d.ts +1 -0
- package/dist/governance/governance-service.js +67 -4
- package/dist/governance/governance-types.d.ts +5 -2
- package/dist/inference/index.d.ts +3 -4
- package/dist/inference/inference-accumulator.js +1 -1
- package/dist/inference/inference-cycle.d.ts +12 -18
- package/dist/inference/inference-cycle.js +120 -335
- package/dist/integrations/base/index.d.ts +0 -1
- package/dist/integrations/base/index.js +0 -2
- package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
- package/dist/integrations/hermes-agent/bridge.mjs +10 -1
- package/dist/mcps/config/server-config-registry.js +1 -1
- package/dist/mcps/governance.server.js +4 -5
- package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
- package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
- package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
- package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
- package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
- package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
- package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
- package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
- package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
- package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
- package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
- package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
- package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
- package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
- package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
- package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
- package/dist/mcps/knowledge-skills/tech-writer.server.js +11 -1
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
- package/dist/mcps/registry.json +1 -1
- package/dist/metrics/agent-metrics.d.ts +2 -1
- package/dist/nucleus/govern-http.d.ts +59 -0
- package/dist/nucleus/govern-http.js +172 -0
- package/dist/nucleus/index.d.ts +14 -0
- package/dist/nucleus/index.js +9 -0
- package/dist/nucleus/kernel.d.ts +51 -0
- package/dist/nucleus/kernel.js +62 -0
- package/dist/nucleus/plugin-registry.d.ts +104 -0
- package/dist/nucleus/plugin-registry.js +147 -0
- package/dist/orchestrator/orchestrator.d.ts +0 -1
- package/dist/orchestrator/orchestrator.js +0 -21
- package/dist/postprocessor/PostProcessor.d.ts +13 -1
- package/dist/postprocessor/PostProcessor.js +41 -1
- package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
- package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
- package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
- package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
- package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
- package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
- package/dist/skills/orchestrator/SKILL.md +1 -1
- package/dist/skills/registry.json +1 -1
- package/dist/state/index.d.ts +0 -2
- package/package.json +4 -3
- package/scripts/node/universal-version-manager.js +3 -3
- package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
- package/src/mcps/config/server-config-registry.ts +1 -1
- package/src/mcps/governance.server.ts +4 -6
- package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
- package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
- package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
- package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
- package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
- package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
- package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
- package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
- package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
- package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
- package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
- package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
- package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
- package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
- package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
- package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
- package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
- package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
- package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
- package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
- package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
- package/src/mcps/knowledge-skills/tech-writer.server.ts +10 -1
- package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
- package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
- package/src/mcps/registry.json +1 -1
- package/src/opencode/codex.codex +1 -1
- package/src/opencode/commands/dependency-audit.md +3 -3
- package/src/opencode/enforcer-config.json +2 -2
- package/src/skills/orchestrator/SKILL.md +1 -1
- package/src/skills/registry.json +1 -1
- package/xray/codex.json +1 -1
- package/xray/config.json +1 -1
- package/xray/features.json +1 -1
- package/xray/integrations.json +3 -3
- package/.opencode/agents/testing-best-practices.yml +0 -12
- package/dist/analytics/consent-manager.d.ts +0 -93
- package/dist/analytics/consent-manager.js +0 -258
- package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
- package/dist/analytics/simple-pattern-analyzer.js +0 -297
- package/dist/cli/commands/analytics-disable.d.ts +0 -9
- package/dist/cli/commands/analytics-disable.js +0 -72
- package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
- package/dist/cli/commands/analytics-enable-action.js +0 -82
- package/dist/cli/commands/analytics-preview.d.ts +0 -9
- package/dist/cli/commands/analytics-preview.js +0 -106
- package/dist/cli/commands/analytics-status.d.ts +0 -9
- package/dist/cli/commands/analytics-status.js +0 -68
- package/dist/cli/server.d.ts +0 -1
- package/dist/cli/server.js +0 -147
- package/dist/core/errors.d.ts +0 -3
- package/dist/core/errors.js +0 -10
- package/dist/core/logging-config.d.ts +0 -11
- package/dist/core/logging-config.js +0 -43
- package/dist/core/trace-context.d.ts +0 -12
- package/dist/core/trace-context.js +0 -33
- package/dist/delegation/voting-coordinator.d.ts +0 -49
- package/dist/delegation/voting-coordinator.js +0 -375
- package/dist/enforcement/test-auto-healing.d.ts +0 -83
- package/dist/enforcement/test-auto-healing.js +0 -325
- package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
- package/dist/integrations/base/ExampleIntegration.js +0 -181
- package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
- package/dist/mcps/orchestrator.server.d.ts +0 -10
- package/dist/mcps/orchestrator.server.js +0 -19
- package/dist/orchestrator/self-direction-activation.d.ts +0 -109
- package/dist/orchestrator/self-direction-activation.js +0 -245
- package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
- package/dist/orchestrator/universal-librarian-consultation.js +0 -216
- package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
- package/dist/orchestrator/universal-registry-bridge.js +0 -247
- package/dist/performance/performance-budget-enforcer.d.ts +0 -158
- package/dist/performance/performance-budget-enforcer.js +0 -434
- package/dist/performance/performance-regression-tester.d.ts +0 -108
- package/dist/performance/performance-regression-tester.js +0 -342
- package/dist/skills/testing-best-practices/SKILL.md +0 -37
- package/dist/state/context-providers.d.ts +0 -4
- package/dist/state/context-providers.js +0 -1
- package/dist/state/state-types.d.ts +0 -5
- package/dist/state/state-types.js +0 -1
- package/dist/utils/batch-operations.d.ts +0 -25
- package/dist/utils/batch-operations.js +0 -292
- package/dist/utils/test-template-generator.d.ts +0 -25
- package/dist/utils/test-template-generator.js +0 -178
- package/dist/utils/token-manager.d.ts +0 -48
- package/dist/utils/token-manager.js +0 -163
- package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
- package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
- package/src/mcps/orchestrator.server.ts +0 -34
- package/src/opencode/agents/testing-best-practices.yml +0 -12
- package/src/skills/testing-best-practices/SKILL.md +0 -37
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isLoggingEnabled, shouldLog, } from "./logging-config.js";
|
|
2
1
|
import { promises as fs, existsSync, mkdirSync } from "fs";
|
|
3
2
|
import { join } from "path";
|
|
4
3
|
/**
|
|
@@ -94,6 +93,36 @@ export function withJobContext(operation, jobId) {
|
|
|
94
93
|
throw error;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
96
|
+
const defaultLoggingConfig = {
|
|
97
|
+
enabled: (process.env.XRAY_LOGGING_ENABLED) !== "false",
|
|
98
|
+
level: (process.env.XRAY_LOG_LEVEL) || "info",
|
|
99
|
+
destinations: ["console", "file"],
|
|
100
|
+
performanceMode: (process.env.XRAY_PERFORMANCE_MODE) === "true",
|
|
101
|
+
};
|
|
102
|
+
const LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
103
|
+
let globalLoggingConfig = { ...defaultLoggingConfig };
|
|
104
|
+
function isLoggingEnabled() {
|
|
105
|
+
return globalLoggingConfig.enabled;
|
|
106
|
+
}
|
|
107
|
+
function shouldLog(level) {
|
|
108
|
+
if (!globalLoggingConfig.enabled)
|
|
109
|
+
return false;
|
|
110
|
+
const currentLevelIndex = LOG_LEVELS.indexOf(globalLoggingConfig.level);
|
|
111
|
+
const messageLevelIndex = LOG_LEVELS.indexOf(level);
|
|
112
|
+
if (currentLevelIndex === -1 || messageLevelIndex === -1)
|
|
113
|
+
return true;
|
|
114
|
+
return messageLevelIndex >= currentLevelIndex;
|
|
115
|
+
}
|
|
116
|
+
// Module-level side effects for env var config (previously in logging-config.ts)
|
|
117
|
+
if (process.env.XRAY_LOGGING_ENABLED === "false") {
|
|
118
|
+
globalLoggingConfig.enabled = false;
|
|
119
|
+
}
|
|
120
|
+
if (process.env.XRAY_LOG_LEVEL) {
|
|
121
|
+
globalLoggingConfig.level = process.env.XRAY_LOG_LEVEL;
|
|
122
|
+
}
|
|
123
|
+
if (process.env.XRAY_PERFORMANCE_MODE === "true") {
|
|
124
|
+
globalLoggingConfig.performanceMode = true;
|
|
125
|
+
}
|
|
97
126
|
export class JobContext {
|
|
98
127
|
jobId;
|
|
99
128
|
startTime;
|
|
@@ -13,10 +13,9 @@ export { SessionCoordinator, createSessionCoordinator, } from "./session-coordin
|
|
|
13
13
|
export { RoutingOutcomeTracker, routingOutcomeTracker, } from "./analytics/index.js";
|
|
14
14
|
export { RoutingAnalytics } from "./analytics/index.js";
|
|
15
15
|
export { LearningEngine, learningEngine } from "./analytics/index.js";
|
|
16
|
-
export { VotingCoordinator, createVotingCoordinator, } from "./voting-coordinator.js";
|
|
17
16
|
export { WeightedVotingAggregator, createWeightedVotingAggregator, createDetailedVotingResult, DEFAULT_HISTORICAL_CONFIG, DEFAULT_CONFIDENCE_CONFIG, } from "./weighted-voting-aggregator.js";
|
|
18
17
|
export { AdaptiveStrategySelector, adaptiveStrategySelector, selectVotingStrategy, } from "./strategy-selector.js";
|
|
19
|
-
export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight,
|
|
18
|
+
export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight, } from "./agent-expertise.js";
|
|
20
19
|
export type { VotingSession, VotingStrategy, VoteChoice, VotingResult, VotingResultDetail, AgentExpertise, StrategySelectionContext, VotingHistoryEntry, AdaptiveStrategyConfig, VotingMetrics, ConflictResolutionRequest, ConflictResolutionResponse, } from "./voting-types.js";
|
|
21
20
|
export type { ComplexityMetrics, ComplexityScore, ComplexityThresholds, } from "./complexity-analyzer.js";
|
|
22
21
|
export type { DelegationRequest, DelegationResult, AgentCapability, DelegationMetrics, } from "./agent-delegator.js";
|
package/dist/delegation/index.js
CHANGED
|
@@ -13,8 +13,7 @@ export { SessionCoordinator, createSessionCoordinator, } from "./session-coordin
|
|
|
13
13
|
export { RoutingOutcomeTracker, routingOutcomeTracker, } from "./analytics/index.js";
|
|
14
14
|
export { RoutingAnalytics } from "./analytics/index.js";
|
|
15
15
|
export { LearningEngine, learningEngine } from "./analytics/index.js";
|
|
16
|
-
export { VotingCoordinator, createVotingCoordinator, } from "./voting-coordinator.js";
|
|
17
16
|
export { WeightedVotingAggregator, createWeightedVotingAggregator, createDetailedVotingResult, DEFAULT_HISTORICAL_CONFIG, DEFAULT_CONFIDENCE_CONFIG, } from "./weighted-voting-aggregator.js";
|
|
18
17
|
export { AdaptiveStrategySelector, adaptiveStrategySelector, selectVotingStrategy, } from "./strategy-selector.js";
|
|
19
|
-
export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight,
|
|
18
|
+
export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight, } from "./agent-expertise.js";
|
|
20
19
|
export { AgentMetricsSystem, getAgentMetricsSystem, initializeAgentMetrics, resetAgentMetricsSystem, } from "../metrics/agent-metrics.js";
|
|
@@ -20,7 +20,7 @@ const ROUTING_MAPPINGS = [
|
|
|
20
20
|
// Core built-in skills (high confidence)
|
|
21
21
|
{ keywords: ["write", "file", "create"], skill: "code-review", agent: "code-reviewer", confidence: 0.9 },
|
|
22
22
|
{ keywords: ["review", "audit", "assess", "evaluate", "check", "inspect", "quality", "validate", "code-review"], skill: "code-review", agent: "code-reviewer", confidence: 0.9 },
|
|
23
|
-
{ keywords: ["test", "testing", "jest", "coverage", "unit", "e2e", "cypress", "spec", "verify"], skill: "testing-
|
|
23
|
+
{ keywords: ["test", "testing", "jest", "coverage", "unit", "e2e", "cypress", "spec", "verify"], skill: "testing-strategy", agent: "testing-lead", confidence: 0.95 },
|
|
24
24
|
{ keywords: ["fix", "debug", "triage", "broken", "error", "crash", "bug", "issue", "resolve"], skill: "bug-triage", agent: "bug-triage-specialist", confidence: 0.92 },
|
|
25
25
|
{ keywords: ["security", "vulnerability", "threat", "scan", "risk", "exploit", "secure", "pentest"], skill: "security-audit", agent: "security-auditor", confidence: 0.95 },
|
|
26
26
|
{ keywords: ["refactor", "cleanup", "improve", "restructure", "modernize", "debt"], skill: "refactoring-strategies", agent: "refactorer", confidence: 0.92 },
|
|
@@ -6,19 +6,11 @@ export interface ApplyResult {
|
|
|
6
6
|
details?: string[];
|
|
7
7
|
error?: string;
|
|
8
8
|
}
|
|
9
|
-
export type CodeChangeCallback = (proposal: InferenceProposal) => Promise<boolean>;
|
|
10
|
-
export type ReviewCallback = (proposal: InferenceProposal, prUrl: string) => Promise<"go" | "no-go" | "modify">;
|
|
11
9
|
export declare class ProposalApplier {
|
|
12
10
|
private projectRoot;
|
|
13
|
-
|
|
14
|
-
private reviewCallback?;
|
|
15
|
-
constructor(projectRoot?: string, codeChangeCallback?: CodeChangeCallback | undefined, reviewCallback?: ReviewCallback | undefined);
|
|
11
|
+
constructor(projectRoot?: string);
|
|
16
12
|
applyProposals(proposals: InferenceProposal[]): Promise<ApplyResult[]>;
|
|
17
|
-
private applyProposal;
|
|
18
13
|
private applyCodification;
|
|
19
|
-
private isInsideGitRepo;
|
|
20
14
|
private getAppliedMarkerPath;
|
|
21
15
|
private recordAppliedProposal;
|
|
22
|
-
private createPR;
|
|
23
16
|
}
|
|
24
|
-
export declare const proposalApplier: ProposalApplier;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { spawnSync } from "child_process";
|
|
4
3
|
import { frameworkLogger } from "../core/framework-logger.js";
|
|
5
|
-
function sanitizeGitArgument(s) {
|
|
6
|
-
if (!/^[a-zA-Z0-9 \-_.\/@]+$/.test(s)) {
|
|
7
|
-
throw new Error("Invalid git argument: contains disallowed characters");
|
|
8
|
-
}
|
|
9
|
-
return s;
|
|
10
|
-
}
|
|
11
4
|
export class ProposalApplier {
|
|
12
5
|
projectRoot;
|
|
13
|
-
|
|
14
|
-
reviewCallback;
|
|
15
|
-
constructor(projectRoot = process.cwd(), codeChangeCallback, reviewCallback) {
|
|
6
|
+
constructor(projectRoot = process.cwd()) {
|
|
16
7
|
this.projectRoot = projectRoot;
|
|
17
|
-
this.codeChangeCallback = codeChangeCallback;
|
|
18
|
-
this.reviewCallback = reviewCallback;
|
|
19
8
|
}
|
|
20
9
|
async applyProposals(proposals) {
|
|
21
10
|
frameworkLogger.log("execution", "proposal-applier-start", "info", {
|
|
@@ -23,112 +12,26 @@ export class ProposalApplier {
|
|
|
23
12
|
});
|
|
24
13
|
const results = [];
|
|
25
14
|
for (const proposal of proposals) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return results;
|
|
30
|
-
}
|
|
31
|
-
async applyProposal(p) {
|
|
32
|
-
frameworkLogger.log("execution", "apply-proposal", "info", {
|
|
33
|
-
proposalId: p.id,
|
|
34
|
-
type: p.type,
|
|
35
|
-
});
|
|
36
|
-
if (p.type === "codify") {
|
|
37
|
-
return this.applyCodification(p);
|
|
38
|
-
}
|
|
39
|
-
const branchName = `inference/${p.type}-${Date.now()}`;
|
|
40
|
-
const isGit = this.isInsideGitRepo();
|
|
41
|
-
try {
|
|
42
|
-
this.recordAppliedProposal(p);
|
|
43
|
-
const changedFiles = [
|
|
44
|
-
path.relative(this.projectRoot, this.getAppliedMarkerPath(p)),
|
|
45
|
-
];
|
|
46
|
-
if (isGit) {
|
|
47
|
-
const branchR = spawnSync('git', ['checkout', '-b', branchName], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
48
|
-
if (branchR.status !== 0) {
|
|
49
|
-
throw new Error(`git checkout -b failed: ${(branchR.stderr || '').toString().trim()}`);
|
|
50
|
-
}
|
|
15
|
+
if (proposal.type === "codify") {
|
|
16
|
+
results.push(this.applyCodification(proposal));
|
|
51
17
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
18
|
+
else {
|
|
19
|
+
this.recordAppliedProposal(proposal);
|
|
20
|
+
const changedFiles = [
|
|
21
|
+
path.relative(this.projectRoot, this.getAppliedMarkerPath(proposal)),
|
|
22
|
+
];
|
|
23
|
+
results.push({
|
|
24
|
+
proposalId: proposal.id,
|
|
25
|
+
success: true,
|
|
26
|
+
filesChanged: changedFiles,
|
|
27
|
+
details: [
|
|
28
|
+
"Proposal recorded by Autonomous Engine (ProposalApplier)",
|
|
29
|
+
`type=${proposal.type}`,
|
|
30
|
+
],
|
|
31
|
+
});
|
|
65
32
|
}
|
|
66
|
-
if (isGit) {
|
|
67
|
-
const addR = spawnSync('git', ['add', '-A'], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
68
|
-
if (addR.status !== 0) {
|
|
69
|
-
throw new Error(`git add failed: ${(addR.stderr || '').toString().trim()}`);
|
|
70
|
-
}
|
|
71
|
-
const commitR = spawnSync('git', ['commit', '-m', p.title], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
72
|
-
if (commitR.status !== 0) {
|
|
73
|
-
throw new Error(`git commit failed: ${(commitR.stderr || '').toString().trim()}`);
|
|
74
|
-
}
|
|
75
|
-
const prUrl = this.createPR(p, branchName);
|
|
76
|
-
if (prUrl) {
|
|
77
|
-
frameworkLogger.log("execution", "pr-created", "info", {
|
|
78
|
-
prUrl,
|
|
79
|
-
proposalId: p.id,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (this.reviewCallback && prUrl) {
|
|
83
|
-
const review = await this.reviewCallback(p, prUrl);
|
|
84
|
-
if (review === "no-go") {
|
|
85
|
-
frameworkLogger.log("execution", "review-no-go", "warning", {
|
|
86
|
-
proposalId: p.id,
|
|
87
|
-
prUrl,
|
|
88
|
-
});
|
|
89
|
-
spawnSync('git', ['checkout', 'master'], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
90
|
-
spawnSync('git', ['branch', '-D', branchName], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
91
|
-
return {
|
|
92
|
-
proposalId: p.id,
|
|
93
|
-
success: false,
|
|
94
|
-
error: "Researcher review rejected proposal",
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
spawnSync('git', ['checkout', 'master'], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
proposalId: p.id,
|
|
102
|
-
success: true,
|
|
103
|
-
filesChanged: changedFiles,
|
|
104
|
-
details: [
|
|
105
|
-
"Proposal applied by Autonomous Engine (ProposalApplier)",
|
|
106
|
-
isGit ? `branch=${branchName}` : "non-git (marker only)",
|
|
107
|
-
`type=${p.type}`,
|
|
108
|
-
],
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
const errorMsg = err.message;
|
|
113
|
-
frameworkLogger.log("execution", "apply-proposal-error", "error", {
|
|
114
|
-
proposalId: p.id,
|
|
115
|
-
error: errorMsg,
|
|
116
|
-
});
|
|
117
|
-
if (isGit) {
|
|
118
|
-
try {
|
|
119
|
-
spawnSync('git', ['checkout', 'master'], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
120
|
-
spawnSync('git', ['branch', '-D', branchName], { cwd: this.projectRoot, stdio: 'pipe' });
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
// ignore cleanup
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
proposalId: p.id,
|
|
128
|
-
success: false,
|
|
129
|
-
error: errorMsg,
|
|
130
|
-
};
|
|
131
33
|
}
|
|
34
|
+
return results;
|
|
132
35
|
}
|
|
133
36
|
applyCodification(p) {
|
|
134
37
|
try {
|
|
@@ -159,19 +62,6 @@ export class ProposalApplier {
|
|
|
159
62
|
return { proposalId: p.id, success: false, error: errorMsg };
|
|
160
63
|
}
|
|
161
64
|
}
|
|
162
|
-
isInsideGitRepo() {
|
|
163
|
-
try {
|
|
164
|
-
const r = spawnSync('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
165
|
-
cwd: this.projectRoot,
|
|
166
|
-
stdio: 'pipe',
|
|
167
|
-
timeout: 2000,
|
|
168
|
-
});
|
|
169
|
-
return r.status === 0;
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
65
|
getAppliedMarkerPath(p) {
|
|
176
66
|
const appliedDir = path.join(this.projectRoot, "docs", "inference", "applied");
|
|
177
67
|
if (!fs.existsSync(appliedDir)) {
|
|
@@ -206,49 +96,4 @@ export class ProposalApplier {
|
|
|
206
96
|
module: "v2-refactor",
|
|
207
97
|
});
|
|
208
98
|
}
|
|
209
|
-
createPR(p, branchName) {
|
|
210
|
-
try {
|
|
211
|
-
sanitizeGitArgument(p.title);
|
|
212
|
-
sanitizeGitArgument(branchName);
|
|
213
|
-
const pushR = spawnSync('git', ['push', '-u', 'origin', branchName], {
|
|
214
|
-
cwd: this.projectRoot,
|
|
215
|
-
stdio: 'pipe',
|
|
216
|
-
timeout: 30000,
|
|
217
|
-
});
|
|
218
|
-
if (pushR.status !== 0) {
|
|
219
|
-
throw new Error(`git push failed: ${(pushR.stderr || '').toString().trim()}`);
|
|
220
|
-
}
|
|
221
|
-
const body = [
|
|
222
|
-
"## Inference Proposal (Autonomous Engine)",
|
|
223
|
-
"",
|
|
224
|
-
p.description,
|
|
225
|
-
"",
|
|
226
|
-
`**Type:** ${p.type} **Confidence:** ${(p.confidence * 100).toFixed(0)}%`,
|
|
227
|
-
"",
|
|
228
|
-
"## Evidence",
|
|
229
|
-
p.evidence.slice(0, 5).join("\n"),
|
|
230
|
-
"",
|
|
231
|
-
"Executed by ProposalApplier (Engine-owned) — V2 Phase 1.",
|
|
232
|
-
].join("\n");
|
|
233
|
-
const ghR = spawnSync('gh', ['pr', 'create', '--head', branchName, '--title', p.title, '--body', body], {
|
|
234
|
-
cwd: this.projectRoot,
|
|
235
|
-
encoding: 'utf-8',
|
|
236
|
-
stdio: 'pipe',
|
|
237
|
-
timeout: 30000,
|
|
238
|
-
});
|
|
239
|
-
if (ghR.status !== 0) {
|
|
240
|
-
throw new Error(`gh pr create failed: ${ghR.stderr || 'unknown error'}`);
|
|
241
|
-
}
|
|
242
|
-
return (ghR.stdout || '').trim();
|
|
243
|
-
}
|
|
244
|
-
catch (err) {
|
|
245
|
-
frameworkLogger.log("execution", "pr-create-failed", "warning", {
|
|
246
|
-
error: String(err),
|
|
247
|
-
proposalId: p.id,
|
|
248
|
-
module: "v2-refactor",
|
|
249
|
-
});
|
|
250
|
-
return "";
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
99
|
}
|
|
254
|
-
export const proposalApplier = new ProposalApplier();
|
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CodexPolicyService
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* This is the V2-P1-S02-REAL first concrete migration slice.
|
|
4
|
+
* Governance-owned Single Source of Truth (SSOT) for Codex / policy loading.
|
|
6
5
|
*
|
|
7
|
-
* Role
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* will eventually ask here instead of performing direct fs reads.
|
|
6
|
+
* Role: External Governance owns "what the policy is".
|
|
7
|
+
* Consumers (enforcers, injectors, formatters, MCPs, plugins) should ask here
|
|
8
|
+
* instead of direct fs reads or scattered loaders.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - Returns ActiveCodexSnapshot compatible with the existing get_active_codex MCP tool.
|
|
16
|
-
* - Provides getTermCount() with safe 60-term fallback (preserves prior behavior of bypasses).
|
|
17
|
-
* - Full frameworkLogger discipline on every load/decision/error.
|
|
18
|
-
* - No caching in v1 skeleton (additive later); no mutation; no enforcement.
|
|
19
|
-
*
|
|
20
|
-
* First wired consumer: src/mcps/enforcer-tools.server.ts (getCodexTermCount bypass removed;
|
|
21
|
-
* now delegates through this service).
|
|
22
|
-
*
|
|
23
|
-
* Next recommended slices (documented in researcher mapping append):
|
|
24
|
-
* - Wire governance.server.ts handleGetActiveCodex to delegate (remove its direct read).
|
|
25
|
-
* - S02b/S02c follow-ups: update codex-injector, context-loader, codex-formatter, plugin.
|
|
26
|
-
* - Make CodexLoader delegate its raw data load here, then re-export from governance.
|
|
27
|
-
*
|
|
28
|
-
* @module governance/codex-policy.service
|
|
29
|
-
* @version 2.0.0-s02-real
|
|
10
|
+
* Provides read-only ActiveCodexSnapshot and term count.
|
|
11
|
+
* Uses canonical resolveCodexPath.
|
|
12
|
+
* Full frameworkLogger on all paths.
|
|
30
13
|
*/
|
|
31
14
|
import type { ActiveCodexSnapshot, ICodexPolicyProvider } from './governance-types.js';
|
|
32
15
|
/**
|
|
@@ -54,4 +37,3 @@ export declare class CodexPolicyService implements ICodexPolicyProvider {
|
|
|
54
37
|
getTermCount(): Promise<number>;
|
|
55
38
|
}
|
|
56
39
|
export declare function getCodexPolicyService(): CodexPolicyService;
|
|
57
|
-
export { CodexPolicyService as default };
|
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CodexPolicyService
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* This is the V2-P1-S02-REAL first concrete migration slice.
|
|
4
|
+
* Governance-owned Single Source of Truth (SSOT) for Codex / policy loading.
|
|
6
5
|
*
|
|
7
|
-
* Role
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* will eventually ask here instead of performing direct fs reads.
|
|
6
|
+
* Role: External Governance owns "what the policy is".
|
|
7
|
+
* Consumers (enforcers, injectors, formatters, MCPs, plugins) should ask here
|
|
8
|
+
* instead of direct fs reads or scattered loaders.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - Returns ActiveCodexSnapshot compatible with the existing get_active_codex MCP tool.
|
|
16
|
-
* - Provides getTermCount() with safe 60-term fallback (preserves prior behavior of bypasses).
|
|
17
|
-
* - Full frameworkLogger discipline on every load/decision/error.
|
|
18
|
-
* - No caching in v1 skeleton (additive later); no mutation; no enforcement.
|
|
19
|
-
*
|
|
20
|
-
* First wired consumer: src/mcps/enforcer-tools.server.ts (getCodexTermCount bypass removed;
|
|
21
|
-
* now delegates through this service).
|
|
22
|
-
*
|
|
23
|
-
* Next recommended slices (documented in researcher mapping append):
|
|
24
|
-
* - Wire governance.server.ts handleGetActiveCodex to delegate (remove its direct read).
|
|
25
|
-
* - S02b/S02c follow-ups: update codex-injector, context-loader, codex-formatter, plugin.
|
|
26
|
-
* - Make CodexLoader delegate its raw data load here, then re-export from governance.
|
|
27
|
-
*
|
|
28
|
-
* @module governance/codex-policy.service
|
|
29
|
-
* @version 2.0.0-s02-real
|
|
10
|
+
* Provides read-only ActiveCodexSnapshot and term count.
|
|
11
|
+
* Uses canonical resolveCodexPath.
|
|
12
|
+
* Full frameworkLogger on all paths.
|
|
30
13
|
*/
|
|
31
14
|
import { frameworkLogger } from '../core/framework-logger.js';
|
|
32
15
|
import { resolveCodexPath } from '../core/config-paths.js';
|
|
@@ -120,7 +103,7 @@ export class CodexPolicyService {
|
|
|
120
103
|
is_fallback: isFallback,
|
|
121
104
|
note: isFallback
|
|
122
105
|
? 'Governance CodexPolicyService — builtin fallback (no external codex.json resolved)'
|
|
123
|
-
: 'Returned via Governance CodexPolicyService
|
|
106
|
+
: 'Returned via Governance CodexPolicyService',
|
|
124
107
|
dynamo_required: true,
|
|
125
108
|
...(includeRaw ? { codex: data } : {}),
|
|
126
109
|
};
|
|
@@ -164,4 +147,3 @@ export function getCodexPolicyService() {
|
|
|
164
147
|
return codexPolicyServiceInstance;
|
|
165
148
|
}
|
|
166
149
|
// Also export the class for direct construction in tests / advanced wiring
|
|
167
|
-
export { CodexPolicyService as default };
|
|
@@ -1,41 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure governance decision logic.
|
|
3
|
-
* This module contains the
|
|
3
|
+
* This module contains the merging rules and metamorphosis scoring.
|
|
4
4
|
* It has no side effects and does not call any MCPs.
|
|
5
5
|
*
|
|
6
6
|
* This is the shared "pure logic" that both the Governance MCP
|
|
7
7
|
* and any HTTP deployment (Vercel) can use.
|
|
8
8
|
*/
|
|
9
9
|
import type { GovernanceVote, GovernanceResult } from './governance-types.js';
|
|
10
|
-
export interface DecisionMatrixInput {
|
|
11
|
-
resonance: number;
|
|
12
|
-
isotopicRatio: number;
|
|
13
|
-
vortexVolume?: number;
|
|
14
|
-
historicalCoherence?: number;
|
|
15
|
-
solarActivity?: 'quiet' | 'moderate' | 'active' | 'storm';
|
|
16
|
-
moralTension?: 'Aligned' | 'Mild' | 'Significant' | 'Critical';
|
|
17
|
-
moralScore?: number;
|
|
18
|
-
moralFusion?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface DecisionMatrixOutput {
|
|
21
|
-
recommendation: 'PASS' | 'NEEDS_REVISION' | 'REJECT';
|
|
22
|
-
confidence: number;
|
|
23
|
-
voteWeight: number;
|
|
24
|
-
reasons: string[];
|
|
25
|
-
moralOverride?: 'rejected_critical' | 'downgraded_significant' | 'none';
|
|
26
|
-
}
|
|
27
|
-
export declare const MORAL_OVERRIDE_LEVELS: {
|
|
28
|
-
Critical: "rejected_critical";
|
|
29
|
-
Significant: "downgraded_significant";
|
|
30
|
-
Mild: "none";
|
|
31
|
-
Aligned: "none";
|
|
32
|
-
};
|
|
33
|
-
export type MoralOverrideThreshold = 'Critical' | 'Significant' | 'Mild' | 'Aligned' | 'disabled';
|
|
34
10
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
11
|
+
* Calculate metamorphosis resonance score for self-evolution proposals.
|
|
12
|
+
*
|
|
13
|
+
* Evaluates whether a proposal increases the system's capacity to govern
|
|
14
|
+
* complex future states. Uses the existing Dynamo resonance signal plus
|
|
15
|
+
* checks for self-improvement indicators.
|
|
16
|
+
*
|
|
17
|
+
* Scoring rubric (0-1):
|
|
18
|
+
* - Base: governance vote confidence (averageConfidence)
|
|
19
|
+
* - Boost: +0.1 if proposal adds new capacity (type=automate/codify)
|
|
20
|
+
* - Boost: +0.05 if historical coherence is strong (>0.8)
|
|
21
|
+
* - Penalty: -0.15 if proposal removes existing capacity (type=compliance-only)
|
|
22
|
+
* - Floor: 0.0, Ceiling: 1.0
|
|
23
|
+
* - Threshold for approval: ≥ 0.7 (configurable via GovernOptions.metamorphosisThreshold)
|
|
24
|
+
*
|
|
25
|
+
* Only meaningful when proposal.type === 'metamorphosis' or source === 'metamorphosis'.
|
|
37
26
|
*/
|
|
38
|
-
export declare function
|
|
27
|
+
export declare function calculateMetamorphosisScore(input: {
|
|
28
|
+
averageConfidence: number;
|
|
29
|
+
proposalType: string;
|
|
30
|
+
historicalCoherence?: number;
|
|
31
|
+
resonanceScore?: number;
|
|
32
|
+
}): number;
|
|
39
33
|
/**
|
|
40
34
|
* Simple weighted merge of votes from multiple servers + external.
|
|
41
35
|
*/
|
|
@@ -1,117 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure governance decision logic.
|
|
3
|
-
* This module contains the
|
|
3
|
+
* This module contains the merging rules and metamorphosis scoring.
|
|
4
4
|
* It has no side effects and does not call any MCPs.
|
|
5
5
|
*
|
|
6
6
|
* This is the shared "pure logic" that both the Governance MCP
|
|
7
7
|
* and any HTTP deployment (Vercel) can use.
|
|
8
8
|
*/
|
|
9
|
-
// Blurrn constants (from chrono-warp-drive)
|
|
10
|
-
const PHI = 1.666;
|
|
11
|
-
const TAU = 0.865;
|
|
12
|
-
export const MORAL_OVERRIDE_LEVELS = {
|
|
13
|
-
Critical: 'rejected_critical',
|
|
14
|
-
Significant: 'downgraded_significant',
|
|
15
|
-
Mild: 'none',
|
|
16
|
-
Aligned: 'none',
|
|
17
|
-
};
|
|
18
9
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
10
|
+
* Calculate metamorphosis resonance score for self-evolution proposals.
|
|
11
|
+
*
|
|
12
|
+
* Evaluates whether a proposal increases the system's capacity to govern
|
|
13
|
+
* complex future states. Uses the existing Dynamo resonance signal plus
|
|
14
|
+
* checks for self-improvement indicators.
|
|
15
|
+
*
|
|
16
|
+
* Scoring rubric (0-1):
|
|
17
|
+
* - Base: governance vote confidence (averageConfidence)
|
|
18
|
+
* - Boost: +0.1 if proposal adds new capacity (type=automate/codify)
|
|
19
|
+
* - Boost: +0.05 if historical coherence is strong (>0.8)
|
|
20
|
+
* - Penalty: -0.15 if proposal removes existing capacity (type=compliance-only)
|
|
21
|
+
* - Floor: 0.0, Ceiling: 1.0
|
|
22
|
+
* - Threshold for approval: ≥ 0.7 (configurable via GovernOptions.metamorphosisThreshold)
|
|
23
|
+
*
|
|
24
|
+
* Only meaningful when proposal.type === 'metamorphosis' or source === 'metamorphosis'.
|
|
21
25
|
*/
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let confidence = 0.75;
|
|
28
|
-
let voteWeight = 1.0;
|
|
29
|
-
let moralOverride = 'none';
|
|
30
|
-
// Log moral fusion if present — weighted signal for transparency
|
|
31
|
-
if (moralFusion != null) {
|
|
32
|
-
reasons.push(`Moral-numerological fusion: ${(moralFusion * 100).toFixed(0)}%`);
|
|
26
|
+
export function calculateMetamorphosisScore(input) {
|
|
27
|
+
let score = input.averageConfidence;
|
|
28
|
+
// Self-improvement capacity: proposals that add automation or codification boost the score
|
|
29
|
+
if (input.proposalType === 'automate' || input.proposalType === 'codify') {
|
|
30
|
+
score += 0.10;
|
|
33
31
|
}
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
recommendation = 'REJECT';
|
|
38
|
-
confidence = 0.92;
|
|
39
|
-
voteWeight = 1.6;
|
|
40
|
-
moralOverride = 'rejected_critical';
|
|
41
|
-
reasons.push(`Critical moral tension — proposal violates moral alignment (score: ${moralScore != null ? (moralScore * 100).toFixed(0) + '%' : 'unknown'})`);
|
|
42
|
-
return {
|
|
43
|
-
recommendation,
|
|
44
|
-
confidence: Math.min(0.99, Math.max(0.5, confidence)),
|
|
45
|
-
voteWeight: Math.max(0.5, Math.min(1.8, voteWeight)),
|
|
46
|
-
reasons,
|
|
47
|
-
moralOverride,
|
|
48
|
-
};
|
|
32
|
+
// Compliance-only proposals (guard type with no new capacity) get a penalty
|
|
33
|
+
if (input.proposalType === 'compliance') {
|
|
34
|
+
score -= 0.15;
|
|
49
35
|
}
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
moralDowngrade = true;
|
|
54
|
-
moralOverride = 'downgraded_significant';
|
|
55
|
-
voteWeight *= 0.85;
|
|
56
|
-
reasons.push(`Significant moral tension — proceed with caution (score: ${moralScore != null ? (moralScore * 100).toFixed(0) + '%' : 'unknown'})`);
|
|
36
|
+
// Strong historical coherence means the system is stable enough for self-evolution
|
|
37
|
+
if (input.historicalCoherence != null && input.historicalCoherence > 0.8) {
|
|
38
|
+
score += 0.05;
|
|
57
39
|
}
|
|
58
|
-
//
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
voteWeight *= 1.05;
|
|
62
|
-
reasons.push(`Moral alignment confirmed (score: ${(moralScore * 100).toFixed(0)}%)`);
|
|
40
|
+
// High Dynamo resonance (Solar signal) supports self-evolution
|
|
41
|
+
if (input.resonanceScore != null && input.resonanceScore >= 0.82) {
|
|
42
|
+
score += 0.05;
|
|
63
43
|
}
|
|
64
|
-
|
|
65
|
-
recommendation = 'PASS';
|
|
66
|
-
confidence = 0.97;
|
|
67
|
-
voteWeight = 1.4;
|
|
68
|
-
reasons.push('High symbiotic resonance (PHI-aligned)');
|
|
69
|
-
}
|
|
70
|
-
else if (resonance >= 0.82 && isotopicRatio >= 0.88) {
|
|
71
|
-
recommendation = 'PASS';
|
|
72
|
-
confidence = 0.89;
|
|
73
|
-
voteWeight = 1.15;
|
|
74
|
-
reasons.push('Solid alignment above TAU threshold');
|
|
75
|
-
}
|
|
76
|
-
else if (resonance < 0.75 || isotopicRatio < 0.80) {
|
|
77
|
-
recommendation = 'REJECT';
|
|
78
|
-
confidence = 0.84;
|
|
79
|
-
reasons.push('Signal below critical threshold (1 - TAU)');
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
reasons.push('Moderate resonance - requires refinement');
|
|
83
|
-
}
|
|
84
|
-
// Moral downgrade: Significant tension demotes PASS → NEEDS_REVISION
|
|
85
|
-
if (moralDowngrade && recommendation === 'PASS') {
|
|
86
|
-
recommendation = 'NEEDS_REVISION';
|
|
87
|
-
reasons.push('Moral tension downgraded recommendation from PASS to NEEDS_REVISION');
|
|
88
|
-
}
|
|
89
|
-
if (vortexVolume < 2.5e25) {
|
|
90
|
-
reasons.push('Low inertial mass (W x M = V)');
|
|
91
|
-
if (recommendation === 'PASS')
|
|
92
|
-
recommendation = 'NEEDS_REVISION';
|
|
93
|
-
}
|
|
94
|
-
if (historicalCoherence < 0.70) {
|
|
95
|
-
reasons.push('Weak historical alignment with past decisions');
|
|
96
|
-
if (recommendation === 'PASS')
|
|
97
|
-
recommendation = 'NEEDS_REVISION';
|
|
98
|
-
}
|
|
99
|
-
else if (historicalCoherence > 0.90) {
|
|
100
|
-
reasons.push('Strong continuity with previous governance');
|
|
101
|
-
voteWeight *= 1.1;
|
|
102
|
-
}
|
|
103
|
-
// Solar adjustment (from chrono-warp-drive)
|
|
104
|
-
if (solarActivity === 'active' || solarActivity === 'storm') {
|
|
105
|
-
voteWeight *= 0.92;
|
|
106
|
-
reasons.push('Elevated solar activity - increased caution applied');
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
recommendation,
|
|
110
|
-
confidence: Math.min(0.99, Math.max(0.5, confidence)),
|
|
111
|
-
voteWeight: Math.max(0.5, Math.min(1.8, voteWeight)),
|
|
112
|
-
reasons,
|
|
113
|
-
moralOverride,
|
|
114
|
-
};
|
|
44
|
+
return Math.min(1.0, Math.max(0.0, Math.round(score * 100) / 100));
|
|
115
45
|
}
|
|
116
46
|
/**
|
|
117
47
|
* Simple weighted merge of votes from multiple servers + external.
|