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.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 statusor 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 understanding the repository structure and finding the relevant files. The issue is about a stale-detection timestamp-field allowlist that's hardcoded and misses spec-declared date fields. I need to find:
- The stale template that hardcodes the timestamp-name allowlist
- Understand how the codebase works
- Modify the code to also derive candidate timestamp fields from the spec (properties with
format: date-time)
Let me explore the repository first.
Assistant
Let me search for the stale-related files more specifically.
Assistant
Found it. Let me look at this template and also search for related references
Assistant
Let me open the stale template to see the current allowlist
Assistant
Let me read the file directly.
Assistant
Now let me find where this template is used in the generator so I understand what data is available.
Assistant
Let me look at the generator code around line 3184 to understand how the template is rendered and what data is available.
Assistant
Let me search for where the stale template is rendered with its data context
Assistant
Let me look at how workflow templates are rendered to understand the data context available
Assistant
So the template is rendered with
g.Specas the data context. Let me look at what the Spec type containsAssistant
Hmm maybe the spec is from the openapi parser. Let me search more broadly.
Assistant
Let me look at the APISpec struct
Assistant
Let me look at Resource and TypeDef structures
Assistant
Let me look at those structs.
Assistant
Let me search for Property and TypeDef structs and format-related fields
Assistant
Let me look at the Property and TypeDef structs in
Assistant
Now let me look at TypeDef struct.
Assistant
Now I have a good understanding. Let me look at how other templates iterate over types/resources to understand the template syntax
Assistant
Let me look at the types.go.tmpl template to understand how it works with TypeDef fields and
Assistant
Let me check how template functions are registered and if there's already a dedup/set function
Assistant
Let me see the FuncMap definition in generator
Assistant
Let me look at the test that pins the timestamp fields list
Assistant
Let me understand how the OpenAPI parser populates Types, especially with format information
Assistant
Let me check how the parser populates TypeField Format
Assistant
Let me find where TypeField Format is set from schema properties
Assistant
Let me look at the code around line 4756
Assistant
Now I have a thorough understanding. Let me plan the implementation:
- Add a
staleTimestampFieldstemplate function to the FuncMap ingenerator.gothat builds the union of hardcoded fields and spec-declared date-time fields - Modify the template
pm_stale.go.tmplto use this function
Let me first find the exact location in generator.go where I should add the function
- Add a
Assistant
Let me find the end of the FuncMap to know where to add the new function
Assistant
Let me find the closing of the FuncMap more precisely
Assistant
Let me find the end of the FuncMap definition
Assistant
Let me find the end of the FuncMap by looking at the structure more
Assistant
Let me look at the code around lines 361 and 370 to see which one closes the FuncMap.
Assistant
Let me look for the end of FuncMap by finding the next non-indented closing brace after line 202
Assistant
Let me find the closing of the FuncMap by looking at what line comes after it
Assistant
Let me find the end of the FuncMap using a different approach
Assistant
The FuncMap is a multi-line assignment that starts with
g.funcs = template.FuncMap{on line 202. Buttemplate.FuncMap{starts on line 202 and the closing}is on a different line. Let me use a different approach to find it.Let me look at the code around line 202:
gog.funcs = template.FuncMap{ "title": ..., ... }The closing brace
}matches the opening{oftemplate.FuncMap{. Let me trace the braces more carefully.Assistant
Let me look at lines around 550-565 to see the end of the FuncMap
Assistant
Now let me look at
buildWhichFallbackEntriesas a reference for how template functions workAssistant
Let me look at that function for reference:
Assistant
Now I have a comprehensive understanding. Let me implement the fix.
Plan:
- Add a
specStaleTimestampFieldstemplate function to the FuncMap ingenerator.gothat builds the union of the hardcoded allowlist and spec-declared date-time fields - Modify the template
pm_stale.go.tmplto use this function
Let me start with the template function in generator.go:
- Add a
Assistant
Let me add the template function in generator.go. I'll insert it before `"whichFallbackEntries"
Assistant
Let me try a different approach using the
replaceAssistant
Let me open the file and navigate to line
Assistant
Let me use a Python script to make the edit
Assistant
Let me verify the change was applied correctly
Assistant
Good, the function was added. Now let me modify the template to use this function
Assistant
Let me use Python to edit the template
Assistant
Let me verify the template
Assistant
Let me verify the Go code compiles
Assistant
Let me check the Go environment
Assistant
Let me set up GOPATH and try building
Assistant
Let me set up the full Go environment
Assistant
Good, it compiles. Let me now run the relevant tests
Assistant
The test
TestStaleTemplateCoversCommonTimestampFieldsfails because it checks the template source for literal field strings. Since the fields are now generated via thespecStaleTimestampFieldstemplate function, I need to update the test to verify the fields are in the function.Let me update the test to check the generator's template function instead of the template source:
Assistant
I need to keep the hardcoded fields visible in the template source for the test to pass. Let me revise the approach: keep the hardcoded list AND add spec-derived fields using a template range. Let me revert the template change and use a hybrid
Assistant
Let me verify the template looks
Assistant
There seems to be a duplication issue. Let me look at the full template
Assistant
The template is messed up - there's a duplicate comment. Let me restore and properly fix it
Assistant
Let me modify the approach. I'll update the template function to return only spec-derived fields (not in hardcoded list) and add them to the template.
Assistant
Now let me edit the template to add the spec-derived fields at the end of the hardcoded
Assistant
Let me verify the template
Assistant
Let me verify the generator function
Assistant
Now let me build and run the tests
Assistant
Good, it compiles. Let me run the stale template test
Assistant
The test passes. Let me run the other related tests
Assistant
Let me run all generator tests to make sure nothing is broken
Assistant
The failure is a vulnerability scan, not related to my changes. Let me check if it was pre-existing by running a few more specific tests
Assistant
Let me also check the scorecard reference
Assistant
Let me verify the Generator struct's Spec field type
Assistant
Let me look at the Generator struct to see the Spec field type.
Assistant
Let me verify how other template functions are called with
Assistant
Let me add a nil-safety check to the template function
Assistant
Let me build and run tests
Assistant
Let me check the full diff to make sure everything looks correct
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.