Avoid repeated prompt metadata lookups
This commit is contained in:
@@ -21,7 +21,7 @@ resource-oriented profile result and changed post-handoff null fallback are
|
|||||||
deliberately selected compatibility changes, not accidental regressions.
|
deliberately selected compatibility changes, not accidental regressions.
|
||||||
|
|
||||||
Review evidence below describes the pre-remediation implementation. Completion
|
Review evidence below describes the pre-remediation implementation. Completion
|
||||||
markers record the subsequent corrections.
|
markers record the subsequent corrections. Both findings are now addressed.
|
||||||
|
|
||||||
## Findings
|
## Findings
|
||||||
|
|
||||||
@@ -79,7 +79,14 @@ another implementation path, compatibility field, or new runtime test.
|
|||||||
|
|
||||||
### R2. Hoist The Prompt Presence Lookup Out Of The Input Loop [P3]
|
### R2. Hoist The Prompt Presence Lookup Out Of The Input Loop [P3]
|
||||||
|
|
||||||
**Status:** Open for consideration. **Affected stage:** 4.
|
**Status:** Complete. **Affected stage:** 4.
|
||||||
|
|
||||||
|
Completion: `InspectPrompt` fetches the selected presence slice once before
|
||||||
|
iterating over inputs. The loop now indexes that slice directly, with no new
|
||||||
|
cache or public contract. Existing inherited-presence, captured-content, generic
|
||||||
|
JSON/YAML encoding, typed-source, and isolation tests pass with Go 1.27.3 under
|
||||||
|
the race detector; `go vet ./...` also passes. No benchmark or implementation-
|
||||||
|
coupled lookup-count test was added.
|
||||||
|
|
||||||
**Location:** [Prompt resource projection](../../internal/configuration/resources.go),
|
**Location:** [Prompt resource projection](../../internal/configuration/resources.go),
|
||||||
`InspectPrompt`, lines 77–85, especially `state.promptMetadata[id][i]` at line 81.
|
`InspectPrompt`, lines 77–85, especially `state.promptMetadata[id][i]` at line 81.
|
||||||
|
|||||||
@@ -76,9 +76,10 @@ func (state *loaded) InspectPrompt(ctx context.Context, id string) (*PromptResou
|
|||||||
result := &PromptResource{ID: id, Hash: entry.hash, DefaultProfile: raw.DefaultProfile, Description: raw.Description, SessionID: raw.SessionID}
|
result := &PromptResource{ID: id, Hash: entry.hash, DefaultProfile: raw.DefaultProfile, Description: raw.Description, SessionID: raw.SessionID}
|
||||||
if raw.Inputs != nil {
|
if raw.Inputs != nil {
|
||||||
inputs := make([]PromptInputResource, len(raw.Inputs))
|
inputs := make([]PromptInputResource, len(raw.Inputs))
|
||||||
|
presence := state.promptMetadata[id]
|
||||||
for i, input := range raw.Inputs {
|
for i, input := range raw.Inputs {
|
||||||
inputs[i] = PromptInputResource{Name: input.Name, ContentType: input.ContentType, Description: input.Description}
|
inputs[i] = PromptInputResource{Name: input.Name, ContentType: input.ContentType, Description: input.Description}
|
||||||
if state.promptMetadata[id][i].required == fieldValue {
|
if presence[i].required == fieldValue {
|
||||||
required := input.Required
|
required := input.Required
|
||||||
inputs[i].Required = &required
|
inputs[i].Required = &required
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user