create-principles-disciple 1.145.16 → 1.145.17

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 (65) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/worker/workspace-worker.js +2 -1
  3. package/console/dist/server/index.js +12 -0
  4. package/console/dist/server/routes/design-gate.d.ts +11 -0
  5. package/console/dist/server/routes/design-gate.js +156 -0
  6. package/console/dist/ui/api.d.ts +29 -1
  7. package/console/dist/ui/api.js +105 -1
  8. package/console/dist/ui/i18n/en.json +45 -0
  9. package/console/dist/ui/i18n/zh-CN.json +45 -0
  10. package/console/dist/ui/pages/control-center/ControlCenterPage.js +2 -1
  11. package/console/dist/ui/pages/control-center/DesignGatePanel.d.ts +1 -0
  12. package/console/dist/ui/pages/control-center/DesignGatePanel.js +137 -0
  13. package/console/dist/web/assets/app.css +6 -0
  14. package/console/dist/web/assets/app.js +30 -30
  15. package/core/dist/runtime-v2/index.d.ts +3 -0
  16. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  17. package/core/dist/runtime-v2/index.js +3 -0
  18. package/core/dist/runtime-v2/index.js.map +1 -1
  19. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts +12 -0
  20. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts.map +1 -1
  21. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.js +23 -0
  22. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.js.map +1 -1
  23. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +1 -1
  24. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  25. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +15 -5
  26. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  27. package/core/dist/runtime-v2/internalization/design-gate-facts.d.ts +54 -0
  28. package/core/dist/runtime-v2/internalization/design-gate-facts.d.ts.map +1 -0
  29. package/core/dist/runtime-v2/internalization/design-gate-facts.js +172 -0
  30. package/core/dist/runtime-v2/internalization/design-gate-facts.js.map +1 -0
  31. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +8 -1
  32. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  33. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js +73 -3
  34. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  35. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  36. package/core/dist/runtime-v2/internalization/evaluator-runner.js +64 -2
  37. package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  38. package/core/dist/runtime-v2/internalization/rule-context-v2.d.ts +3 -0
  39. package/core/dist/runtime-v2/internalization/rule-context-v2.d.ts.map +1 -1
  40. package/core/dist/runtime-v2/internalization/rule-context-v2.js +4 -0
  41. package/core/dist/runtime-v2/internalization/rule-context-v2.js.map +1 -1
  42. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.d.ts +49 -0
  43. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -0
  44. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.js +274 -0
  45. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.js.map +1 -0
  46. package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
  47. package/core/dist/runtime-v2/store/sqlite-connection.js +31 -0
  48. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  49. package/core/package.json +5 -1
  50. package/host-runtime/dist/codex-artificer-trusted-facts.d.ts +7 -0
  51. package/host-runtime/dist/codex-artificer-trusted-facts.js +17 -0
  52. package/host-runtime/dist/codex-rule-context-provider.js +82 -13
  53. package/host-runtime/dist/design-gate-facts.d.ts +37 -0
  54. package/host-runtime/dist/design-gate-facts.js +249 -0
  55. package/host-runtime/dist/index.d.ts +3 -0
  56. package/host-runtime/dist/index.js +3 -0
  57. package/host-runtime/dist/production-rulehost-gate.js +37 -1
  58. package/host-runtime/dist/workspace-behavior-evidence.d.ts +9 -0
  59. package/host-runtime/dist/workspace-behavior-evidence.js +85 -0
  60. package/host-runtime/package.json +1 -1
  61. package/package.json +1 -1
  62. package/plugin/dist/bundle.js +449 -419
  63. package/plugin/dist/rulehost-evidence.js +24 -24
  64. package/release-manager/package.json +1 -1
  65. package/workbuddy-adapter/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "productVersion": "2.3.9",
4
- "sourceCommit": "a821a6fe469e297285c206a53f5175a6de679aa7"
3
+ "productVersion": "2.3.10",
4
+ "sourceCommit": "72df0b91189c8ad18dbbfefb48c140609bad5c14"
5
5
  }
@@ -28,7 +28,7 @@
28
28
  import fs from 'node:fs';
29
29
  import path from 'node:path';
30
30
  import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime-v2';
31
- import { createWorkspaceBehaviorEvidencePort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, saveHostToolDeclaration, } from '@principles/host-runtime';
31
+ import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, saveHostToolDeclaration, } from '@principles/host-runtime';
32
32
  import { catchUpCodexIngestion } from '../ingestion/catch-up.js';
33
33
  import { CODEX_TOOL_SEMANTIC_MAPPINGS, CODEX_TOOL_SEMANTICS } from '../tool-semantics.js';
34
34
  const WORKER_OWNER = 'companion-worker';
@@ -407,6 +407,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
407
407
  logger,
408
408
  emitEvent,
409
409
  behaviorEvidence: createWorkspaceBehaviorEvidencePort(workspaceDir, CODEX_TOOL_SEMANTICS),
410
+ trustedFacts: createCodexArtificerTrustedFactsPort(),
410
411
  toolSemantics: CODEX_TOOL_SEMANTICS,
411
412
  // PRI-741: artificer generation gets the Codex host projection
412
413
  // (Bash/apply_patch — evidence-bound, intentionally sparse).
@@ -23,6 +23,7 @@ import { handleApprovalsGroupedRoute, disposeApprovalsGroupedModels } from './ro
23
23
  import { handleGovernanceRoute, handleGovernanceExperienceRoute, resolveOwnerConfigSnapshot, disposeGovernanceModels } from './routes/governance.js';
24
24
  import { handleOwnerDecisionsRoute } from './routes/owner-decisions.js';
25
25
  import { handleEvidenceOutcomesRoute } from './routes/evidence-outcomes.js';
26
+ import { handleDesignGateRoute } from './routes/design-gate.js';
26
27
  import { handleOwnerDecisionInboxRoute, handleOwnerDecisionViewRoute, handleOwnerDecisionLibraryRoute, parseOwnerDecisionViewSubPath } from './routes/owner-decision.js';
27
28
  import { handleOwnerIdentityRoute } from './routes/owner-identity.js';
28
29
  import { handleEvidenceChainRoute, disposeEvidenceChainModels } from './routes/evidence-chain.js';
@@ -502,6 +503,17 @@ function handleRequest(services) {
502
503
  }))(req, res);
503
504
  return;
504
505
  }
506
+ if (urlPath.startsWith('/api/v1/governance/design-gate/')) {
507
+ const identity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
508
+ const { ownerId, credentialId } = identity;
509
+ asyncHandler(() => handleDesignGateRoute(req, res, {
510
+ workspaceDir: services.workspaceDir,
511
+ subPath: urlPath.slice('/api/v1/governance/design-gate'.length),
512
+ ownerIdentity: services.authConfig.isEnabled() && ownerId !== null && credentialId !== null
513
+ ? { ownerId, credentialId } : null,
514
+ }))(req, res);
515
+ return;
516
+ }
505
517
  // PRI-466/477: GET/POST/PUT /api/v1/intent (+ /init, /content sub-paths)
506
518
  if (urlPath === '/api/v1/intent' || urlPath.startsWith('/api/v1/intent/')) {
507
519
  const subPath = urlPath === '/api/v1/intent' ? '' : urlPath.slice('/api/v1/intent'.length);
@@ -0,0 +1,11 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export interface DesignGateRouteContext {
3
+ workspaceDir: string;
4
+ subPath: string;
5
+ ownerIdentity: {
6
+ ownerId: string;
7
+ credentialId: string;
8
+ } | null;
9
+ }
10
+ /** Authenticated Owner attestations; never treats a principle approval as a design decision. */
11
+ export declare function handleDesignGateRoute(req: IncomingMessage, res: ServerResponse, ctx: DesignGateRouteContext): Promise<void>;
@@ -0,0 +1,156 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import path from 'node:path';
3
+ import { createRuntimeStateHandle, SqliteDesignGateStore, DesignGateStoreError } from '@principles/core/runtime-v2';
4
+ import { listObservedDesignGateSessions, readDesignGateSpecSnapshot } from '@principles/host-runtime';
5
+ import { readBody } from '../utils/request.js';
6
+ import { sendSuccess, sendError, sendBadRequest, sendMethodNotAllowed } from '../utils/response.js';
7
+ function record(value) {
8
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
9
+ }
10
+ function text(value) {
11
+ return typeof value === 'string' && value.trim().length > 0 && value.length <= 4096;
12
+ }
13
+ function decision(value) {
14
+ return value === 'approved' || value === 'not_approved' || value === 'not_required';
15
+ }
16
+ function scope(value) {
17
+ return record(value) && Object.keys(value).every(key => key === 'paths' || key === 'actions')
18
+ && Array.isArray(value.paths) && value.paths.length > 0 && value.paths.length <= 100
19
+ && value.paths.every(p => text(p) && !/[*?[\]]/.test(p) && !path.isAbsolute(p) && !p.split(/[\\/]/).includes('..'))
20
+ && Array.isArray(value.actions) && value.actions.length > 0 && value.actions.length <= 3
21
+ && value.actions.every(a => a === 'read' || a === 'write' || a === 'execute');
22
+ }
23
+ function closedBody(value, keys) {
24
+ return record(value) && Object.keys(value).every(key => keys.includes(key));
25
+ }
26
+ /** Authenticated Owner attestations; never treats a principle approval as a design decision. */
27
+ export async function handleDesignGateRoute(req, res, ctx) {
28
+ if (!ctx.ownerIdentity) {
29
+ sendError(res, 403, 'owner_authentication_required', 'A verified Owner identity is required to read or change design declarations.');
30
+ return;
31
+ }
32
+ const url = new URL(req.url ?? '/', 'http://localhost');
33
+ if (req.method === 'GET' && ctx.subPath === '/sessions') {
34
+ try {
35
+ sendSuccess(res, { sessions: listObservedDesignGateSessions(ctx.workspaceDir) });
36
+ }
37
+ catch {
38
+ sendError(res, 503, 'session_source_unavailable', 'Observed Codex session data is unavailable.', { nextAction: 'Run a Codex session with PD observation enabled, then refresh.' });
39
+ }
40
+ return;
41
+ }
42
+ if (req.method === 'GET' && ctx.subPath === '/declaration') {
43
+ const project = url.searchParams.get('projectWorkspacePath');
44
+ const session = url.searchParams.get('hostSessionId');
45
+ if (!text(project) || !text(session)) {
46
+ sendBadRequest(res, 'Project and native session are required.');
47
+ return;
48
+ }
49
+ let declaration;
50
+ try {
51
+ const handle = await createRuntimeStateHandle({ workspaceDir: ctx.workspaceDir, readonly: true, bootstrapIfMissing: false });
52
+ try {
53
+ declaration = new SqliteDesignGateStore(handle.stateManager.connection).getLatestDeclaration(project, session);
54
+ }
55
+ finally {
56
+ await handle.close();
57
+ }
58
+ }
59
+ catch {
60
+ sendError(res, 503, 'declaration_source_unavailable', 'The design declaration source could not be read.', {
61
+ nextAction: 'Restore or initialize the governance workspace state database, then refresh the declaration.',
62
+ });
63
+ return;
64
+ }
65
+ sendSuccess(res, { declaration });
66
+ return;
67
+ }
68
+ if (req.method !== 'POST') {
69
+ sendMethodNotAllowed(res);
70
+ return;
71
+ }
72
+ let raw;
73
+ try {
74
+ raw = JSON.parse(await readBody(req));
75
+ }
76
+ catch {
77
+ sendBadRequest(res, 'Request body must be valid JSON.');
78
+ return;
79
+ }
80
+ const create = ctx.subPath === '/declarations';
81
+ const mutate = /^\/declarations\/([^/]+)\/(decision|revoke)$/.exec(ctx.subPath);
82
+ if (!create && !mutate) {
83
+ sendError(res, 404, 'not_found', 'Unknown design declaration operation.');
84
+ return;
85
+ }
86
+ if (create) {
87
+ if (!closedBody(raw, ['projectWorkspacePath', 'hostSessionId', 'specPath', 'scope', 'decision'])
88
+ || !text(raw.projectWorkspacePath) || !text(raw.hostSessionId) || !text(raw.specPath)
89
+ || !scope(raw.scope) || !decision(raw.decision)) {
90
+ sendBadRequest(res, 'Expected an observed project/session, SPEC path, explicit paths/actions and decision; identity fields are not accepted.');
91
+ return;
92
+ }
93
+ }
94
+ else if (!closedBody(raw, mutate?.[2] === 'decision' ? ['expectedRevision', 'decision'] : ['expectedRevision'])
95
+ || typeof raw.expectedRevision !== 'number' || !Number.isSafeInteger(raw.expectedRevision) || raw.expectedRevision < 1
96
+ || (mutate?.[2] === 'decision' && !decision(raw.decision))) {
97
+ sendBadRequest(res, 'Expected the current revision and a valid decision.');
98
+ return;
99
+ }
100
+ // All request validation/source checks precede any write transaction.
101
+ if (!record(raw)) {
102
+ sendBadRequest(res, 'Invalid declaration.');
103
+ return;
104
+ }
105
+ try {
106
+ let createInput = null;
107
+ if (create && text(raw.projectWorkspacePath) && text(raw.hostSessionId) && text(raw.specPath) && scope(raw.scope) && decision(raw.decision)) {
108
+ const chosen = listObservedDesignGateSessions(ctx.workspaceDir).find(entry => entry.projectWorkspacePath === raw.projectWorkspacePath && entry.hostSessionId === raw.hostSessionId);
109
+ if (!chosen) {
110
+ sendError(res, 409, 'native_scope_unverified', 'Select a Codex session already observed by this workspace.');
111
+ return;
112
+ }
113
+ const snapshot = readDesignGateSpecSnapshot(chosen.projectWorkspacePath, path.resolve(chosen.projectWorkspacePath, raw.specPath));
114
+ createInput = { project: chosen.projectWorkspacePath, session: chosen.hostSessionId, specPath: snapshot.realPath, specDigest: snapshot.digest, scope: raw.scope, decision: raw.decision };
115
+ }
116
+ const handle = await createRuntimeStateHandle({ workspaceDir: ctx.workspaceDir, bootstrapIfMissing: false });
117
+ try {
118
+ const store = new SqliteDesignGateStore(handle.stateManager.connection);
119
+ const actor = ctx.ownerIdentity;
120
+ const decidedAt = new Date().toISOString();
121
+ if (createInput) {
122
+ sendSuccess(res, { declaration: store.createDeclaration({ sourceRef: randomUUID(), governanceWorkspacePath: path.resolve(ctx.workspaceDir), projectWorkspacePath: createInput.project, hostSessionId: createInput.session, taskRef: `codex:${createInput.session}`, specPath: createInput.specPath, specDigest: createInput.specDigest, scope: createInput.scope, decision: createInput.decision, actor, decidedAt }) });
123
+ }
124
+ else if (mutate && typeof raw.expectedRevision === 'number') {
125
+ const sourceRef = decodeURIComponent(mutate[1] ?? '');
126
+ if (mutate[2] === 'revoke')
127
+ sendSuccess(res, { declaration: store.revoke({ sourceRef, expectedRevision: raw.expectedRevision, actor, decidedAt }) });
128
+ else if (decision(raw.decision)) {
129
+ const existing = store.getDeclaration(sourceRef);
130
+ if (existing) {
131
+ const currentSpec = readDesignGateSpecSnapshot(existing.projectWorkspacePath, existing.specPath);
132
+ if (currentSpec.digest !== existing.specDigest) {
133
+ sendError(res, 409, 'design_gate_spec_changed', 'The bound SPEC changed after this declaration was recorded.', {
134
+ nextAction: 'Review the current SPEC and create a new declaration before changing its decision.',
135
+ });
136
+ return;
137
+ }
138
+ }
139
+ sendSuccess(res, { declaration: store.updateDecision({ sourceRef, expectedRevision: raw.expectedRevision, decision: raw.decision, actor, decidedAt }) });
140
+ }
141
+ }
142
+ }
143
+ finally {
144
+ await handle.close();
145
+ }
146
+ }
147
+ catch (error) {
148
+ if (error instanceof DesignGateStoreError) {
149
+ const status = error.code === 'invalid_input' ? 400 : error.code === 'not_found' ? 404 : error.code === 'corrupt_data' ? 503 : 409;
150
+ sendError(res, status, `design_gate_${error.code}`, error.message, { nextAction: 'Refresh the declaration before retrying; no previous record was overwritten.' });
151
+ }
152
+ else {
153
+ sendError(res, 503, 'design_gate_source_unavailable', 'The SPEC, observed session or declaration source could not be verified.', { nextAction: 'Check that the SPEC is a readable file inside the observed project and refresh the session list.' });
154
+ }
155
+ }
156
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ApiResponse } from "../types.js";
2
2
  import type { OwnerDecisionsData, OwnerResolutionResultData, OwnerDecisionInboxData, OwnerDecisionLibraryData } from "./utils/validators.js";
3
+ import type { DesignGateAction, DesignGateDecision, DesignGateDeclaration, DesignGateScope } from "@principles/core/runtime-v2/internalization/design-gate-facts";
3
4
  import type { GovernanceExperienceSnapshot, OwnerGovernanceView, OwnerDecisionViewCore } from '@principles/core/runtime-v2';
4
5
  import type { OwnerIdentityViewData, OwnerIdentityRegisterData, OwnerIdentityUnregisterData } from "./utils/validators.js";
5
6
  import type { FeedbackReportData, FeedbackDraftSummaryData, FeedbackDraftEnvelopeData, FeedbackChannelsData, FeedbackSubmitResultData, DeleteEnvelopeData, WorkspaceEntryData, RemovedEnvelopeData, SyncResultData, ConfigSummaryData, ConfigCatalogData, AgentBindingUpdateData, DefaultRuntimeUpdateData, RuntimeProfileMutationData, ReadinessCheckData, FeatureFlagUpdateData, OutputLanguageData, GovernanceQueueData, RecoveryResultData, FailedTaskDetailData, ActivationsData, DisableActivationData, LifecycleMetricsData, UpdateStatusData, UpdateHistoryData, ApplyUpdateResultData, UpdateRecoveryData, UpdateTransactionData, ApprovalRecordData, PrinciplesListData, CorePrinciplesData, ApprovalsGroupedData, EvidenceChainData, TrajectoryData, IntentSummaryData, IntentDecisionRecordData, IntentDecisionResultData, IntentDecisionSummaryData, FollowUpResponseData, IntentInitResultData, IntentSaveResultData, IntentRawContentData, IntentVersionData, RuleCodeOwnerReviewData, RuleCodeMutationData } from "./utils/validators.js";
@@ -343,7 +344,34 @@ export interface FollowUpPayload {
343
344
  candidateId?: string;
344
345
  }
345
346
  declare function dispatchFollowUp(decisionId: string, payload: FollowUpPayload): Promise<ApiResponse<FollowUpResponseData>>;
346
- export { request, getToken, setToken, clearToken, checkAuth, approveApproval, rejectApproval, editApproval, fetchPrinciples, fetchCorePrinciples, fetchPrincipleDetail, fetchPrincipleGovernance, fetchOwnerDecisionView, fetchOwnerDecisionInbox, fetchOwnerDecisionLibrary, fetchPrincipleTrajectory, fetchPrincipleReceipts, fetchReceiptCounts, fetchEvidenceAudit, archivePrinciple, unarchivePrinciple, createFeedbackReport, listFeedbackReports, getFeedbackReport, deleteFeedbackReport, fetchFeedbackChannels, submitFeedbackReport, markFeedbackReportSent, fetchConfigSummary, fetchConfigCatalog, updateAgentBinding, updateDefaultRuntime, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, fetchAgentReadiness, patchFeatureFlag, fetchOutputLanguage, updateOutputLanguage, fetchWorkspaces, addWorkspace, removeWorkspace, syncWorkspace, fetchGovernanceQueue, fetchGovernanceExperience, recoverFailedTask, fetchFailedTaskDetail, fetchOwnerDecisions, resolveOwnerDecision, fetchApprovalsGrouped, fetchAllActivations, disableActivation, proposePromptRevision, fetchRuleCodeOwnerReview, ruleCodeDecision, pauseAllRuleCode, releaseRuleCodePause, fetchLifecycleMetrics, fetchUpdateStatus, fetchUpdateHistory, applyFullUpdate, fetchUpdateRecovery, fetchUpdateTransaction, fetchEvidenceChain, fetchIntentSummary, fetchIntentContent, createIntentTemplate, saveIntentContent, fetchIntentVersions, recordIntentDecision, listIntentDecisionsByPainId, listIntentDecisionsByTaskId, fetchIntentDecisionSummary, dispatchFollowUp, };
347
+ export interface DesignGateObservedSession {
348
+ projectWorkspacePath: string;
349
+ hostSessionId: string;
350
+ }
351
+ export interface DesignGateDeclarationInput {
352
+ projectWorkspacePath: string;
353
+ hostSessionId: string;
354
+ specPath: string;
355
+ scope: DesignGateScope;
356
+ decision: DesignGateDecision;
357
+ }
358
+ declare function fetchDesignGateSessions(): Promise<ApiResponse<{
359
+ sessions: DesignGateObservedSession[];
360
+ }>>;
361
+ declare function fetchDesignGateDeclaration(projectWorkspacePath: string, hostSessionId: string): Promise<ApiResponse<{
362
+ declaration: DesignGateDeclaration | null;
363
+ }>>;
364
+ declare function createDesignGateDeclaration(input: DesignGateDeclarationInput): Promise<ApiResponse<{
365
+ declaration: DesignGateDeclaration | null;
366
+ }>>;
367
+ declare function updateDesignGateDecision(sourceRef: string, expectedRevision: number, decision: DesignGateDecision): Promise<ApiResponse<{
368
+ declaration: DesignGateDeclaration | null;
369
+ }>>;
370
+ declare function revokeDesignGateDeclaration(sourceRef: string, expectedRevision: number): Promise<ApiResponse<{
371
+ declaration: DesignGateDeclaration | null;
372
+ }>>;
373
+ export { request, getToken, setToken, clearToken, checkAuth, approveApproval, rejectApproval, editApproval, fetchPrinciples, fetchCorePrinciples, fetchPrincipleDetail, fetchPrincipleGovernance, fetchOwnerDecisionView, fetchOwnerDecisionInbox, fetchOwnerDecisionLibrary, fetchPrincipleTrajectory, fetchPrincipleReceipts, fetchReceiptCounts, fetchEvidenceAudit, archivePrinciple, unarchivePrinciple, createFeedbackReport, listFeedbackReports, getFeedbackReport, deleteFeedbackReport, fetchFeedbackChannels, submitFeedbackReport, markFeedbackReportSent, fetchConfigSummary, fetchConfigCatalog, updateAgentBinding, updateDefaultRuntime, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, fetchAgentReadiness, patchFeatureFlag, fetchOutputLanguage, updateOutputLanguage, fetchWorkspaces, addWorkspace, removeWorkspace, syncWorkspace, fetchGovernanceQueue, fetchGovernanceExperience, recoverFailedTask, fetchFailedTaskDetail, fetchOwnerDecisions, resolveOwnerDecision, fetchApprovalsGrouped, fetchAllActivations, disableActivation, proposePromptRevision, fetchRuleCodeOwnerReview, ruleCodeDecision, pauseAllRuleCode, releaseRuleCodePause, fetchLifecycleMetrics, fetchUpdateStatus, fetchUpdateHistory, applyFullUpdate, fetchUpdateRecovery, fetchUpdateTransaction, fetchEvidenceChain, fetchIntentSummary, fetchIntentContent, createIntentTemplate, saveIntentContent, fetchIntentVersions, recordIntentDecision, listIntentDecisionsByPainId, listIntentDecisionsByTaskId, fetchIntentDecisionSummary, dispatchFollowUp, fetchDesignGateSessions, fetchDesignGateDeclaration, createDesignGateDeclaration, updateDesignGateDecision, revokeDesignGateDeclaration, };
374
+ export type { DesignGateAction, DesignGateDecision, DesignGateDeclaration, DesignGateScope };
347
375
  export type { FeedbackReportData, FeedbackDraftSummaryData, FeedbackDraftEnvelopeData, FeedbackChannelsData, FeedbackSubmitResultData, DeleteEnvelopeData, WorkspaceEntryData, RemovedEnvelopeData, SyncResultData, ConfigSummaryData, ConfigCatalogData, AgentBindingUpdateData, DefaultRuntimeUpdateData, RuntimeProfileMutationData, ReadinessCheckData, FeatureFlagUpdateData, OutputLanguageData, GovernanceQueueData, RecoveryResultData, ActivationsData, DisableActivationData, RuleCodeOwnerReviewData, RuleCodeMutationData, FailedTaskDetailData, LifecycleMetricsData, UpdateStatusData, UpdateHistoryData, ApplyUpdateResultData, UpdateRecoveryData, ApprovalRecordData, PrinciplesListData, CorePrinciplesData, CorePrincipleData, ApprovalsGroupedData, EvidenceChainData, EvidenceChainRecordData, EvidenceChainStateData, TrajectoryData, TrajectoryStageData, IntentSummaryData, IntentSectionsData, IntentDocWarningData, IntentDecisionRecordData, IntentDecisionResultData, IntentDecisionSummaryData, FollowUpResponseData, LinkCandidateFollowUpData, GuideRulehostFollowUpData, GeneratePatchProposalFollowUpData, IntentVersionEntry, IntentVersionData, } from "./utils/validators.js";
348
376
  export type { ActivationRecordData as ActivationRecord } from "./utils/validators.js";
349
377
  export type { OwnerDecisionInboxData, OwnerDecisionLibraryData } from "./utils/validators.js";
@@ -891,9 +891,113 @@ async function dispatchFollowUp(decisionId, payload) {
891
891
  body: JSON.stringify(payload),
892
892
  }, validateFollowUpResponse);
893
893
  }
894
+ function isDesignGateRecord(value) {
895
+ return typeof value === "object" && value !== null && !Array.isArray(value);
896
+ }
897
+ function validateDesignGateSessions(value) {
898
+ if (!isDesignGateRecord(value) || !Array.isArray(value.sessions))
899
+ return null;
900
+ const sessions = [];
901
+ for (const entry of value.sessions) {
902
+ if (!isDesignGateRecord(entry)
903
+ || typeof entry.projectWorkspacePath !== "string" || entry.projectWorkspacePath.trim() === ""
904
+ || typeof entry.hostSessionId !== "string" || entry.hostSessionId.trim() === "")
905
+ return null;
906
+ sessions.push({ projectWorkspacePath: entry.projectWorkspacePath, hostSessionId: entry.hostSessionId });
907
+ }
908
+ return { sessions };
909
+ }
910
+ function isDesignGateAction(value) {
911
+ return value === "read" || value === "write" || value === "execute";
912
+ }
913
+ function isDesignGateDecisionValue(value) {
914
+ return value === "approved" || value === "not_approved" || value === "not_required";
915
+ }
916
+ function isNonEmptyDesignGateString(value) {
917
+ return typeof value === "string" && value.trim().length > 0;
918
+ }
919
+ function isDesignGateStringArray(value) {
920
+ if (!Array.isArray(value))
921
+ return false;
922
+ for (let index = 0; index < value.length; index += 1) {
923
+ if (!Object.hasOwn(value, index) || !isNonEmptyDesignGateString(value[index]))
924
+ return false;
925
+ }
926
+ return true;
927
+ }
928
+ /**
929
+ * Field-by-field mirror of the server declaration contract (rc-1 style) —
930
+ * the browser bundle never runtime-imports the Node-oriented core barrel, so
931
+ * the wire format is re-validated locally; the server remains the authority.
932
+ */
933
+ function isDesignGateDeclarationValue(value) {
934
+ if (!isDesignGateRecord(value))
935
+ return false;
936
+ if (!Object.hasOwn(value, "sourceRef") || !isNonEmptyDesignGateString(value.sourceRef))
937
+ return false;
938
+ if (!isNonEmptyDesignGateString(value.governanceWorkspacePath))
939
+ return false;
940
+ if (!isNonEmptyDesignGateString(value.projectWorkspacePath))
941
+ return false;
942
+ if (!isNonEmptyDesignGateString(value.hostSessionId))
943
+ return false;
944
+ if (!isNonEmptyDesignGateString(value.taskRef))
945
+ return false;
946
+ if (!isNonEmptyDesignGateString(value.specPath) || !isNonEmptyDesignGateString(value.specDigest))
947
+ return false;
948
+ if (!isDesignGateRecord(value.scope))
949
+ return false;
950
+ if (!Object.hasOwn(value.scope, "paths") || !Object.hasOwn(value.scope, "actions"))
951
+ return false;
952
+ if (!isDesignGateStringArray(value.scope.paths) || value.scope.paths.length === 0)
953
+ return false;
954
+ if (!Array.isArray(value.scope.actions) || value.scope.actions.length === 0)
955
+ return false;
956
+ for (let index = 0; index < value.scope.actions.length; index += 1) {
957
+ if (!Object.hasOwn(value.scope.actions, index) || !isDesignGateAction(value.scope.actions[index]))
958
+ return false;
959
+ }
960
+ if (!isDesignGateDecisionValue(value.decision))
961
+ return false;
962
+ if (typeof value.revision !== "number" || !Number.isSafeInteger(value.revision) || value.revision < 1)
963
+ return false;
964
+ if (typeof value.revoked !== "boolean")
965
+ return false;
966
+ if (!isDesignGateRecord(value.actor)
967
+ || !Object.hasOwn(value.actor, "ownerId") || !Object.hasOwn(value.actor, "credentialId")
968
+ || !isNonEmptyDesignGateString(value.actor.ownerId) || !isNonEmptyDesignGateString(value.actor.credentialId))
969
+ return false;
970
+ if (!isNonEmptyDesignGateString(value.decidedAt))
971
+ return false;
972
+ return true;
973
+ }
974
+ function validateDesignGateDeclarationEnvelope(value) {
975
+ if (!isDesignGateRecord(value) || !Object.hasOwn(value, "declaration"))
976
+ return null;
977
+ if (value.declaration === null)
978
+ return { declaration: null };
979
+ return isDesignGateDeclarationValue(value.declaration) ? { declaration: value.declaration } : null;
980
+ }
981
+ const designGateBasePath = "/api/v1/governance/design-gate";
982
+ async function fetchDesignGateSessions() {
983
+ return request(`${designGateBasePath}/sessions`, undefined, validateDesignGateSessions);
984
+ }
985
+ async function fetchDesignGateDeclaration(projectWorkspacePath, hostSessionId) {
986
+ const query = new URLSearchParams({ projectWorkspacePath, hostSessionId });
987
+ return request(`${designGateBasePath}/declaration?${query.toString()}`, undefined, validateDesignGateDeclarationEnvelope);
988
+ }
989
+ async function createDesignGateDeclaration(input) {
990
+ return request(`${designGateBasePath}/declarations`, { method: "POST", body: JSON.stringify(input) }, validateDesignGateDeclarationEnvelope);
991
+ }
992
+ async function updateDesignGateDecision(sourceRef, expectedRevision, decision) {
993
+ return request(`${designGateBasePath}/declarations/${encodeURIComponent(sourceRef)}/decision`, { method: "POST", body: JSON.stringify({ expectedRevision, decision }) }, validateDesignGateDeclarationEnvelope);
994
+ }
995
+ async function revokeDesignGateDeclaration(sourceRef, expectedRevision) {
996
+ return request(`${designGateBasePath}/declarations/${encodeURIComponent(sourceRef)}/revoke`, { method: "POST", body: JSON.stringify({ expectedRevision }) }, validateDesignGateDeclarationEnvelope);
997
+ }
894
998
  // ── Exports ───────────────────────────────────────────────────────────────────
895
999
  export { request,
896
1000
  // auth
897
1001
  getToken, setToken, clearToken, checkAuth, approveApproval, rejectApproval, editApproval, fetchPrinciples, fetchCorePrinciples, fetchPrincipleDetail, fetchPrincipleGovernance, fetchOwnerDecisionView, fetchOwnerDecisionInbox, fetchOwnerDecisionLibrary, fetchPrincipleTrajectory, fetchPrincipleReceipts, fetchReceiptCounts, fetchEvidenceAudit, archivePrinciple, unarchivePrinciple, createFeedbackReport, listFeedbackReports, getFeedbackReport, deleteFeedbackReport,
898
1002
  // Feedback submit ladder (Slice 3, spec §8)
899
- fetchFeedbackChannels, submitFeedbackReport, markFeedbackReportSent, fetchConfigSummary, fetchConfigCatalog, updateAgentBinding, updateDefaultRuntime, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, fetchAgentReadiness, patchFeatureFlag, fetchOutputLanguage, updateOutputLanguage, fetchWorkspaces, addWorkspace, removeWorkspace, syncWorkspace, fetchGovernanceQueue, fetchGovernanceExperience, recoverFailedTask, fetchFailedTaskDetail, fetchOwnerDecisions, resolveOwnerDecision, fetchApprovalsGrouped, fetchAllActivations, disableActivation, proposePromptRevision, fetchRuleCodeOwnerReview, ruleCodeDecision, pauseAllRuleCode, releaseRuleCodePause, fetchLifecycleMetrics, fetchUpdateStatus, fetchUpdateHistory, applyFullUpdate, fetchUpdateRecovery, fetchUpdateTransaction, fetchEvidenceChain, fetchIntentSummary, fetchIntentContent, createIntentTemplate, saveIntentContent, fetchIntentVersions, recordIntentDecision, listIntentDecisionsByPainId, listIntentDecisionsByTaskId, fetchIntentDecisionSummary, dispatchFollowUp, };
1003
+ fetchFeedbackChannels, submitFeedbackReport, markFeedbackReportSent, fetchConfigSummary, fetchConfigCatalog, updateAgentBinding, updateDefaultRuntime, createRuntimeProfile, updateRuntimeProfile, deleteRuntimeProfile, fetchAgentReadiness, patchFeatureFlag, fetchOutputLanguage, updateOutputLanguage, fetchWorkspaces, addWorkspace, removeWorkspace, syncWorkspace, fetchGovernanceQueue, fetchGovernanceExperience, recoverFailedTask, fetchFailedTaskDetail, fetchOwnerDecisions, resolveOwnerDecision, fetchApprovalsGrouped, fetchAllActivations, disableActivation, proposePromptRevision, fetchRuleCodeOwnerReview, ruleCodeDecision, pauseAllRuleCode, releaseRuleCodePause, fetchLifecycleMetrics, fetchUpdateStatus, fetchUpdateHistory, applyFullUpdate, fetchUpdateRecovery, fetchUpdateTransaction, fetchEvidenceChain, fetchIntentSummary, fetchIntentContent, createIntentTemplate, saveIntentContent, fetchIntentVersions, recordIntentDecision, listIntentDecisionsByPainId, listIntentDecisionsByTaskId, fetchIntentDecisionSummary, dispatchFollowUp, fetchDesignGateSessions, fetchDesignGateDeclaration, createDesignGateDeclaration, updateDesignGateDecision, revokeDesignGateDeclaration, };
@@ -1404,6 +1404,51 @@
1404
1404
  "eyebrow": "Control Center",
1405
1405
  "title": "Config Readiness",
1406
1406
  "subtitle": "PD can only work when configuration is complete. This page shows config readiness — not a system health dashboard.",
1407
+ "designGate": {
1408
+ "title": "Local Codex Design Declaration",
1409
+ "description": "Record an Owner decision for a SPEC and an observed native Codex session. The server verifies the session and SPEC snapshot; it does not prove that implementation matches natural-language intent.",
1410
+ "loadingSessions": "Loading observed Codex sessions…",
1411
+ "noSessions": "No native Codex sessions have been observed for this workspace yet. Open a Codex session with PD observation enabled, then refresh.",
1412
+ "refresh": "Refresh",
1413
+ "loadingDeclaration": "Loading the latest declaration…",
1414
+ "nativeSession": "Observed native session",
1415
+ "noDeclaration": "No declaration exists for this session. Record the SPEC, covered paths, actions, and an explicit Owner decision.",
1416
+ "specPath": "SPEC file path",
1417
+ "specPathHint": "Relative to the selected project workspace, or an absolute path inside it",
1418
+ "scopePathsInput": "Project-relative paths covered by this declaration (one per line)",
1419
+ "scopePathsHint": "packages/example/src/file.ts",
1420
+ "scopePathsHelp": "Use . for the project root. With Execute, . covers command invocations originating in this native project/session; it does not sandbox process effects or prove filesystem containment.",
1421
+ "scopeActionsInput": "Actions covered",
1422
+ "initialDecision": "Owner decision",
1423
+ "decisions": {
1424
+ "approved": "Approved",
1425
+ "notApproved": "Not approved",
1426
+ "notRequired": "Approval not required"
1427
+ },
1428
+ "actions": {
1429
+ "read": "Read",
1430
+ "write": "Write",
1431
+ "execute": "Execute"
1432
+ },
1433
+ "decision": "Decision:",
1434
+ "revision": "Revision:",
1435
+ "spec": "SPEC:",
1436
+ "specDigest": "SPEC snapshot digest:",
1437
+ "scopePaths": "Covered paths:",
1438
+ "scopeActions": "Covered actions:",
1439
+ "owner": "Recorded by Owner:",
1440
+ "decidedAt": "Recorded at:",
1441
+ "revoked": "Revoked",
1442
+ "revokedLatest": "The latest declaration is revoked (revision {{revision}}). You can record a new declaration for this session.",
1443
+ "semanticLimit": "This Owner declaration is bound to the shown SPEC snapshot, project, session, and paths/actions. Execute with . covers commands originating in this native project/session; it does not sandbox process effects or prove filesystem containment. Host operations outside a reliably classified path/action scope remain unknown. This declaration does not prove that code satisfies the SPEC’s natural-language meaning.",
1444
+ "requiredFields": "Enter a SPEC path, at least one covered path, and one or more actions.",
1445
+ "invalidMutationResponse": "The server returned no declaration after a successful change. Refresh before continuing.",
1446
+ "approve": "Approve this scope",
1447
+ "markPending": "Mark not approved",
1448
+ "revoke": "Revoke declaration",
1449
+ "saving": "Saving…",
1450
+ "create": "Record declaration"
1451
+ },
1407
1452
  "configReady": "Configuration complete. All enabled agents are ready.",
1408
1453
  "configNeedsSetup": "Some agents need configuration before they can run.",
1409
1454
  "configNotReady": "Some agents cannot run. Check configuration errors below.",
@@ -1404,6 +1404,51 @@
1404
1404
  "eyebrow": "控制中心",
1405
1405
  "title": "配置就绪",
1406
1406
  "subtitle": "PD 能否正常工作取决于配置是否完成。本页展示配置就绪状态——不是系统健康面板。",
1407
+ "designGate": {
1408
+ "title": "本地 Codex 设计声明",
1409
+ "description": "为一份 SPEC 和已观测到的 Codex 原生会话记录拥有者决定。服务端会核验会话与 SPEC 快照,但不会证明实现符合自然语言意图。",
1410
+ "loadingSessions": "正在加载已观测的 Codex 会话…",
1411
+ "noSessions": "此工作区尚未观测到 Codex 原生会话。请在启用 PD 观测的情况下打开 Codex 会话,然后刷新。",
1412
+ "refresh": "刷新",
1413
+ "loadingDeclaration": "正在加载最新声明…",
1414
+ "nativeSession": "已观测的原生会话",
1415
+ "noDeclaration": "此会话尚无声明。请填写 SPEC、覆盖路径、操作和明确的拥有者决定。",
1416
+ "specPath": "SPEC 文件路径",
1417
+ "specPathHint": "相对于所选项目工作区,或工作区内的绝对路径",
1418
+ "scopePathsInput": "声明覆盖的项目相对路径(每行一个)",
1419
+ "scopePathsHint": "packages/example/src/file.ts",
1420
+ "scopePathsHelp": "项目根目录使用 .。选择“执行”并填写 .,表示覆盖从此原生项目/会话发起的命令;这不会沙箱化进程副作用,也不能证明文件系统影响仅限于项目内。",
1421
+ "scopeActionsInput": "覆盖的操作",
1422
+ "initialDecision": "拥有者决定",
1423
+ "decisions": {
1424
+ "approved": "已批准",
1425
+ "notApproved": "未批准",
1426
+ "notRequired": "无需批准"
1427
+ },
1428
+ "actions": {
1429
+ "read": "读取",
1430
+ "write": "写入",
1431
+ "execute": "执行"
1432
+ },
1433
+ "decision": "决定:",
1434
+ "revision": "修订:",
1435
+ "spec": "SPEC:",
1436
+ "specDigest": "SPEC 快照摘要:",
1437
+ "scopePaths": "覆盖路径:",
1438
+ "scopeActions": "覆盖操作:",
1439
+ "owner": "记录拥有者:",
1440
+ "decidedAt": "记录时间:",
1441
+ "revoked": "已撤回",
1442
+ "revokedLatest": "最新声明已撤回(修订 {{revision}})。你可以为此会话记录新声明。",
1443
+ "semanticLimit": "此拥有者声明绑定所示 SPEC 快照、项目、会话及路径/操作范围。选择“执行”并填写 .,覆盖从此原生项目/会话发起的命令;这不会沙箱化进程副作用,也不能证明文件系统影响仅限于项目内。无法可靠分类到路径/操作范围的宿主操作仍属未知。此声明不能证明代码符合 SPEC 的自然语言含义。",
1444
+ "requiredFields": "请填写 SPEC 路径、至少一个覆盖路径和至少一种操作。",
1445
+ "invalidMutationResponse": "服务器在变更成功后未返回声明。请刷新后再继续。",
1446
+ "approve": "批准此范围",
1447
+ "markPending": "标记为未批准",
1448
+ "revoke": "撤回声明",
1449
+ "saving": "保存中…",
1450
+ "create": "记录声明"
1451
+ },
1407
1452
  "configReady": "配置完成,所有已启用智能体就绪。",
1408
1453
  "configNeedsSetup": "部分智能体需要配置后才能运行。",
1409
1454
  "configNotReady": "部分智能体无法运行,请检查下方配置错误。",
@@ -11,6 +11,7 @@ import { enumLabel } from "../../utils/enum-labels.js";
11
11
  import { WorkflowDiagram } from "./WorkflowDiagram.js";
12
12
  import { AgentGroup } from "./AgentGroup.js";
13
13
  import { RuntimeProfileManager } from "./RuntimeProfileManager.js";
14
+ import { DesignGatePanel } from "./DesignGatePanel.js";
14
15
  import { AGENT_GROUPS, AGENT_METADATA, } from "../../utils/agent-metadata.js";
15
16
  // ── Runtime validators (H section / ERR-001/005/009/013) ─────────────────────
16
17
  function validateSource(raw) {
@@ -485,7 +486,7 @@ export function ControlCenterPage() {
485
486
  };
486
487
  const overallReadiness = computeOverallReadiness(diagnostics);
487
488
  const availableProfiles = catalogData?.profiles ?? configData.runtimeProfiles;
488
- return (_jsx(PageShell, { children: _jsxs("div", { className: "animate-[pdFadeIn_400ms_ease-out]", children: [_jsx("div", { className: "font-mono text-[12px] tracking-[0.14em] text-ink-3 uppercase mb-3", children: t("pages.controlCenter.eyebrow") }), _jsx("h1", { className: "text-[29px] font-semibold tracking-tight text-ink mb-2", children: t("pages.controlCenter.title") }), _jsx("p", { className: "text-ink-3 text-[14px] max-w-[760px] leading-relaxed mb-7", children: t("pages.controlCenter.subtitle") }), _jsx(WorkflowDiagram, {}), _jsx(CompactStatusBar, { readiness: overallReadiness, agents: configData.agents }), _jsxs("section", { className: "mt-8", "aria-labelledby": "section-agents", children: [_jsx(SectionTitle, { id: "section-agents", children: t("pages.controlCenter.internalAgents") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3", children: t("pages.controlCenter.internalAgentsDescription") }), (() => {
489
+ return (_jsx(PageShell, { children: _jsxs("div", { className: "animate-[pdFadeIn_400ms_ease-out]", children: [_jsx("div", { className: "font-mono text-[12px] tracking-[0.14em] text-ink-3 uppercase mb-3", children: t("pages.controlCenter.eyebrow") }), _jsx("h1", { className: "text-[29px] font-semibold tracking-tight text-ink mb-2", children: t("pages.controlCenter.title") }), _jsx("p", { className: "text-ink-3 text-[14px] max-w-[760px] leading-relaxed mb-7", children: t("pages.controlCenter.subtitle") }), _jsx(WorkflowDiagram, {}), _jsx(CompactStatusBar, { readiness: overallReadiness, agents: configData.agents }), _jsx(DesignGatePanel, {}), _jsxs("section", { className: "mt-8", "aria-labelledby": "section-agents", children: [_jsx(SectionTitle, { id: "section-agents", children: t("pages.controlCenter.internalAgents") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3", children: t("pages.controlCenter.internalAgentsDescription") }), (() => {
489
490
  const { groups, unknown } = groupAgentsByDependency(configData.agents);
490
491
  const locale = i18n.language.startsWith("en")
491
492
  ? "en"
@@ -0,0 +1 @@
1
+ export declare function DesignGatePanel(): import("react").JSX.Element;