stemedb/sdk/go/adk/tools_supersede.go
jordan b3e8a9a058 feat: Multi-application expansion with chaos testing and community UI
Major additions:
- Community Next.js app (port 18187) for browsing claims with API docs
- stemedb-chaos crate: Fault injection, chaos testing, CRDT properties
- Latent ingestion system: Reddit/FDA ingesters with ADK-Go agents
- Disputed claims handling: Manual review workflows and validation
- Aphoria security scanner: New extractors (SQL injection, command
  injection, weak crypto, TLS version), policy-based ignores, UAT reports
- Docker infrastructure: Dockerfile, docker-compose.yml for full stack
- VulnBank demo: Intentionally vulnerable multi-language test corpus

SDK & API enhancements:
- Source registry handlers for tracking data provenance
- Metrics endpoint
- Skeptic filtering improvements

Code quality:
- Split 14 large files (>500 lines) into focused modules
- All files now under 500-line limit per project guidelines

Documentation:
- Chaos testing guide, circuit breakers, observability docs
- Phase 7 UAT documentation updates
- Martin Kleppmann technical writer agent

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:24:14 -07:00

75 lines
1.9 KiB
Go

package adk
import (
"context"
"encoding/json"
"fmt"
"github.com/orchard9/stemedb-go/steme"
)
// SupersedeTool provides error correction with cascade tracking.
//
// Used by Human Supervisor to correct bad assertions.
type SupersedeTool struct {
client EpistemeClient
}
// NewSupersedeTool creates a new Supersede tool.
func NewSupersedeTool(client EpistemeClient) *SupersedeTool {
return &SupersedeTool{client: client}
}
// Name returns the tool name.
func (t *SupersedeTool) Name() string {
return "episteme_supersede"
}
// Description returns the tool description.
func (t *SupersedeTool) Description() string {
return "Supersede a bad assertion with correction tracking. " +
"Shows cascade impact on downstream assertions. " +
"Used for incident remediation and knowledge correction."
}
// Execute performs the supersede operation.
func (t *SupersedeTool) Execute(ctx context.Context, input []byte) ([]byte, error) {
var params SupersedeInput
if err := json.Unmarshal(input, &params); err != nil {
return nil, fmt.Errorf("invalid supersede input: %w", err)
}
// Convert SupersessionType
superType := parseSupersessionType(params.Type)
// Build SupersedeParams
supersedeParams := steme.SupersedeParams{
TargetHash: params.Hash,
SupersessionType: superType,
Reason: params.Reason,
NewHash: params.NewHash,
AgentID: params.AgentID,
Signature: params.Signature,
}
// Execute supersede
result, err := t.client.Supersede(ctx, supersedeParams)
if err != nil {
return nil, fmt.Errorf("supersede failed: %w", err)
}
// Convert to SupersedeOutput format
output := SupersedeOutput{
Success: true,
TargetHash: result.TargetHash,
SupersessionType: string(result.SupersessionType),
Timestamp: result.Timestamp,
}
outputBytes, err := json.Marshal(output)
if err != nil {
return nil, fmt.Errorf("failed to marshal supersede output: %w", err)
}
return outputBytes, nil
}