writeupdraftuc

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package writeupdraftuc is the use case for AI-proposed, human-gated finding write-up drafts ("human-gated authoritative drafts"). It orchestrates the writeupdraft.Draft lifecycle over a store and writes an append-only audit entry for every state change.

Tenant isolation is enforced UPSTREAM at the HTTP route (withEngTenant), so these methods take an already-tenant-proven engagement id. The agent reaches ONLY Propose (via a narrow proposer interface it declares); Edit/Accept/Reject are human actions gated by RBAC (PermReview) + separation of duties at the route – and the domain enforces SoD again (a proposer cannot sign off its own draft) as defense-in-depth. A draft never renders into a report by itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service drives the write-up-draft lifecycle.

func NewService

func NewService(store ports.WriteupDraftStore, audit ports.AuditLogger, clock ports.Clock, ids ports.IDGenerator) (*Service, error)

NewService validates its dependencies and returns the service.

func (*Service) Accept

func (s *Service) Accept(ctx context.Context, principal string, engagementID, id shared.ID) (writeupdraft.Draft, error)

Accept is the human sign-off on a proposed draft. The domain rejects a proposer signing off its own draft (separation of duties).

func (*Service) Edit

func (s *Service) Edit(ctx context.Context, principal string, engagementID, id shared.ID, description, remediation string) (writeupdraft.Draft, error)

Edit replaces a still-proposed draft's text (a human revising the AI draft before sign-off).

func (*Service) ListByEngagement

func (s *Service) ListByEngagement(ctx context.Context, engagementID shared.ID) ([]writeupdraft.Draft, error)

ListByEngagement returns the engagement's drafts (tenant already proven upstream).

func (*Service) Propose

func (s *Service) Propose(ctx context.Context, proposer string, engagementID, findingID shared.ID, description, remediation string) (writeupdraft.Draft, error)

Propose records a new AI-proposed draft (StateProposed). proposer is the agent identity. The draft is inert until a human signs off; this only persists the proposal and audits it.

func (*Service) Reject

func (s *Service) Reject(ctx context.Context, principal string, engagementID, id shared.ID) (writeupdraft.Draft, error)

Reject discards a proposed draft.

func (*Service) SetFindingWriteupApplier

func (s *Service) SetFindingWriteupApplier(a ports.FindingWriteupApplier)

SetFindingWriteupApplier wires the on-accept hook that applies an accepted draft's prose to its finding . Optional – without it, Accept just marks the draft accepted (no apply). The composition root supplies *findings.Service through the narrow ports.FindingWriteupApplier (writeupdraftuc never imports the findings use case).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL