create-principles-disciple 1.148.10 → 1.149.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.
Files changed (53) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/package.json +1 -1
  3. package/console/dist/server/index.js +7 -0
  4. package/console/dist/server/models/OwnerDecisionConsoleModel.d.ts +18 -0
  5. package/console/dist/server/models/OwnerDecisionConsoleModel.js +42 -6
  6. package/console/dist/server/routes/compatibility-scan.d.ts +18 -0
  7. package/console/dist/server/routes/compatibility-scan.js +33 -0
  8. package/console/dist/shared/compatibility-scan-contract.d.ts +26 -0
  9. package/console/dist/shared/compatibility-scan-contract.js +1 -0
  10. package/console/dist/web/assets/app.js +31 -31
  11. package/core/dist/runtime/activation/index.d.ts +2 -2
  12. package/core/dist/runtime/activation/index.d.ts.map +1 -1
  13. package/core/dist/runtime/activation/index.js +1 -1
  14. package/core/dist/runtime/activation/index.js.map +1 -1
  15. package/core/dist/runtime/activation/promotion-readiness-evaluator.d.ts +34 -0
  16. package/core/dist/runtime/activation/promotion-readiness-evaluator.d.ts.map +1 -1
  17. package/core/dist/runtime/activation/promotion-readiness-evaluator.js +49 -8
  18. package/core/dist/runtime/activation/promotion-readiness-evaluator.js.map +1 -1
  19. package/core/dist/runtime/activation-compatibility-read-model.d.ts +33 -2
  20. package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
  21. package/core/dist/runtime/activation-compatibility-read-model.js +46 -6
  22. package/core/dist/runtime/activation-compatibility-read-model.js.map +1 -1
  23. package/core/dist/runtime/config/pd-config-types.d.ts +0 -2
  24. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  25. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  26. package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
  27. package/core/dist/runtime/config/pd-config-validate.js +82 -0
  28. package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
  29. package/core/package.json +1 -1
  30. package/dist/installer.d.ts +58 -7
  31. package/dist/installer.d.ts.map +1 -1
  32. package/dist/installer.js +131 -6
  33. package/dist/installer.js.map +1 -1
  34. package/host-runtime/package.json +1 -1
  35. package/install-layout/dist/index.d.ts +1 -1
  36. package/install-layout/dist/index.js +1 -1
  37. package/install-layout/dist/pd-home.d.ts +9 -2
  38. package/install-layout/dist/pd-home.js +77 -14
  39. package/install-layout/package.json +1 -1
  40. package/package.json +3 -3
  41. package/pd-cli/dist/commands/runtime-compatibility-scan.d.ts +5 -2
  42. package/pd-cli/dist/commands/runtime-compatibility-scan.d.ts.map +1 -1
  43. package/pd-cli/dist/commands/runtime-compatibility-scan.js +28 -2
  44. package/pd-cli/dist/commands/runtime-compatibility-scan.js.map +1 -1
  45. package/pd-cli/dist/services/config-doctor.d.ts +9 -0
  46. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  47. package/pd-cli/dist/services/config-doctor.js +15 -0
  48. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  49. package/pd-cli/package.json +1 -1
  50. package/plugin/dist/bundle.js +284 -284
  51. package/release-manager/dist/installer.js +131 -6
  52. package/release-manager/package.json +1 -1
  53. package/workbuddy-adapter/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "productVersion": "2.8.6",
4
- "sourceCommit": "80e8f5e27a6b7b395f73d2334477eb34317c3cc0"
4
+ "sourceCommit": "7ad401c6ecb8a3f50d53783c0091fcf65dccadd9"
5
5
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,6 +21,7 @@ import { handleLifecycleRoute, disposeLifecycleModels } from './routes/lifecycle
21
21
  import { handleExaminerRoute } from './routes/examiner.js';
22
22
  import { handleActivationsRoute, disposeActivationsModels } from './routes/activations.js';
23
23
  import { handleReceiptsRoute, disposeReceiptsModels } from './routes/receipts.js';
24
+ import { handleCompatibilityScanRoute } from './routes/compatibility-scan.js';
24
25
  import { handleApprovalsGroupedRoute, disposeApprovalsGroupedModels } from './routes/approvals-grouped.js';
25
26
  import { handleGovernanceRoute, handleGovernanceExperienceRoute, resolveOwnerConfigSnapshot, disposeGovernanceModels } from './routes/governance.js';
26
27
  import { handleOwnerDecisionsRoute } from './routes/owner-decisions.js';
@@ -367,6 +368,12 @@ export function handleRequest(services) {
367
368
  asyncHandler(() => handleFailedTasksRoute(req, res, { workspaceDir: services.workspaceDir, subPath, featureFlags: services.feedbackFlags }))(req, res);
368
369
  return;
369
370
  }
371
+ // 5B-F: GET /api/runtime/compatibility-scan — read-only rule
372
+ // compatibility scan (reason-granular; never the per-row findings).
373
+ if (routePath === '/api/runtime/compatibility-scan') {
374
+ asyncHandler(() => handleCompatibilityScanRoute(req, res, services.workspaceDir))(req, res);
375
+ return;
376
+ }
370
377
  // PRI-533: GET /api/receipts/counts, /api/receipts/principles/:id
371
378
  if (routePath === '/api/receipts' || routePath.startsWith('/api/receipts/')) {
372
379
  const subPath = routePath.slice('/api/receipts'.length);
@@ -23,10 +23,28 @@ export interface OwnerDecisionItem {
23
23
  readonly evidenceUnavailableReason?: string;
24
24
  readonly createdAt: string;
25
25
  }
26
+ /**
27
+ * rc-9 — 一条"本应进入收件箱但没有出现"的 RuleCode 条目。
28
+ *
29
+ * 收件箱此前用 `catch { continue; }` 吞掉 owner-review 读取失败,于是
30
+ * "没有待决"与"读不到"在页面上同形。这里把每类跳过显式计数,并保留
31
+ * 有界样本用于归因(rc-8:不放大输出)。
32
+ */
33
+ export interface OwnerDecisionReadIssue {
34
+ readonly scope: 'rulecode_shadow';
35
+ readonly reason: 'owner_review_read_failed' | 'readiness_not_actionable' | 'shadow_scan_unavailable';
36
+ readonly count: number;
37
+ /** 最多 5 个 activation id,仅用于归因。 */
38
+ readonly sampleActivationIds: readonly string[];
39
+ /** 首个跳过原因的短摘要(≤200 字符)。 */
40
+ readonly detail?: string;
41
+ }
26
42
  export interface OwnerDecisionListResult {
27
43
  readonly items: readonly OwnerDecisionItem[];
28
44
  readonly total: number;
29
45
  readonly generatedAt: string;
46
+ /** rc-9:空数组 = 没有任何条目被静默吞掉。 */
47
+ readonly readIssues: readonly OwnerDecisionReadIssue[];
30
48
  }
31
49
  export declare class OwnerDecisionConsoleModel {
32
50
  private readonly workspaceDir;
@@ -14,6 +14,12 @@ import * as path from 'node:path';
14
14
  import { SqliteConnection, SqlitePIArtifactStore, SqliteApprovalQueueStore, collectOwnerDecisionFacts, deriveOwnerDecisionCapability, buildOwnerDecisionReview, } from '@principles/core/runtime';
15
15
  import { ActivationsConsoleModel } from './ActivationsConsoleModel.js';
16
16
  import { createArtifactPrincipleResolutionDeps, resolveArtifactPrincipleId, } from './artifact-principle-resolver.js';
17
+ /** 每条 issue 保留的样本上限,防止异常放大响应体。 */
18
+ const MAX_READ_ISSUE_SAMPLES = 5;
19
+ const MAX_READ_ISSUE_DETAIL_CHARS = 200;
20
+ function describeError(error) {
21
+ return error instanceof Error ? error.message : String(error);
22
+ }
17
23
  const GOVERNANCE_TASK_KINDS = new Set(['evaluator', 'rollout_reviewer']);
18
24
  /** tasks.status 合法值(PDTaskStatus)运行时守卫。 */
19
25
  const TASK_STATUSES = new Set(['pending', 'leased', 'succeeded', 'retry_wait', 'failed', 'needs_human_review']);
@@ -191,13 +197,33 @@ export class OwnerDecisionConsoleModel {
191
197
  async listOwnerDecisionItems(routeContext) {
192
198
  const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
193
199
  if (!fs.existsSync(stateDbPath)) {
194
- return { items: [], total: 0, generatedAt: new Date().toISOString() };
200
+ return { items: [], total: 0, generatedAt: new Date().toISOString(), readIssues: [] };
195
201
  }
196
202
  const conn = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: true });
197
203
  try {
198
204
  const db = conn.getDb();
199
205
  const artifactStore = new SqlitePIArtifactStore(conn);
200
206
  const items = [];
207
+ // rc-9:被跳过/读取失败的条目必须可计数、可归因,不能只体现在"条数变少"。
208
+ const issueByReason = new Map();
209
+ const recordReadIssue = (reason, activationId, detail) => {
210
+ let issue = issueByReason.get(reason);
211
+ if (issue === undefined) {
212
+ issue = { scope: 'rulecode_shadow', reason, count: 0, sampleActivationIds: [] };
213
+ issueByReason.set(reason, issue);
214
+ }
215
+ issue.count += 1;
216
+ if (activationId.length > 0
217
+ && issue.sampleActivationIds.length < MAX_READ_ISSUE_SAMPLES
218
+ && !issue.sampleActivationIds.includes(activationId)) {
219
+ issue.sampleActivationIds.push(activationId);
220
+ }
221
+ if (detail !== undefined && detail.length > 0 && issue.detail === undefined) {
222
+ issue.detail = detail.length > MAX_READ_ISSUE_DETAIL_CHARS
223
+ ? `${detail.slice(0, MAX_READ_ISSUE_DETAIL_CHARS)}…`
224
+ : detail;
225
+ }
226
+ };
201
227
  // ── 1. needs_human_review 的 decision-capable 任务 (PRI-629 核心) ──
202
228
  let nhrRows = [];
203
229
  try {
@@ -272,10 +298,14 @@ export class OwnerDecisionConsoleModel {
272
298
  // Console HTTP surface for the visibility evaluation; promotion
273
299
  // still re-evaluates at the real owner-review/promote entry.
274
300
  const review = await activationModel.getOwnerReview(activationId, true, { routeContext });
275
- if (review.readiness.status !== 'ready' && review.readiness.status !== 'evidence_insufficient')
301
+ if (review.readiness.status !== 'ready' && review.readiness.status !== 'evidence_insufficient') {
302
+ // 非待决:不进收件箱,但必须留下计数与原因(否则该 activation 永久不可见)。
303
+ recordReadIssue('readiness_not_actionable', activationId, `readiness=${review.readiness.status}`);
276
304
  continue;
305
+ }
277
306
  }
278
- catch {
307
+ catch (error) {
308
+ recordReadIssue('owner_review_read_failed', activationId, describeError(error));
279
309
  continue;
280
310
  }
281
311
  items.push({
@@ -295,10 +325,16 @@ export class OwnerDecisionConsoleModel {
295
325
  });
296
326
  }
297
327
  }
298
- catch {
299
- // activations 表缺失 → 跳过
328
+ catch (error) {
329
+ // activations 表缺失 → 无影子规则可列;这本身是降级事实,必须可见。
330
+ recordReadIssue('shadow_scan_unavailable', '', describeError(error));
300
331
  }
301
- return { items, total: items.length, generatedAt: new Date().toISOString() };
332
+ return {
333
+ items,
334
+ total: items.length,
335
+ generatedAt: new Date().toISOString(),
336
+ readIssues: [...issueByReason.values()],
337
+ };
302
338
  }
303
339
  finally {
304
340
  conn.close();
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 5B-F — GET /api/runtime/compatibility-scan (read-only).
3
+ *
4
+ * Surfaces the SAME scan the installer preflight and `pd runtime
5
+ * compatibility-scan` use, reduced to reason-granular counts + samples (see
6
+ * `shared/compatibility-scan-contract.ts`). The scanner already holds the
7
+ * workspace DB connection semantics (`readonly`), so this route adds no
8
+ * runtime dependency — it reuses @principles/core/runtime in process.
9
+ *
10
+ * No mutation: the handler only constructs the read model and maps its result.
11
+ */
12
+ import type { IncomingMessage, ServerResponse } from 'node:http';
13
+ import type { ActivationCompatibilityScanResult } from '@principles/core/runtime';
14
+ import type { CompatibilityScanViewData } from '../../shared/compatibility-scan-contract.js';
15
+ /** Injectable seam so the route mapping is testable without seeding SQLite. */
16
+ export type CompatibilityScanner = (workspaceDir: string) => ActivationCompatibilityScanResult;
17
+ export declare function toCompatibilityScanView(result: ActivationCompatibilityScanResult): CompatibilityScanViewData;
18
+ export declare function handleCompatibilityScanRoute(req: IncomingMessage, res: ServerResponse, workspaceDir: string, scan?: CompatibilityScanner): Promise<void>;
@@ -0,0 +1,33 @@
1
+ import { ActivationCompatibilityReadModel } from '@principles/core/runtime';
2
+ import { sendSuccess, sendError, sendMethodNotAllowed, errorMessage } from '../utils/response.js';
3
+ const defaultScanner = workspaceDir => new ActivationCompatibilityReadModel({ workspaceDir }).scan();
4
+ export function toCompatibilityScanView(result) {
5
+ return {
6
+ status: result.status,
7
+ scannedActivations: result.scannedActivations,
8
+ unscannable: result.skipped.map(({ reason, count, sampleActivationIds }) => ({
9
+ reason,
10
+ count,
11
+ sampleActivationIds: [...sampleActivationIds],
12
+ })),
13
+ findingsTotal: result.findings.length,
14
+ ...(result.reason !== undefined ? { reason: result.reason } : {}),
15
+ ...(result.nextAction !== undefined ? { nextAction: result.nextAction } : {}),
16
+ };
17
+ }
18
+ /* eslint-disable @typescript-eslint/max-params */
19
+ export async function handleCompatibilityScanRoute(req, res, workspaceDir, scan = defaultScanner) {
20
+ if (req.method !== 'GET') {
21
+ sendMethodNotAllowed(res);
22
+ return;
23
+ }
24
+ try {
25
+ sendSuccess(res, toCompatibilityScanView(scan(workspaceDir)));
26
+ }
27
+ catch (error) {
28
+ // rc-9: a scan that throws is observable, not an empty list.
29
+ sendError(res, 500, 'compatibility_scan_failed', errorMessage(error), {
30
+ reason: 'compatibility_scan_failed',
31
+ });
32
+ }
33
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 5B-F — read-only "rule compatibility scan" view shared by the console server
3
+ * and the browser.
4
+ *
5
+ * This is a DELIBERATELY reduced projection of the core scan result:
6
+ * reason-granular counts + bounded activation-id samples, never the per-row
7
+ * findings array. The console needs to answer "did this upgrade verify my
8
+ * rules?", not to re-render the CLI report.
9
+ *
10
+ * Type-only: the browser validates the wire payload in
11
+ * `ui/utils/validators.ts`; the server maps it in `server/routes/compatibility-scan.ts`.
12
+ */
13
+ export interface CompatibilityScanUnscannableView {
14
+ reason: string;
15
+ count: number;
16
+ sampleActivationIds: string[];
17
+ }
18
+ export interface CompatibilityScanViewData {
19
+ status: 'clean' | 'incomplete' | 'legacy_dependency' | 'no_state_db' | 'scan_failed';
20
+ scannedActivations: number;
21
+ /** Empty = every ACTIVE row was read. */
22
+ unscannable: CompatibilityScanUnscannableView[];
23
+ findingsTotal: number;
24
+ reason?: string;
25
+ nextAction?: string;
26
+ }
@@ -0,0 +1 @@
1
+ export {};