Commit df73c79
fix(cli): hindsight memory retain --timestamp + correct fact-type values (#1881)
Two unrelated CLI bugs surfaced during sandbox testing on 2026-05-31.
1) `hindsight memory retain --timestamp <ISO 8601>` never worked.
`MemoryItem.timestamp` is generated from the OpenAPI schema
`anyOf: [{type: string, format: date-time}, {type: string}]`. Progenitor
emits that as a struct with two `#[serde(flatten)]` Option subtypes —
which serde refuses to serialize for primitives:
"can only flatten structs and maps (got a string)"
So even constructing the value manually fails at serialize time, before
the request hits the wire. The CLI's `serde_json::from_value::<…>(String)`
round-trip also fails (struct deserializer expects an object).
Fixed at the codegen boundary by adding a pre-codegen spec-massage step
`collapse_string_anyof_unions` in hindsight-clients/rust/build.rs that
collapses any `anyOf` whose members are all `{type: string}` into a
single `{type: string}`. The `format: date-time` distinction is lossless
on the wire — both serialize to the same string — so this is safe.
Result: `MemoryItem.timestamp: Option<String>`, no broken type generated.
The CLI no longer needs to round-trip through a wrapper type; the user
string is passed through directly.
2) `hindsight memory clear --fact-type` rejected the valid value
`observation` and accepted stale values `agent` / `opinion` that the
server silently treats as no-ops.
Help text on `bank graph`, `memory list`, `memory recall`, and
`memory clear` referred to a non-existent fact type `opinion`. The
canonical fact types per the API are `world | experience | observation`
(see hindsight_api.api.http.MemoryItem and the `Literal[…]` arm on
fact_types in recall/reflect requests).
Fixed: `opinion` → `observation` everywhere in CLI help / clap defaults,
and `agent`/`opinion` → `experience`/`observation` in the clear
command's value_parser allow-list.
Regression test:
hindsight-cli/tests/integration_test.rs::
test_memory_item_timestamp_serializes_as_plain_string
Verified:
- cargo build → clean
- cargo test --bin hindsight → 55/55 pass
- cargo test --test integration_test test_memory_item_timestamp_… → pass
- cargo clippy → no new warnings (171 pre-existing uninlined_format_args)
- hindsight memory clear --help → [possible values: world, experience, observation]
- hindsight memory recall --help → [default: world experience observation]
- hindsight bank graph --help → (world, experience, observation)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2a9589f commit df73c79
5 files changed
Lines changed: 90 additions & 20 deletions
File tree
- hindsight-clients/rust
- hindsight-cli
- src
- commands
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1266 | 1266 | | |
1267 | 1267 | | |
1268 | 1268 | | |
1269 | | - | |
1270 | | - | |
| 1269 | + | |
| 1270 | + | |
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 6 | + | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
| |||
454 | 452 | | |
455 | 453 | | |
456 | 454 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | 455 | | |
467 | 456 | | |
468 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
492 | | - | |
493 | | - | |
| 492 | + | |
| 493 | + | |
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
648 | | - | |
649 | | - | |
| 648 | + | |
| 649 | + | |
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
94 | 123 | | |
95 | 124 | | |
96 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
46 | 92 | | |
47 | 93 | | |
48 | 94 | | |
| |||
132 | 178 | | |
133 | 179 | | |
134 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
135 | 187 | | |
136 | 188 | | |
137 | 189 | | |
| |||
0 commit comments