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 call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Positive: a spec with a
Assistant
Let me start by exploring the repository structure to understand the codebase.
Assistant
This is a Go code generator (printing-press). The issue is about a stale template that hardcodes a timestamp-field allowlist. Let me find the relevant template file.
Assistant
Let me search in testdata and for the template.
Assistant
Now let me look at how the template is rendered in generator.go.
Assistant
Let me find where pm_stale.go is rendered and what data is passed.
Assistant
Let me explore the spec structure to understand how resources/properties and
format: date-timeare represented.Assistant
Let me look at the Resource and Endpoint types, and the Param type for properties/format.
Assistant
Now let me look at the ResponseDef and response schema properties where date-time format fields would appear.
Assistant
Let me check how date-time fields are detected/used elsewhere in the codebase.
Assistant
Let me look at schema_builder.go around the date-time handling.
Assistant
Let me look at the template functions registered.
Assistant
Assistant
Let me check the existing generator_test.go references to staleTimestampFields.
Assistant
Let me look at the dogfood test around pm_stale to understand how tests exercise generation.
Assistant
Let me look at the
minimalSpechelper used in tests.Assistant
Let me check the profiler.SyncableResources to understand which resources are synced.
Assistant
Let me check the Generate flow and when the profile is computed.
Assistant
Let me check how syncable resources handle sub-resources in the profiler.
Assistant
So sub-resources are walked with their own name as the resource name (the
walkfunction adds them to thesyncablemap keyed by the sub-resource name). Let me check the walk function to see the key.Assistant
Let me look at the
walkfunction and howresourceNameis set, and how sub-resources are keyed.Assistant
So syncable resources are keyed by
strings.ToLower(name). Let me check whereg.funcsis assigned and theNewconstructor.Assistant
Let me check for pm_stale.go in testdata/golden to understand if golden fixtures would be affected.
Assistant
Let me check for existing helper functions
sortedResourceNamesand any date-time format helper.Assistant
Let me look at the end of the func map to find a good insertion point.
Assistant
No golden fixtures contain pm_stale.go, so no golden regeneration is needed. Let me check how the OpenAPI parser sets the
date-timeformat to ensure my format check matches.Assistant
I now understand the codebase well. Let me reproduce the issue first by creating a test script that generates a CLI with a
dateLastActivitydate-time field and checks whetherstalefinds stale rows. First, let me look at thecollectResponseFieldsend and find a clean insertion point.Assistant
Now let me add the new generator functions to
schema_builder.go. I'll insert them aftersqliteType.Assistant
Now let me insert the new functions after
sqliteType(line 328).Assistant
Now let me insert these functions into the file after
sqliteType's closing brace (line 328).Assistant
The insertion looks good. Now let me register the template func in
generator.go's funcMap, nearexportableResources.Assistant
I'll add the
specStaleTimestampFieldstemplate func registration afterexportableResources.Assistant
Now let me update the template to union the spec-derived fields into the
staleTimestampFieldsvar literal.Assistant
I'll update the comment and var declaration to union the spec-derived fields.
Assistant
Now let me verify the project builds.
Assistant
Build succeeds. Now let me write a temporary reproduction test to confirm the fix works at the source level.
Assistant
Both source-level tests pass. Now let me verify the runtime behavior end-to-end by generating a CLI, seeding old data, and running the
stalecommand. Let me check the store schema and howresource_typeis stored.Assistant
The store package is generated. Let me find the store template to understand the
resourcestable schema.Assistant
The
resourcestable is generic. Let me write a runtime end-to-end test that generates the CLI, seeds old data, and runsstale. First, let me check the generated root.go forRootCmd()and the--jsonflag.Assistant
--jsonis a persistent flag. Now let me write a runtime end-to-end test.Assistant
Let me fix the unused imports in the outer test file.
Assistant
The nested backtick escaping is messy. Let me rewrite the inner test using
fmt.Sprintfand double-quoted SQL.Assistant
The runtime test passes — the generated
stalecommand finds old cards bydateLastActivity. Now let me run the existing relevant tests to ensure no regressions.Assistant
Let me check the name of the test that iterates the workflow template cases (line 12796).
Assistant
Now let me run the broader generator test suite to ensure nothing broke. Let me first remove my temporary repro tests so they don't interfere, then run the full generator package.
Assistant
The only failure is
TestGenerateWithNoAuth, which fails due to agovulncheckvulnerability in the Go standard library (crypto/tls@go1.26.4, fixed ingo1.26.5) — an environment/Go-version issue unrelated to my change. Let me confirm it's pre-existing by stashing my changes and running just that test.Assistant
Confirmed —
TestGenerateWithNoAuthfails on the original code too (pre-existinggovulncheck/Go-version issue). There's an untrackedinternal/generator/.local/dir from a test run; let me clean it up.Assistant
Let me re-run the full generator suite skipping the pre-existing govulncheck-dependent test to confirm no other regressions.
Assistant
Let me find which specific test failed.
Assistant
Two build-cache tests failed. Let me inspect them — they look environment-related (GOCACHE).
Assistant
These build-cache tests rely on
os.UserHomeDir()/HOME, which is unset in this environment. Let me confirm they fail without my changes too.Assistant
Confirmed — both build-cache tests fail on the original code due to
$HOME is not definedin this environment (pre-existing, unrelated to my change). Let me clean up leftover artifacts.Assistant
Let me verify the other packages that referenced these terms still build correctly.
Assistant
Let me check
scorecard.go:652which reads the generatedpm_stale.gocontent, to ensure my template change doesn't break a scorecard check.Assistant
The scorecard check for
"limit"inpm_stale.gois unaffected (the--limitflag remains). Let me rungo veton the generator package to be safe about the new code.Assistant
Let me verify my modified Go files are gofmt-clean.
Assistant
gofmt -llisted the files, meaning they need formatting. Let me check the diff.Assistant
Just needs a blank line after my function before the
textFieldKeywordscomment. Let me check the generator.go diff too.Assistant
The funcMap keys need realignment after adding the longer key. Let me run
gofmt -won both files.Assistant
Both files are now gofmt-clean. Let me re-verify the build and re-run the stale-related tests.
Assistant
Let me do a final review of the complete diff.
Assistant
The diff is clean and complete. Let me do a final check of the git status to ensure only my intended files are modified and no temp files remain.
Assistant
Let me refine the template comment to accurately reflect the implementation (all resources, not just synced), matching the
schema_builder.godoc.Assistant
Let me run the stale template test and build once more to confirm everything is intact.
Assistant
Everything passes. Let me do a final git status check and clean any stray artifacts before submitting.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.