@gitgov/core 1.8.3 → 1.9.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.
@@ -54,7 +54,7 @@ interface ActorRecord {
54
54
  /**
55
55
  * Canonical schema for agent operational manifests.
56
56
  */
57
- interface AgentRecord {
57
+ interface AgentRecord<TMetadata = object> {
58
58
  /**
59
59
  * Unique identifier for the agent, linking to an ActorRecord.
60
60
  */
@@ -87,9 +87,7 @@ interface AgentRecord {
87
87
  * This field does NOT affect agent execution - it is purely informational.
88
88
  *
89
89
  */
90
- metadata?: {
91
- [k: string]: unknown | undefined;
92
- };
90
+ metadata?: TMetadata;
93
91
  engine: {
94
92
  type: 'local';
95
93
  /**
@@ -274,7 +272,7 @@ interface CycleRecord {
274
272
  /**
275
273
  * Canonical schema for execution log records - the universal event stream
276
274
  */
277
- interface ExecutionRecord {
275
+ interface ExecutionRecord<TMetadata = object> {
278
276
  /**
279
277
  * Unique identifier for the execution log entry (10 timestamp + 1 dash + 4 'exec' + 1 dash + max 50 slug = 66 max)
280
278
  */
@@ -317,6 +315,15 @@ interface ExecutionRecord {
317
315
  *
318
316
  */
319
317
  references?: string[];
318
+ /**
319
+ * Optional structured data for machine consumption.
320
+ * Use this field for data that needs to be programmatically processed (e.g., audit findings,
321
+ * performance metrics, scan results). This complements result (human-readable WHAT) and
322
+ * notes (narrative HOW/WHY) by providing structured, queryable data.
323
+ * Common use cases: audit findings arrays, performance metrics, tool outputs, scan summaries.
324
+ *
325
+ */
326
+ metadata?: TMetadata;
320
327
  }
321
328
 
322
329
  /**
@@ -754,7 +761,7 @@ declare class GitGovError extends Error {
754
761
  type index$m_ActorPayload = ActorPayload;
755
762
  type index$m_ActorRecord = ActorRecord;
756
763
  type index$m_AgentPayload = AgentPayload;
757
- type index$m_AgentRecord = AgentRecord;
764
+ type index$m_AgentRecord<TMetadata = object> = AgentRecord<TMetadata>;
758
765
  type index$m_ChangelogPayload = ChangelogPayload;
759
766
  type index$m_ChangelogRecord = ChangelogRecord;
760
767
  type index$m_CustomRecord = CustomRecord;
@@ -763,7 +770,7 @@ type index$m_CycleRecord = CycleRecord;
763
770
  type index$m_EmbeddedMetadataHeader = EmbeddedMetadataHeader;
764
771
  type index$m_EmbeddedMetadataRecord<T extends GitGovRecordPayload> = EmbeddedMetadataRecord<T>;
765
772
  type index$m_ExecutionPayload = ExecutionPayload;
766
- type index$m_ExecutionRecord = ExecutionRecord;
773
+ type index$m_ExecutionRecord<TMetadata = object> = ExecutionRecord<TMetadata>;
767
774
  type index$m_FeedbackPayload = FeedbackPayload;
768
775
  type index$m_FeedbackRecord = FeedbackRecord;
769
776
  type index$m_GitGovActorRecord = GitGovActorRecord;
@@ -3756,12 +3763,23 @@ declare function createCycleRecord(payload: Partial<CycleRecord>): CycleRecord;
3756
3763
  declare function loadCycleRecord(data: unknown): GitGovCycleRecord;
3757
3764
 
3758
3765
  /**
3759
- * Creates a complete ExecutionRecord with validation
3766
+ * Creates a complete ExecutionRecord with validation.
3767
+ *
3768
+ * The factory is generic to preserve the metadata type for compile-time safety.
3760
3769
  *
3761
- * @param payload - Partial ExecutionRecord payload
3762
- * @returns ExecutionRecord - The validated ExecutionRecord
3770
+ * @param payload - Partial ExecutionRecord payload with optional typed metadata
3771
+ * @returns ExecutionRecord<TMetadata> - The validated ExecutionRecord with preserved metadata type
3772
+ *
3773
+ * @example
3774
+ * interface AuditMetadata { scannedFiles: number; }
3775
+ * const record = createExecutionRecord<AuditMetadata>({
3776
+ * taskId: '1752274500-task-audit',
3777
+ * result: 'Audit complete',
3778
+ * metadata: { scannedFiles: 245 }
3779
+ * });
3780
+ * // record.metadata?.scannedFiles is typed as number
3763
3781
  */
3764
- declare function createExecutionRecord(payload: Partial<ExecutionRecord>): ExecutionRecord;
3782
+ declare function createExecutionRecord<TMetadata extends object = object>(payload: Partial<ExecutionRecord<TMetadata>>): ExecutionRecord<TMetadata>;
3765
3783
  /**
3766
3784
  * Loads and validates an existing ExecutionRecord from untrusted data.
3767
3785
  * Used by RecordStore to validate records when reading from disk.
@@ -5675,8 +5693,29 @@ declare const Schemas: {
5675
5693
  default: never[];
5676
5694
  description: string;
5677
5695
  };
5696
+ metadata: {
5697
+ type: string;
5698
+ additionalProperties: boolean;
5699
+ description: string;
5700
+ examples: ({
5701
+ findings: {
5702
+ type: string;
5703
+ file: string;
5704
+ line: number;
5705
+ }[];
5706
+ scannedFiles: number;
5707
+ metrics?: never;
5708
+ } | {
5709
+ metrics: {
5710
+ duration_ms: number;
5711
+ memory_mb: number;
5712
+ };
5713
+ findings?: never;
5714
+ scannedFiles?: never;
5715
+ })[];
5716
+ };
5678
5717
  };
5679
- examples: {
5718
+ examples: ({
5680
5719
  id: string;
5681
5720
  taskId: string;
5682
5721
  type: string;
@@ -5684,7 +5723,34 @@ declare const Schemas: {
5684
5723
  result: string;
5685
5724
  notes: string;
5686
5725
  references: string[];
5687
- }[];
5726
+ metadata?: never;
5727
+ } | {
5728
+ id: string;
5729
+ taskId: string;
5730
+ type: string;
5731
+ title: string;
5732
+ result: string;
5733
+ notes: string;
5734
+ references: string[];
5735
+ metadata: {
5736
+ scannedFiles: number;
5737
+ scannedLines: number;
5738
+ duration_ms: number;
5739
+ findings: {
5740
+ id: string;
5741
+ severity: string;
5742
+ file: string;
5743
+ line: number;
5744
+ type: string;
5745
+ }[];
5746
+ summary: {
5747
+ critical: number;
5748
+ high: number;
5749
+ medium: number;
5750
+ low: number;
5751
+ };
5752
+ };
5753
+ })[];
5688
5754
  };
5689
5755
  readonly FeedbackRecord: {
5690
5756
  $schema: string;
@@ -7459,8 +7525,29 @@ declare function getSchema(name: SchemaName): {
7459
7525
  default: never[];
7460
7526
  description: string;
7461
7527
  };
7528
+ metadata: {
7529
+ type: string;
7530
+ additionalProperties: boolean;
7531
+ description: string;
7532
+ examples: ({
7533
+ findings: {
7534
+ type: string;
7535
+ file: string;
7536
+ line: number;
7537
+ }[];
7538
+ scannedFiles: number;
7539
+ metrics?: never;
7540
+ } | {
7541
+ metrics: {
7542
+ duration_ms: number;
7543
+ memory_mb: number;
7544
+ };
7545
+ findings?: never;
7546
+ scannedFiles?: never;
7547
+ })[];
7548
+ };
7462
7549
  };
7463
- examples: {
7550
+ examples: ({
7464
7551
  id: string;
7465
7552
  taskId: string;
7466
7553
  type: string;
@@ -7468,7 +7555,34 @@ declare function getSchema(name: SchemaName): {
7468
7555
  result: string;
7469
7556
  notes: string;
7470
7557
  references: string[];
7471
- }[];
7558
+ metadata?: never;
7559
+ } | {
7560
+ id: string;
7561
+ taskId: string;
7562
+ type: string;
7563
+ title: string;
7564
+ result: string;
7565
+ notes: string;
7566
+ references: string[];
7567
+ metadata: {
7568
+ scannedFiles: number;
7569
+ scannedLines: number;
7570
+ duration_ms: number;
7571
+ findings: {
7572
+ id: string;
7573
+ severity: string;
7574
+ file: string;
7575
+ line: number;
7576
+ type: string;
7577
+ }[];
7578
+ summary: {
7579
+ critical: number;
7580
+ high: number;
7581
+ medium: number;
7582
+ low: number;
7583
+ };
7584
+ };
7585
+ })[];
7472
7586
  } | {
7473
7587
  $schema: string;
7474
7588
  $id: string;
package/dist/src/index.js CHANGED
@@ -1388,6 +1388,29 @@ var execution_record_schema_default = {
1388
1388
  },
1389
1389
  default: [],
1390
1390
  description: "Optional list of typed references to relevant commits, files, PRs, or external documents.\nShould use typed prefixes for clarity and trazabilidad (see execution_protocol_appendix.md):\n- commit: Git commit SHA\n- pr: Pull Request number\n- file: File path (relative to repo root)\n- url: External URL\n- issue: GitHub Issue number\n- task: TaskRecord ID\n- exec: ExecutionRecord ID (for corrections or dependencies)\n- changelog: ChangelogRecord ID\n"
1391
+ },
1392
+ metadata: {
1393
+ type: "object",
1394
+ additionalProperties: true,
1395
+ description: "Optional structured data for machine consumption.\nUse this field for data that needs to be programmatically processed (e.g., audit findings,\nperformance metrics, scan results). This complements result (human-readable WHAT) and\nnotes (narrative HOW/WHY) by providing structured, queryable data.\nCommon use cases: audit findings arrays, performance metrics, tool outputs, scan summaries.\n",
1396
+ examples: [
1397
+ {
1398
+ findings: [
1399
+ {
1400
+ type: "PII",
1401
+ file: "src/user.ts",
1402
+ line: 42
1403
+ }
1404
+ ],
1405
+ scannedFiles: 245
1406
+ },
1407
+ {
1408
+ metrics: {
1409
+ duration_ms: 1250,
1410
+ memory_mb: 512
1411
+ }
1412
+ }
1413
+ ]
1391
1414
  }
1392
1415
  },
1393
1416
  examples: [
@@ -1460,6 +1483,52 @@ var execution_record_schema_default = {
1460
1483
  references: [
1461
1484
  "exec:1752275500-exec-refactor-queries"
1462
1485
  ]
1486
+ },
1487
+ {
1488
+ id: "1752276000-exec-gdpr-audit-scan",
1489
+ taskId: "1752274500-task-gdpr-compliance",
1490
+ type: "analysis",
1491
+ title: "GDPR Audit Scan - 2025-01-15",
1492
+ result: "Escaneados 245 archivos. Encontrados 10 findings (3 critical, 4 high, 3 medium). Ver metadata para detalles estructurados.",
1493
+ notes: "Scan ejecutado con RegexDetector + HeuristicDetector. LLM calls: 0 (tier free).",
1494
+ references: [
1495
+ "file:src/config/db.ts",
1496
+ "file:src/auth/keys.ts"
1497
+ ],
1498
+ metadata: {
1499
+ scannedFiles: 245,
1500
+ scannedLines: 18420,
1501
+ duration_ms: 1250,
1502
+ findings: [
1503
+ {
1504
+ id: "SEC-001",
1505
+ severity: "critical",
1506
+ file: "src/config/db.ts",
1507
+ line: 5,
1508
+ type: "api_key"
1509
+ },
1510
+ {
1511
+ id: "SEC-003",
1512
+ severity: "critical",
1513
+ file: "src/auth/keys.ts",
1514
+ line: 2,
1515
+ type: "private_key"
1516
+ },
1517
+ {
1518
+ id: "PII-003",
1519
+ severity: "critical",
1520
+ file: "src/payments/stripe.ts",
1521
+ line: 8,
1522
+ type: "credit_card"
1523
+ }
1524
+ ],
1525
+ summary: {
1526
+ critical: 3,
1527
+ high: 4,
1528
+ medium: 3,
1529
+ low: 0
1530
+ }
1531
+ }
1463
1532
  }
1464
1533
  ]
1465
1534
  };
@@ -4320,7 +4389,7 @@ function createExecutionRecord(payload) {
4320
4389
  title: payload.title,
4321
4390
  notes: payload.notes,
4322
4391
  references: payload.references,
4323
- ...payload
4392
+ metadata: payload.metadata
4324
4393
  };
4325
4394
  const validation = validateExecutionRecordDetailed(execution);
4326
4395
  if (!validation.isValid) {