Why: Project retrieval hits, tool results, and saved visible analysis must be individually traceable and fully analyzed before later project actions consume them. Evidence: RED tests first showed missing run-source capture, tool-result capture, and run-wide preflight; go test -p 1 ./... and go build ./... passed; isolated PostgreSQL source, migration, audit, and context tests passed. Impact: Persist actual run-bound sources with current-status checks and exact manifests behind the disabled X3 assembly gate; no live product path, migration, deployment, or release is enabled. Refs: TT-N03, TT-R01; approved X3 stage-five plan r1
29 lines
916 B
Go
29 lines
916 B
Go
package store
|
|
|
|
import (
|
|
"database/sql"
|
|
"errors"
|
|
|
|
core "agent-system-core"
|
|
)
|
|
|
|
// ProjectWorkKnowledgeSource returns a stored knowledge source to the trusted
|
|
// host verifier. This is not a client read API: callers must independently
|
|
// enforce current owner, project, and resource publication permissions before
|
|
// disclosing its body to a project observer or model.
|
|
func (s *Store) ProjectWorkKnowledgeSource(id string) (core.KnowledgeDoc, error) {
|
|
var doc core.KnowledgeDoc
|
|
var owner, created string
|
|
err := s.db.QueryRow(s.q(`SELECT id,owner,project_id,source,title,ref,chunk,created_at FROM knowledge WHERE id=?`), id).
|
|
Scan(&doc.ID, &owner, &doc.ProjectID, &doc.Source, &doc.Title, &doc.Ref, &doc.Chunk, &created)
|
|
if errors.Is(err, sql.ErrNoRows) {
|
|
return doc, ErrNotFound
|
|
}
|
|
if err != nil {
|
|
return doc, err
|
|
}
|
|
doc.Owner = core.ID(owner)
|
|
doc.CreatedAt, err = parseTime(created)
|
|
return doc, err
|
|
}
|