feat(metrics): Implement scan metrics repository and PostgreSQL integration
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Added IScanMetricsRepository interface for scan metrics persistence and retrieval. - Implemented PostgresScanMetricsRepository for PostgreSQL database interactions, including methods for saving and retrieving scan metrics and execution phases. - Introduced methods for obtaining TTE statistics and recent scans for tenants. - Implemented deletion of old metrics for retention purposes. test(tests): Add SCA Failure Catalogue tests for FC6-FC10 - Created ScaCatalogueDeterminismTests to validate determinism properties of SCA Failure Catalogue fixtures. - Developed ScaFailureCatalogueTests to ensure correct handling of specific failure modes in the scanner. - Included tests for manifest validation, file existence, and expected findings across multiple failure cases. feat(telemetry): Integrate scan completion metrics into the pipeline - Introduced IScanCompletionMetricsIntegration interface and ScanCompletionMetricsIntegration class to record metrics upon scan completion. - Implemented proof coverage and TTE metrics recording with logging for scan completion summaries.
This commit is contained in:
@@ -334,6 +334,50 @@ cmd.Parameters.AddWithValue("config", json);
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
|
||||
```
|
||||
|
||||
### 5.3.1 Generated Columns for JSONB Hot Keys
|
||||
|
||||
**RULE:** Frequently-queried JSONB fields (>10% of queries) SHOULD be extracted as generated columns.
|
||||
|
||||
**When to use generated columns:**
|
||||
- Field is used in WHERE clauses frequently
|
||||
- Field is used in JOIN conditions
|
||||
- Field is used in GROUP BY or ORDER BY
|
||||
- Query planner needs cardinality statistics
|
||||
|
||||
```sql
|
||||
-- ✓ CORRECT: Generated column for hot JSONB field
|
||||
ALTER TABLE scheduler.runs
|
||||
ADD COLUMN finding_count INT GENERATED ALWAYS AS ((stats->>'findingCount')::int) STORED;
|
||||
|
||||
CREATE INDEX idx_runs_finding_count ON scheduler.runs(tenant_id, finding_count);
|
||||
```
|
||||
|
||||
**RULE:** Generated column names MUST follow snake_case convention matching the JSON path.
|
||||
|
||||
```sql
|
||||
-- ✓ CORRECT naming
|
||||
doc->>'bomFormat' → bom_format
|
||||
stats->>'findingCount' → finding_count
|
||||
raw->>'schemaVersion' → schema_version
|
||||
|
||||
-- ✗ INCORRECT naming
|
||||
doc->>'bomFormat' → bomFormat, format, bf
|
||||
```
|
||||
|
||||
**RULE:** Generated columns MUST be added with concurrent index creation in production.
|
||||
|
||||
```sql
|
||||
-- ✓ CORRECT: Non-blocking migration
|
||||
ALTER TABLE scheduler.runs ADD COLUMN finding_count INT GENERATED ALWAYS AS (...) STORED;
|
||||
CREATE INDEX CONCURRENTLY idx_runs_finding_count ON scheduler.runs(finding_count);
|
||||
ANALYZE scheduler.runs;
|
||||
|
||||
-- ✗ INCORRECT: Blocking migration
|
||||
CREATE INDEX idx_runs_finding_count ON scheduler.runs(finding_count); -- Blocks table
|
||||
```
|
||||
|
||||
**Reference:** See `SPECIFICATION.md` Section 6.4 for detailed guidelines.
|
||||
|
||||
### 5.4 Null Handling
|
||||
|
||||
**RULE:** Nullable values MUST use `DBNull.Value` when null.
|
||||
|
||||
Reference in New Issue
Block a user