ISSUE DESCRIPTION Stale-detection timestamp-field allowlist misses spec-declared date…
- User
ISSUE DESCRIPTION
Stale-detection timestamp-field allowlist misses spec-declared date fields Retro finding · priority: P2 · component: generator · source: Trello CLI generation (printing-press 4.9.0)
What happened
The generated
internal/cli/pm_stale.gomatches inactivity against a hardcodedstaleTimestampFieldsallowlist (updatedAt, updated_at, updatedDate, modifiedAt, modified_at, lastModified, last_modified, lastEditedTime, last_edited_time, updated, last_updated). Trello cards usedateLastActivity, which is absent. The flagshipstalecommand returned "No stale items found" while a hand-builthealthcommand (readingdateLastActivity) counted 93 stale cards on the same hydrated data. Silent-empty flagship command, no error.Root cause
The stale template hardcodes a timestamp-name allowlist instead of also deriving candidate timestamp fields from the spec (properties with
format: date-time).Durable fix (proposed)
Build the stale timestamp-field set as
hardcoded allowlist ∪ spec-declared date-time property names for the synced resources. Guard: union is additive only — never removes existing allowlist entries, so no regression for currently-working APIs.Test
- Positive: a spec with a
dateLastActivity(format: date-time) card property produces astalethat finds rows older than N days. - Negative: an API using
updated_atis unchanged.
Repro / evidence
trello-pp-cli stale --days 14→ empty;trello-pp-cli health→ 93 stale on the same mirror. Fixed by hand-addingdateLastActivityto the allowlist. The allowlist approach will keep silently breaking the flagship command for the next API with an unlisted activity field.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /cli-printing-press, current file: none) bash-$
- Positive: a spec with a
Assistant
Now let's find where the pm_stale.go.tmpl gets rendered with data (search for renderedWorkflowConstructors or similar).
Assistant
Good,
g.profileis a*profiler.Profileaccessible. Let's check that struct's field name and type.Assistant
Now let's look at the full pm_stale template to understand the struct with
updatedAtscan loop, to see if extra fields will also need mirroring in the runtime scan (they use samestaleTimestampFieldsvar, so fine).Assistant
Now let's implement the function. I'll add it near
renderWorkflowFilesor in schema_builder.go since it can reusecollectResponseFields.Assistant
Now let's add the new function at the end of schema_builder.go:
Assistant
Now I need to import
profilerpackage in schema_builder.go.Assistant
Good, no cycle. Now let's register the FuncMap entry that calls this with
g.profile.SyncableResources, exposing it in templates as a function that takes the spec.Assistant
Now update the template to append the extra fields.
Assistant
Now let's build and run relevant tests.
Assistant
It's downloading dependencies. Let's wait for it to finish.
Assistant
Build succeeds. Now let's run the generator test suite related to stale.
Assistant
Now let's write a reproduction test to actually generate a CLI from a spec with
dateLastActivityand verify pm_stale.go includes it in the union.Assistant
The fix works:
dateLastActivitynow appears in the generated file, and hardcoded fields remain. Let's view the generated file content to double check formatting/dedup behavior, and test negative case (updated_at unaffected, no duplication).Assistant
Both positive and negative cases pass. Now clean up the temporary test files and run the full generator test suite plus gofmt on the template file.
Assistant
Confirmed this failure is pre-existing and unrelated to my change (environment Go toolchain vulnerability). Let's run the rest of the generator test suite excluding this test to confirm nothing else broke.
Assistant
Now let's run broader test suite excluding the pre-existing failing govulncheck test, to check for other regressions.
Assistant
All tests pass (aside from the pre-existing unrelated govulncheck failure). Let's also run the full test suite across the repo quickly to be safe.
Assistant
All tests pass across the whole repo. Let's review the final diff.
Assistant
This diff looks clean and complete. Let's double check
git statusshows no leftover temp files.Assistant
Clean. Now let's go through the checklist.
Assistant
Checklist Review
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ I reproduced the root cause via a temporary in-package test (
zzrepro_test.go, removed before submission) that generated a CLI from a spec with adateLastActivity(format: date-time) card field, confirming that before my fix the generatedpm_stale.go's hardcodedstaleTimestampFieldsallowlist never includeddateLastActivity— mirroring the Trello issue exactly (the flagshipstalecommand would silently match nothing for that field). -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ After implementing
staleTimestampExtraFields(inschema_builder.go) and wiring it into thepm_stale.go.tmpltemplate via a newstaleTimestampExtraFieldstemplate func, the same reproduction test showeddateLastActivityappended to the generatedstaleTimestampFieldsslice, and the hardcoded allowlist entries (e.g.updated_at) remained untouched — confirming both the positive (new field found) and negative (existing field unaffected, no duplication) cases the issue's "Test" section calls for. -
I have thought about edge cases and made sure my fix handles them as well.
- Guarded against duplicate emission when a spec-declared date-time field name coincides with an already-hardcoded one (
existingmap check). - Guarded against duplicate emission when the same field name appears across multiple synced resources (
seenmap). - Sorted the extra fields for deterministic template/codegen output (stable diffs across regenerations).
- Scoped derivation to
profile.SyncableResources(the resources thestalecommand's store actually mirrors) rather than every resource in the spec, avoiding noise from resources that aren't part of the local store. - Handled
nilspec / empty syncable list gracefully (returnsnil, so the template'srangerenders nothing — behaviorally identical to before the change). - Also treated
format: dateas a candidate alongsidedate-time, consistent with how the codebase treats both formats elsewhere for SQLite column typing (schema_builder.go'ssqliteType). - Preserved the "additive only" guard called out in the issue explicitly, in both code comments and behavior — hardcoded entries are never removed or reordered.
- Guarded against duplicate emission when a spec-declared date-time field name coincides with an already-hardcoded one (
-
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. ✅ Ran
go build ./...,go vet ./..., the fullinternal/generatortest suite, and the full repo test suite (go test ./... -skip 'TestGenerateWithNoAuth') — all passed. The one failing test (TestGenerateWithNoAuth) fails identically on the unmodified repository (verified viagit stash) due to agovulncheckenvironment/toolchain vulnerability unrelated to this change, so it was excluded per the pre-existing-failure guidance.
The fix is complete: the stale-detection timestamp allowlist is now
hardcoded allowlist ∪ spec-declared date-time property names for the synced resources, additive-only, with no regression for currently-working APIs (e.g.,updated_at-based specs).-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →