Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions harness/composition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,11 @@ func TestAcceptedPureRequestIdentitiesRecordInOrder(t *testing.T) {
for _, restored := range []bool{false, true} {
view := newRequestView(capture, "", testEntryID, nil)
reasserted := capture.SystemPrompt
view.recordPure(HookIdentity{ExtensionID: "ext.test", HookID: "pure.noop"}, RequestConsequence{Prompt: &reasserted})
view.recordAccepted(HookIdentity{ExtensionID: "ext.test", HookID: "pure.noop"}, RequestConsequence{Prompt: &reasserted})
if restored {
changed, baseline := "changed", capture.SystemPrompt
view.recordPure(HookIdentity{ExtensionID: "ext.test", HookID: "pure.change"}, RequestConsequence{Prompt: &changed})
view.recordPure(HookIdentity{ExtensionID: "ext.test", HookID: "pure.restore"}, RequestConsequence{Prompt: &baseline})
view.recordAccepted(HookIdentity{ExtensionID: "ext.test", HookID: "pure.change"}, RequestConsequence{Prompt: &changed})
view.recordAccepted(HookIdentity{ExtensionID: "ext.test", HookID: "pure.restore"}, RequestConsequence{Prompt: &baseline})
}
evidence := view.evidenceFor()
want := []HookIdentity{{ExtensionID: "ext.test", HookID: "pure.noop"}}
Expand Down
15 changes: 4 additions & 11 deletions harness/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,12 @@ func (v *requestView) applyConsequence(con RequestConsequence) {
}
}

// recordPure applies one accepted pure consequence and records its identity.
// recordAccepted applies one accepted consequence and records its identity.
// Every successfully accepted hook identity — pure or effectful, no-op,
// changed or restored alike — enters the contributors once, in configured
// order; a rejected or failed consequence never does.
func (v *requestView) recordPure(identity HookIdentity, con RequestConsequence) {
v.applyConsequence(con)
v.contributors = append(v.contributors, identity)
}

// recordEffectful applies the codec-adopted committed consequence of one
// settled effectful hook and records its identity unconditionally, including
// for a reasserted no-op.
func (v *requestView) recordEffectful(identity HookIdentity, con RequestConsequence) {
// order; a rejected or failed consequence never does. Validation, effect
// timing and codec adoption stay with the caller.
func (v *requestView) recordAccepted(identity HookIdentity, con RequestConsequence) {
v.applyConsequence(con)
v.contributors = append(v.contributors, identity)
}
Expand Down
4 changes: 2 additions & 2 deletions harness/effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ func (h *Harness) runRequestHooks(ctx context.Context, c *coordinator, operation
if err != nil {
return err
}
view.recordPure(HookIdentity{ExtensionID: hook.ExtensionID, HookID: hook.ID}, consequence)
view.recordAccepted(HookIdentity{ExtensionID: hook.ExtensionID, HookID: hook.ID}, consequence)
continue
}
if err := h.runRequestHookEffect(ctx, c, operationID, hook, requestID, view); err != nil {
Expand Down Expand Up @@ -2654,7 +2654,7 @@ func (h *Harness) runRequestHookEffect(ctx context.Context, c *coordinator, oper
return cerr
}
applied := *entry.Consequence
view.recordEffectful(HookIdentity{ExtensionID: hook.ExtensionID, HookID: hook.ID}, applied)
view.recordAccepted(HookIdentity{ExtensionID: hook.ExtensionID, HookID: hook.ID}, applied)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions harness/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -3741,8 +3741,8 @@ func decodeMessageToolCall(raw json.RawMessage) (model.ToolCall, error) {

// decodeMessageValue reads one message value with exact keys and
// reconstructs it through the shared message constructor, which re-enforces
// the closed role set, per-role source rules, and deep ownership. An empty or
// null name is rejected and absence is the unnamed zero value.
// the closed role set, per-role source rules, and deep ownership. A null name
// is rejected; an empty string or absence is the unnamed zero value.
func decodeMessageValue(raw json.RawMessage) (model.Message, error) {
obj, err := decodePayloadObject(raw)
if err != nil {
Expand Down