nsmcp::QuestionService method evidence (public)

 <instance of nsmcp::QuestionService[i]> evidence context handle id

Defined in /usr/local/ns/tcl/nsmcp/question-service.tcl

Retrieve retained tool evidence for an owned conversation. Validate the evidence identifier, confirm it belongs to a retained turn and read only the bounded private evidence file.

Parameters:
context (required)
Authenticated request context carrying the principal, grants and selected server.
handle (required)
Retained job or conversation handle; ownership and expiry checks still apply.
id (required)
Private evidence identifier already referenced by an owned turn.
Returns:
A rooted JSON object containing the retained result text.

Testcases:
No testcase defined.
Source code:
ns_mutex lock ${:mutex}
try {
    set record [:owned $context $handle]
    if {![regexp {^[a-f0-9]{32}$} $id]} {
        error "Unknown evidence"
    }
    set found false
    foreach turn [dict get $record turns] {
        foreach tool [dict get $turn tools] {
            if {[dict exists $tool evidenceHandle] && [dict get $tool evidenceHandle] eq $id} {
                set found true
            }
        }
    }
    if {!$found} {
        error "Unknown evidence"
    }
    set path [file join ${:evidenceDirectory} $handle $id.json]
    if {[file type $path] ne "file" || [file size $path]>${:maxEvidenceBytes}} {
        error "Evidence unavailable"
    }
    set channel [open $path r]
    try {
        fconfigure $channel -encoding utf-8 -translation lf
        set result [read $channel]
    } finally {
        close $channel
    }
    return [list {} object [list result string $result]]
} finally {
    ns_mutex unlock ${:mutex}
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: