Skip to content

Add config parser - #9

Open
Satarupa22-SD wants to merge 4 commits into
gemaraproj:mainfrom
Satarupa22-SD:add-evidenceparser
Open

Add config parser#9
Satarupa22-SD wants to merge 4 commits into
gemaraproj:mainfrom
Satarupa22-SD:add-evidenceparser

Conversation

@Satarupa22-SD

Copy link
Copy Markdown

references #2

@jpower432 jpower432 linked an issue Mar 2, 2026 that may be closed by this pull request
@jpower432
jpower432 self-requested a review March 2, 2026 22:39
Comment thread internal/tool/parse.go Outdated
"format": map[string]interface{}{
"type": "string",
"description": "Format hint for the document. One of: markdown, yaml, json, kubernetes, dockerfile. If omitted, auto-detection is used.",
"enum": []string{"markdown", "yaml", "json", "kubernetes", "dockerfile"},

@sonupreetam sonupreetam Mar 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Satarupa22-SD "dockerfile" can be removed from the supported formats enum and dropped the test case, as it is not implemented and not relevant for governance documents. And the most common governance format (PDF) isn't handled, so is it something you would like to consider? WDYT?

@Satarupa22-SD Satarupa22-SD Mar 3, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@sonupreetam Thank you for reviewing. Actually, I had implemented pdf parser initially, but it was running into some errors and I had to remove it ultimately. I am still working on the pdf parser, it will be updated by tomorrow

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have removed dockerfile from the supported formats, thank you for pointing it out

if strings.Contains(lower, kw) {

mappingConfidence := 0.75
combined := mappingConfidence * chunk.Confidence

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

High-confidence (≥0.7) are suitable for automated artifact generation, but no parser can produce it with the math (eg: 0.90 × 0.75 = 0.675). Either threshold should be lowered or the confidence values should be tuned.


// schemaFieldRules defines the keyword-to-field mapping table used by the SchemaMapper.
// Rules are evaluated in order; the first match wins.
var schemaFieldRules = []fieldRule{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Satarupa22-SD For real governance documents like PCI DSS, many sections contain language spanning multiple schema fields. Do you think returning multiple candidates per chunk could be good, or at least document this as a known limitation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

To be honest, we are still brainstorming all the possible ways we can get around this particular limitation.

@jpower432

Copy link
Copy Markdown
Contributor

@Satarupa22-SD Looks like the DCO check is failed. Might just need a quick rebase on the existing commits to add the sign off. Solution is here - https://github.com/gemaraproj/gemara-mcp/pull/9/checks?check_run_id=65604954779

// Plain YAML: key: value at the start
if len(content) > 0 && strings.Contains(strings.SplitN(content, "\n", 2)[0], ":") {
// Avoid stealing from Dockerfile or Markdown parsers
if !strings.HasPrefix(content, "#") && !strings.HasPrefix(content, "FROM") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we still need this if the Dockerfile parser is gone?

Suggested change
if !strings.HasPrefix(content, "#") && !strings.HasPrefix(content, "FROM") {
if !strings.HasPrefix(content, "#") {

@jpower432 jpower432 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just leaving an initial review, but I plan to testing this locally.

I like the code structure and the way this is laid out, but it may be good to take a second look at the SchemaMapper.


// schemaFieldRules defines the keyword-to-field mapping table used by the SchemaMapper.
// Rules are evaluated in order; the first match wins.
var schemaFieldRules = []fieldRule{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some of these target fields don't exist in the ControlCatalog schema. Is that what we are always targeting in this initial implementation?

{keywords: []string{"control statement", "requirement", "must ", "shall ", "required to"}, targetField: "controls[].statement"},
{keywords: []string{"assessment", "verify", "verification", "audit", "check"}, targetField: "controls[].assessment"},
{keywords: []string{"implementation", "procedure", "how to", "steps to"}, targetField: "controls[].implementation"},
{keywords: []string{"parameter", "setting", "configuration", "config value"}, targetField: "controls[].parameters[]"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{keywords: []string{"parameter", "setting", "configuration", "config value"}, targetField: "controls[].parameters[]"},

{keywords: []string{"version:", "revision:"}, targetField: "metadata.version"},
{keywords: []string{"objective", "goal", "purpose", "intent"}, targetField: "controls[].objective"},
{keywords: []string{"control statement", "requirement", "must ", "shall ", "required to"}, targetField: "controls[].statement"},
{keywords: []string{"assessment", "verify", "verification", "audit", "check"}, targetField: "controls[].assessment"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{keywords: []string{"assessment", "verify", "verification", "audit", "check"}, targetField: "controls[].assessment"},
{keywords: []string{"assessment", "verify", "verification", "audit", "check"}, targetField: "controls[].assessment-requirements"},

{keywords: []string{"title:", "name:", "policy name", "control name"}, targetField: "metadata.title"},
{keywords: []string{"version:", "revision:"}, targetField: "metadata.version"},
{keywords: []string{"objective", "goal", "purpose", "intent"}, targetField: "controls[].objective"},
{keywords: []string{"control statement", "requirement", "must ", "shall ", "required to"}, targetField: "controls[].statement"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{keywords: []string{"control statement", "requirement", "must ", "shall ", "required to"}, targetField: "controls[].statement"},

{keywords: []string{"implementation", "procedure", "how to", "steps to"}, targetField: "controls[].implementation"},
{keywords: []string{"parameter", "setting", "configuration", "config value"}, targetField: "controls[].parameters[]"},
{keywords: []string{"reference", "see also", "related", "maps to"}, targetField: "metadata.references[]"},
{keywords: []string{"scope", "applies to", "applicability"}, targetField: "metadata.scope"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This only applies to the Policy Schema

Comment thread internal/tool/mode.go
mcp.AddTool(server, MetadataGetSchemaDocs, a.getSchemaDocs)

// Evidence pipeline tool - parses governance and config documents into schema candidates
mcp.AddTool(server, MetadataParseGovernanceDocument, ParseGovernanceDocument)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't need to be addressed in this initial implementation, but we should add this to Artifact Mode I think because it is geared toward Gemara artifact creation and not Gemara artifact parsing, but that new mode was merged into main after this PR was submitted.

Format string
ID string
}
type EvidenceParser interface {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Satarupa22-SD What do you think of advertising here what schemas are supported by which type or maybe this PR can just stick to populating Capabilities?

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.

Add a config parser to assist with the evidence pipeline

3 participants