Skip to content

feat: dict/lookup/default funcs + --out .db fix + trivy-ghsa schema#136

Merged
jamestexas merged 2 commits intomainfrom
feat/dict-lookup-trivy-schema
Mar 26, 2026
Merged

feat: dict/lookup/default funcs + --out .db fix + trivy-ghsa schema#136
jamestexas merged 2 commits intomainfrom
feat/dict-lookup-trivy-schema

Conversation

@jamestexas
Copy link
Copy Markdown
Contributor

Summary

  • 3 template functions: dict, lookup, default — enables JSON reshaping in content templates
  • Bug fix: --out was ignored on .db source path, causing NFS mount hang (rosary-3c969d)
  • Trivy schema: examples/trivy-ghsa-schema.json — projects venturi GitHub Advisory data into trivy-db BoltDB layout
  • Engine fix: processRecord now passes record values as _parent context so .db streaming path children can access parent fields

Test plan

  • 12 template func tests (dict, lookup, default, composition)
  • TestOutFlag_DBSource — regression test for .db + --out
  • End-to-end validated: venturi GitHub advisory → ZIP with correct bucket paths (Npm::ghsa/curl/GHSA-test/advisory.json)
  • task lint — 0 issues
  • task test — full suite green

Beads: mache-1094a2, rosary-3c969d

🤖 Generated with Claude Code

…trivy-ghsa schema

Template funcs (12 tests):
- dict: construct maps {{dict "key" val | json}}
- lookup: enum mapping {{lookup .Severity "Critical" 4 "High" 3 0}}
- default: nil/empty fallback {{default .name "unknown"}}

Bug fix (regression test):
- --out was ignored on .db source path, causing hang on NFS mount
- Added --out escape to .db branch: ingest via SQLiteWriter, materialize, exit
- TestOutFlag_DBSource verifies .db + --out --format zip works

Schema:
- examples/trivy-ghsa-schema.json: projects venturi GitHub Advisory data
  into trivy-db BoltDB bucket layout (Npm::ghsa/pkg/CVE → Advisory JSON)
- Exercises _parent context, lookup, dict, replace template funcs

Engine:
- processRecord now passes record values as _parent context to collectNodes
  so .db streaming path children can access parent record fields

[mache-1094a2] [rosary-3c969d]
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new template helpers and improves .db ingestion/export behavior to support richer schema-driven JSON reshaping and Trivy DB projection use-cases.

Changes:

  • Added 3 template functions: dict, lookup, default (+ tests and composition coverage).
  • Fixed .db + --out flow to materialize outputs instead of entering the mount path.
  • Added an example schema (examples/trivy-ghsa-schema.json) projecting GHSA advisories into a Trivy BoltDB-like layout and updated .db streaming _parent propagation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/ingest/template_funcs_test.go Adds unit tests covering new dict/lookup/default functions and composition.
internal/ingest/engine.go Threads _parent through .db streaming path and registers new template functions.
examples/trivy-ghsa-schema.json Example topology schema to map venturi GHSA records into Trivy DB-style buckets/files.
cmd/out_db_test.go Regression test ensuring .db sources honor --out without hanging.
cmd/mount.go Implements .db + --out materialization short-circuit in the mount command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/ingest/engine.go Outdated
Comment thread cmd/mount.go Outdated
Comment thread cmd/mount.go
Comment thread examples/trivy-ghsa-schema.json Outdated
Comment thread internal/ingest/engine.go Outdated
… for --out, add materializeVirtuals, use first for CVE

- dict: returns error on odd arg count instead of silent truncation
- default: comment matches behavior (nil + empty string, not all zero values)
- .db --out: check outPath BEFORE OpenSQLiteGraph/EagerScan (avoids wasted scan)
- .db --out: call materializeVirtuals for consistent output (_schema.json, callers)
- .db --out: defer cleanup of temp index DB
- Schema: use first instead of index for CVE array (handles empty/nil safely)

[mache-1094a2]
@jamestexas jamestexas merged commit cc5a181 into main Mar 26, 2026
14 checks passed
@jamestexas jamestexas deleted the feat/dict-lookup-trivy-schema branch March 26, 2026 00:49
@jamestexas jamestexas restored the feat/dict-lookup-trivy-schema branch March 26, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants