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
I'll start by exploring the repository structure to understand the codebase and locate the relevant files. Let's first get an overview.
- Assistant
Let me explore more of the repository structure to understand what we're working with.
- Assistant
No Go files found with "stale" in the name. Let me search more broadly for files related to stale detection or the CLI generation.
- Assistant
Let me look for stale-related files more broadly.
- Assistant
Let me explore the generator files to find the stale-related code.
- Assistant
Let me open the template file to understand the current implementation.
- Assistant
Let me scroll down to see the rest of the file.
- Assistant
Let me see the rest of the file and then examine the generator code to understand how templates are rendered.
- Assistant
Now let me examine the generator code to understand how templates are rendered and what data is available.
- Assistant
Let me look at the generator.go file to understand how templates are rendered and what data is passed to them.
- Assistant
Let me look for where the template data is prepared, particularly for the pm_stale template. Let me search for where templates are executed.
- Assistant
Let me look for where the templates are rendered, specifically where the data is passed to them. Let me search for where the stale template is rendered.
- Assistant
Let me search for where the generator actually renders the pm_stale template with data. Let me look for the rendering logic.
- Assistant
Let me search more specifically for where the workflow templates are rendered.
- Assistant
Now I can see at line 2698 that when the workflow templates (including pm_stale.go.tmpl) are rendered, they're passed
g.Specas the data. This means the template has access to the spec data. Let me examine whatg.Speclooks like and understand the spec structure. - Assistant
Let me look for the Spec type in the generator package.
- Assistant
Let me check what g.Spec is.
- Assistant
Let me look at the Generator struct definition.
- Assistant
So g.Spec is of type
*spec.APISpec. Let me look at that type definition. - Assistant
Let me examine the spec.go file to understand the APISpec structure.
- Assistant
Let me continue examining the spec.go file to understand the APISpec structure better.
- Assistant
Now I need to understand the spec structure better, particularly the Resources and Types sections. Let me look for where timestamp fields might be defined.
- Assistant
Let me look at the spec structure to understand how properties with
format: date-timeare defined. - Assistant
Let me examine the spec structure to understand how properties are defined, especially with format: date-time.
- Assistant
Let me look at the Resource type and related types to understand how properties are defined.
- Assistant
Let me look at the Types structure to understand how they're defined and how properties with format: date-time might be represented.
- Assistant
Let me look at the TypeDef structure.
- Assistant
Let me look at the spec structure to understand how resources and their types are connected. Let me search for how the spec is used in the template.
- Assistant
Let me look at the spec to see if there's any existing helper that extracts fields with
format: date-time. - Assistant
Now let me understand how the template data structure works by examining the template more carefully. Let me also look at other templates that use similar patterns.
- Assistant
Let me look at how the template data is set up and what functions the spec has available for accessing types with date-time format.
- Assistant
Let me check if there are any methods on APISpec that return fields with specific format.
- Assistant
Let me search for all methods on APISpec in spec.go.
- Assistant
Let me look at how templates get access to the spec. The template receives the full
*spec.APISpecas its data object, so we can add a method toAPISpecthat returns spec-declared date-time field names for resources, and then use that method in the template.Let me think about the approach:
- We need to add a method on
APISpecthat returns a list of property names from the spec's types that haveformat: date-timeorformat: date - We need to modify the
pm_stale.go.tmpltemplate to:- Add this spec-derived list to the hardcoded allowlist
- Make this work at the Go level (since this is a template that generates Go code)
Wait, let me re-read the issue. The template is generating Go code. The hardcoded list is in the generated Go code. The spec information is available at template-rendering time, not at runtime.
So the fix should be:
- At template rendering time, extract the date-time fields from the spec
- Include them in the hardcoded allowlist that gets generated
This means we should modify the template to use template functions to extract the date-time fields from the spec and add them to the
staleTimestampFieldsslice. - We need to add a method on
- Assistant
Let me look at what template functions are available in the generator.
- Assistant
Let me look at the existing test for the stale template fields.
- Assistant
Let me look at tests that actually render the template with a spec to understand the golden file expectations.
- Assistant
Now let me look at the golden files to understand what the generated stale file looks like.
- Assistant
Let me check the golden files directory structure.
- Assistant
Now let me understand the approach better. I need to:
- Add a method to
APISpecthat collects alldate-timefield names from the spec's types - Modify the template to include those fields in
staleTimestampFields
Let me first check the existing golden test files to understand what's expected.
- Add a method to
- Assistant
Let me check if any of the golden APIs have pm_stale.go files and look at them.
- Assistant
Let me check if any golden tests include pm_stale and what spec they use.
- Assistant
Let me look at the spec to understand what fields have format: date-time and how they're represented.
- Assistant
Let me look at the TypeField structure and understand how the spec stores fields. Let me also look at how other templates access these fields.
- Assistant
Let me check how templates access types.
- Assistant
Let me look at the types.go.tmpl template to see how it accesses .Types and the fields.
- Assistant
Now I understand how templates access types. The template receives the spec as
.Typesand can iterate over them. Let me now look at the spec to understand how to get date-time fields. - Assistant
Now I understand the structure. Let me now look at the template to understand how to add the spec-derived fields. Let me look at the full template structure again.
- Assistant
Now I have a clear understanding of the issue. Let me plan my approach:
- The
pm_stale.go.tmpltemplate has a hardcodedstaleTimestampFieldslist that doesn't includedateLastActivity(used by Trello). - The spec (
APISpec) hasTypeswhere eachTypeDefhasFields []TypeFieldwith aFormatfield that can be"date-time". - The template receives the spec as
.(an*APISpec), so it has access to.Types.
I need to modify the template so that the
staleTimestampFieldslist includes not just the hardcoded fields, but also any fields from the spec's Types that haveformat: date-time.Let me first add a method to
APISpecthat returns spec-declared date-time field names, and then modify the template to use it.Let me first check if there's already a method for this:
- The
- Assistant
Now I have a good understanding of the codebase. Let me plan my approach:
- Add a method
DateTimeFieldNames()to*APISpecinspec.gothat returns unique field names from allTypeswhereFormat == "date-time", excluding fields already in the hardcoded allowlist. - Modify
pm_stale.go.tmplto append these spec-derived fields to thestaleTimestampFieldsslice using template logic.
This keeps the hardcoded allowlist intact (preserving the existing test) while also including spec-declared date-time fields. Let me implement this.
- Add a method
- Assistant
Let me find a good spot to add the method. Let me look at the end of the file:
- Assistant
Let me add a method to
APISpecthat returns all field names fromTypeswhereFormat == "date-time". I'll add it right after theCountMCPToolsmethod. - Assistant
Now let me add the
DateTimeFieldNamesmethod toAPISpec. I'll add it after theCountMCPToolsmethod. - Assistant
Let me clean up the unnecessary loop in the method:
- Assistant
Now let me modify the
pm_stale.go.tmpltemplate to include the spec-derived date-time fields. I need to add them at the end of thestaleTimestampFieldsslice literal. - Assistant
Now I need to modify the template to add spec-derived date-time fields. I'll modify the
staleTimestampFieldsslice literal to include template logic that appends the spec-derived fields. - Assistant
Now let me verify the changes compile correctly. Let me run the tests:
- Assistant
I need to set up the Go environment properly.
- Assistant
Let me try setting GOPATH and running the build.
- Assistant
Let me try setting all the required Go environment variables.
- Assistant
The spec code compiles. Now let me run the specific tests related to the stale template.
- Assistant
Good, the existing test passes. Now let me run the broader test suite to make sure nothing is broken.
- Assistant
Let me run the full test suite for the spec package to make sure nothing is broken.
- Assistant
All spec tests pass. Now let me create a temporary test script to verify the fix works. I want to create a spec with a
dateLastActivityfield and verify it gets included in the generatedstaleTimestampFields. - Assistant
Now let me check the generator package to understand how to create a generator with a VisionSet properly.
- Assistant
Let me check the VisionTemplateSet type:
- Assistant
Let me check the VisionTemplateSet struct definition:
- Assistant
Let me check the New function:
- Assistant
Let me now run my test script to verify the fix works:
- Assistant
Let me create a proper test within the generator package:
- Assistant
All spec tests pass. Let me clean up the test file since the instructions say I shouldn't modify existing tests or add new tests to the repository.
- Assistant
Now let me run the generator tests to make sure the template change doesn't break anything.
- Assistant
Let me run the broader generator tests:
- Assistant
All tests pass. Let me also run the framework collision test since it uses pm_stale.go.tmpl:
- Assistant
Let me search for the framework collision test:
- Assistant
Let me run the framework collision test:
- Assistant
Let me run the full generator test suite to make sure nothing is broken:
- Assistant
Let me look at the full output to understand what went wrong:
- Assistant
The failure is
TestGenerateWithNoAuthfailing because of a Go vulnerability check (govulncheck) finding a crypto/tls vulnerability in Go 1.26.4 that's fixed in Go 1.26.5. This is a pre-existing issue unrelated to my changes - it's a Go version issue in the test environment. Let me verify by checking if the same test was failing before my changes: - Assistant
Let me verify this is a pre-existing failure:
- Assistant
Good, the test was already failing before my changes due to a govulncheck issue. This is a pre-existing problem unrelated to my changes. Let me restore my changes:
- Assistant
Now let me run all the tests excluding the failing govulncheck one to make sure my changes don't break anything:
- Assistant
Let me skip that specific test and run the rest.
- Assistant
All tests pass (except the pre-existing govulncheck failure which is unrelated to my changes). Let me also run the spec tests:
- Assistant
All tests pass. Let me now review my changes one more time to make sure they're correct and complete.
- Assistant
The changes look clean and correct. Let me verify the final state of the template file to make sure it looks right:
- Assistant
The template looks correct. Let me now verify the final state of the spec.go file:
- Assistant
Let me verify that
slicesis imported in spec.go: - Assistant
Good,
slicesis already imported (line 11). Everything looks correct. Let me now do a final check to make sure the template renders correctly for a spec with no date-time fields (negative test): - Assistant
Let me run the golden API tests to make sure the generated code is still correct:
- Assistant
Let me find the golden test name:
- Assistant
Let me run the TestGenerateProjectsCompile test to make sure the golden projects still compile correctly:
- Assistant
All golden projects compile correctly. The fix is working as expected. Let me run the complete test suite one more time excluding the known govulncheck failure to confirm everything is good:
- Assistant
All tests pass. Let me now do a final review of my changes and verify the checklist:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.