MCPcopy Create free account
hub / github.com/diillson/chatcli / touchFieldMeta

Method touchFieldMeta

cli/workspace/memory/profile.go:188–217  ·  view source on GitHub ↗

touchFieldMeta maintains provenance/freshness/sensitivity for one applied update; callers must hold the write lock. Returns whether meta changed.

(res updateResult, rawKey, source string)

Source from the content-addressed store, hash-verified

186// touchFieldMeta maintains provenance/freshness/sensitivity for one applied
187// update; callers must hold the write lock. Returns whether meta changed.
188func (ps *UserProfileStore) touchFieldMeta(res updateResult, rawKey, source string) bool {
189 if res.field == "" {
190 return false
191 }
192 if ps.profile.FieldMeta == nil {
193 ps.profile.FieldMeta = make(map[string]FieldMeta)
194 }
195 m := ps.profile.FieldMeta[res.field]
196 dirty := false
197 now := time.Now()
198 switch {
199 case res.changed:
200 m.Source, m.UpdatedAt, m.ConfirmedAt = source, now, now
201 dirty = true
202 case res.affirmable && source == FieldSourceUser:
203 // The user restating the current value is a confirmation — and it
204 // upgrades trust when the value had only been inferred by extraction.
205 m.ConfirmedAt = now
206 m.Source = source
207 dirty = true
208 }
209 if !m.Sensitive && isSensitiveField(res.field, rawKey) {
210 m.Sensitive = true
211 dirty = true
212 }
213 if dirty {
214 ps.profile.FieldMeta[res.field] = m
215 }
216 return dirty
217}
218
219// setSensitive flips the privacy flag on the named fields (comma-separated;
220// preference keys may be given bare or as "pref:<key>").

Callers 1

UpdateWithSourceMethod · 0.95

Calls 1

isSensitiveFieldFunction · 0.85

Tested by

no test coverage detected