feat(ai-sdk): searchControls — recall control sources on implementation questions (#39)
CI / detect-changes (push) Successful in 5s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Successful in 6s
CI / validate-canonical-controls (push) Successful in 3s
CI / loc-budget (push) Successful in 18s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Has been skipped
CI / test-go (push) Successful in 58s
CI / iace-gt-coverage (push) Successful in 15s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
CI / detect-changes (push) Successful in 5s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Successful in 6s
CI / validate-canonical-controls (push) Successful in 3s
CI / loc-budget (push) Successful in 18s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Has been skipped
CI / test-go (push) Successful in 58s
CI / iace-gt-coverage (push) Successful in 15s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
This commit was merged in pull request #39.
This commit is contained in:
@@ -204,6 +204,34 @@ func (c *LegalRAGClient) searchBinding(ctx context.Context, collection string, e
|
||||
return c.doPointsSearch(ctx, collection, searchReq)
|
||||
}
|
||||
|
||||
// controlPoolDepth is how deep the dense control pull reaches. Measured: for an EU-cyber
|
||||
// control query the relevant control sources sit at dense rank ~8-9 (NIST, CRA Annex), far
|
||||
// below the client's small top-K — so a fixed dense depth of 60 reliably surfaces them.
|
||||
const controlPoolDepth = 60
|
||||
|
||||
// searchControls fetches a DEEP dense pool and keeps only the control-pool roles, so control
|
||||
// sources that the small top-K (hybrid) search misses become candidates on an implementation
|
||||
// question. Role is derived in code (no source_role tag needed). AUGMENTS the pool — the
|
||||
// caller gates it on control-intent.
|
||||
func (c *LegalRAGClient) searchControls(ctx context.Context, collection string, embedding []float64) ([]qdrantSearchHit, error) {
|
||||
searchReq := qdrantSearchRequest{
|
||||
Vector: embedding,
|
||||
Limit: controlPoolDepth,
|
||||
WithPayload: true,
|
||||
}
|
||||
hits, err := c.doPointsSearch(ctx, collection, searchReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
kept := make([]qdrantSearchHit, 0, len(hits))
|
||||
for _, h := range hits {
|
||||
if isControlPoolRole(controlRoleOf(h.Payload)) {
|
||||
kept = append(kept, h)
|
||||
}
|
||||
}
|
||||
return kept, nil
|
||||
}
|
||||
|
||||
// doPointsSearch issues a POST /points/search and decodes the hits.
|
||||
func (c *LegalRAGClient) doPointsSearch(ctx context.Context, collection string, searchReq qdrantSearchRequest) ([]qdrantSearchHit, error) {
|
||||
jsonBody, err := json.Marshal(searchReq)
|
||||
|
||||
Reference in New Issue
Block a user