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 understand the issue:
- There's a stale detection feature in a CLI code generator called "printing-press"
- The stale command uses a hardcoded allowlist of timestamp field names:
updatedAt, updated_at, updatedDate, modifiedAt, modified_at, lastModified, last_modified, lastEditedTime, last_edited_time, updated, last_updated - Trello uses
dateLastActivitywhich is not in the allowlist, so the stale command silently returns no results - The fix should: build the stale timestamp-field set as
hardcoded allowlist ∪ spec-declared date-time property names for the synced resources
Let me explore the repository to understand its structure and find the relevant files.
Assistant
Let me search for the stale-related template and code:
Assistant
Let me search for the stale timestamp fields allowlist
Assistant
Let me look at the vision_templates.go file for the stale template:
Assistant
Let me find the template file:
Assistant
Let me look at the template file.
Assistant
Let me try using bash to view the file.
Assistant
Now let me understand how the template is rendered. Let me look at the generator code that processes this template:
Assistant
Let me look at the relevant section of the generator.go
Assistant
Let me find where the stale template is rendered to understand the data context
Assistant
Let me search for where RenderTemplate is called with pm_stale.
Assistant
Let me look at the vision_templates.go to understand the template context.
Assistant
I can't seem to use the
opencommand. Let me just usecatwith sed to view specific lines.Assistant
Now let me understand the template rendering to see what data is available. Let me search for where the template rendering is called for workflows.
Assistant
Let me look at lines around 1897 and 2695.
Assistant
Let me look at lines around 2695
Assistant
So the template is rendered with
g.Spec. Let me look at the spec type to understand what data isAssistant
Let me find the Resources field and Resource type in spec.go:
Assistant
Let me look at the Resource struct definition and its Properties:
Assistant
Let me look at the Endpoint type and any other relevant types for the spec.
Assistant
Let me look at the Endpoint struct.
Assistant
Let me look at the ResponseDef type to see if it contains properties with types and
Assistant
Let me look at ResponseDef and Param types
Assistant
Let me find where the types are stored in the
Assistant
Let me understand the template system better to know what functions and access patterns are available for
Assistant
Let me look at the template function
Assistant
Now I understand the structure. Let me look at how the generator renders the stale template and what data
Assistant
Let me look at the existing stale test in generator_test.go:
Assistant
Let me look at an example of what stale looks like in golden files
Assistant
Let me look at the test around line 12796 for stale:
Assistant
Let me look at how template functions access spec data (closure-based vs parameter-based):
Assistant
Let me check the APISpec struct for Owner and other fields the template uses:
Assistant
Let me first run the existing tests related to the stale template to understand the current state:
Assistant
Let me check the Go environment
Assistant
Let me set up the Go environment
Assistant
Now let me try running the stale template tests
Assistant
Let me set up the environment more completely
Assistant
Let me understand how resource types are determined:
Assistant
Let me search for response type usage in the codebase:
Assistant
Let me look for how the types are accessed in the generator:
Assistant
Let me try a broader search
Assistant
Let me search differently.
Assistant
Interesting. Let me look at how types are accessed in templates:
Assistant
Let me look at how the types template accesses the data:
Assistant
Now I have a clear plan. Let me implement the fix:
- Add a
specDateTimeFieldstemplate function ingenerator.gothat returns date-time field names from the spec (excluding those already in the hardcoded allowlist) - Modify
pm_stale.go.tmplto include those fields
Let me first look at where to add the template function in
- Add a
Assistant
Let me look around line 262:
Assistant
Let me check the imports of generator.go:
Assistant
Now let me implement the fix. First, I'll add the template function to generator.go:
Assistant
Let me open the generator.go file at the right spot:
Assistant
Now let me add the
specDateTimeFieldsfunction. I'll insert it afterhasNonScalarType:Assistant
Now let me modify the template to include spec-derived date-time fields. Let me look at the relevant part of the template:
Assistant
Let me see the template lines 24-36:
Assistant
Now let me modify the template to add spec-derived fields. I'll replace the last entry of the hardcoded list to include the template iteration:
Assistant
Now let me verify that the changes compile:
Assistant
Let me check what happened around line 270:
Assistant
Let me check git to see the original state:
Assistant
I see the issue - my edit removed the
return falseline fromhasNonScalarType. Let me fix that:Assistant
Now let me verify it compiles:
Assistant
Good, it compiles. Let me now run the stale template tests:
Assistant
Let me check what happened to the
"updated"entry:Assistant
I see - my edit accidentally removed
"updated"from the hardcoded list. Let me fix the template:Assistant
Now let me run the tests again:
Assistant
Now let me run a broader set of tests to ensure nothing is broken:
Assistant
All tests pass. Now let me check if there are golden files that need updating (since they contain pre-generated output from the template):
Assistant
Good - no golden files for stale. Let me also run the full generator test suite to make sure nothing is broken:
Assistant
The failing test
TestGenerateWithNoAuthappears to fail due to a vulnerability scan (govulncheck), not related to my changes. Let me verify by checking the git status and running a specific test that's more relevant:Assistant
Let me verify the fix by looking at the minimal spec used in the test and ensuring it works correctly:
Assistant
Let me search for the minimal spec function:
Assistant
Let me find the minimalSpec definition:
Assistant
Let me look at the minimalSpec function:
Assistant
Let me create a temporary test script to verify the fix works with a spec that has date-time fields:
Assistant
Now let me run the test script:
Assistant
Let me write the test within the module instead:
Assistant
Let me copy the test file and run it:
Assistant
Let me fix the test to check properly and see the actual output:
Assistant
Now let me run the test again:
Assistant
The fix works correctly! Let me now clean up the temporary test file:
Assistant
Let me verify the final state of my changes:
Assistant
Let me run all the stale-related tests one final time to confirm everything is good:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.