feat: add audit trail for detach operations (gt-h6eq.8)
Add DetachMoleculeWithAudit() function that logs detach operations to .beads/audit.log in JSONL format. Each entry captures: - timestamp - operation type (detach, burn, squash) - pinned_bead_id - detached_molecule - detached_by (agent identity) - reason (optional) - previous_state Updated callers: - runMoleculeDetach: logs "detach" operation - runMoleculeBurn: logs "burn" operation with reason - runMoleculeSquash: logs "squash" operation with digest ID 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -201,8 +201,12 @@ func runMoleculeBurn(cmd *cobra.Command, args []string) error {
|
||||
|
||||
moleculeID := attachment.AttachedMolecule
|
||||
|
||||
// Detach the molecule (this "burns" it by removing the attachment)
|
||||
_, err = b.DetachMolecule(handoff.ID)
|
||||
// Detach the molecule with audit logging (this "burns" it by removing the attachment)
|
||||
_, err = b.DetachMoleculeWithAudit(handoff.ID, beads.DetachOptions{
|
||||
Operation: "burn",
|
||||
Agent: target,
|
||||
Reason: "molecule burned by agent",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("detaching molecule: %w", err)
|
||||
}
|
||||
@@ -334,8 +338,12 @@ squashed_at: %s
|
||||
style.Dim.Render("Warning:"), err)
|
||||
}
|
||||
|
||||
// Detach the molecule from the handoff bead
|
||||
_, err = b.DetachMolecule(handoff.ID)
|
||||
// Detach the molecule from the handoff bead with audit logging
|
||||
_, err = b.DetachMoleculeWithAudit(handoff.ID, beads.DetachOptions{
|
||||
Operation: "squash",
|
||||
Agent: target,
|
||||
Reason: fmt.Sprintf("molecule squashed to digest %s", digestIssue.ID),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("detaching molecule: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user