Add config parser - #9
Conversation
| "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"}, |
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
To be honest, we are still brainstorming all the possible ways we can get around this particular limitation.
|
@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") { |
There was a problem hiding this comment.
Do we still need this if the Dockerfile parser is gone?
| if !strings.HasPrefix(content, "#") && !strings.HasPrefix(content, "FROM") { | |
| if !strings.HasPrefix(content, "#") { |
jpower432
left a comment
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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[]"}, |
There was a problem hiding this comment.
| {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"}, |
There was a problem hiding this comment.
| {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"}, |
There was a problem hiding this comment.
| {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"}, |
There was a problem hiding this comment.
This only applies to the Policy Schema
| mcp.AddTool(server, MetadataGetSchemaDocs, a.getSchemaDocs) | ||
|
|
||
| // Evidence pipeline tool - parses governance and config documents into schema candidates | ||
| mcp.AddTool(server, MetadataParseGovernanceDocument, ParseGovernanceDocument) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
@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?
references #2