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 what we're working with.
Assistant
Let me look at the generator to understand how the template is processed and how I can inject the spec-declared date-time properties.
Assistant
Let me look at the spec package to understand the structure of resources and properties.
Assistant
Let me understand the resources and types structure to see where I can find date-time property names.
Assistant
Let me look at the existing test for the stale timestamp fields.
Assistant
Let me look at the test data to see what a typical spec looks like and look for
date-timeformat fields.Assistant
Let me look at how the spec passes through to the template, and how the date-time fields are stored in resources.
Assistant
Let me look at the workflow rendering more carefully:
Assistant
Let me look at the spec methods that derive things from the resources to understand the convention:
Assistant
Let me look at how templates use the spec - looking at how spec resources are accessed in templates:
Assistant
Let me look at where the template is rendered in tests, to understand the full picture:
Assistant
Now let me look at the minimalSpec function to understand how the test works:
Assistant
Now let me look at the other workflow templates to see how they handle the spec data:
Assistant
Now let me check what other tests exist around the spec package to understand the conventions:
Assistant
Now I have a good understanding. Let me make my plan and implement it:
Assistant
Let me check where TypeField.Format is set in the parser:
Assistant
Let me also check how body fields' Format is set:
Assistant
Let me check if any existing template uses method calls on the spec:
Assistant
Let me look at how method calls return data in templates - look at a method that returns a list/slice:
Assistant
Let me look at the existing test that pins the stale template:
Assistant
Now I have a clear understanding. Let me first check the existing renderTemplate call to make sure I understand the data flow:
Assistant
Now let me also check if there's a body param testdata example:
Assistant
Now I have a complete understanding. Let me start by reproducing the issue first to ensure I understand the current behavior:
Assistant
The spec parser doesn't extract types from internal YAML. Let me look at the testdata spec:
Assistant
Let me check how internal YAML specs declare types:
Assistant
Let me look at how the OpenAPI parser populates
Types:Assistant
Let me write a more complete test using an OpenAPI spec:
Assistant
Let me check how openapi spec is loaded:
Assistant
Now I have a clear understanding. Let me clean up the test files and start implementing the fix.
Assistant
Now let me look at how methods that return slices are used in templates:
Assistant
Now let me add the
DateTimeFieldNamesmethod to the spec. Let me first look at the area near the similar methods:Assistant
Now let me add the
DateTimeFieldNamesmethod. I'll add it after theHasResourceBaseURLOverridefunction:Assistant
Let me try a different approach with the replace command:
Assistant
Now let me verify the change and that
sortis imported in the spec package:Assistant
I need to add the
sortimport:Assistant
Now let me verify the build still passes:
Assistant
The function
walkParamis defined after it's used. In Go, this is fine for closures within the same function. But wait, I declaredwalkParam := func(p Param)inside the function, so the inner closure should work. Let me check:Assistant
Let me look at the actual code:
Assistant
Let me check the exact issue:
Assistant
I need to fix the recursive closure issue. In Go, function literals can't refer to themselves by the variable name. Let me fix this:
Assistant
Now let me write a test for the new method:
Assistant
The method works. Now let me update the
pm_stale.go.tmplto use this:Assistant
Now let me update the
pm_stale.go.tmplto use the new method:Assistant
Now let me check the updated template:
Assistant
Now let me run the existing test:
Assistant
Now let me run the entire generator test suite to make sure my changes don't break anything:
Assistant
The failure is from a Go vulnerability check (unrelated to my changes). Let me look for a flag to skip that:
Assistant
Let me now run the spec tests:
Assistant
Now let me write a reproduction test that verifies the fix end-to-end. Let me first understand how the existing render tests are structured:
Assistant
Let me write a temporary test script to see the generated output:
Assistant
Hmm, the spec.ParseBytes() doesn't process OpenAPI format - that's done by openapi.Parse. Let me use openapi.Parse instead:
Assistant
The fix works! Let me clean up the test code:
Assistant
Now let me also add a unit test for the spec method:
Assistant
Now let me add tests for the new method:
Assistant
All the unit tests pass. Now let me also add a test for the generator that verifies the template generates code that includes the spec-derived fields:
Assistant
Let me add a test in the generator test file that verifies the end-to-end behavior:
Assistant
Let me check the generated file:
Assistant
The SQL is generated dynamically. Let me update the test:
Assistant
All tests pass. Let me also check that we don't have a problem with the
fmtimport being used in the existing template since I haven't actually used it in my changes:Assistant
Let me run a broader test to make sure nothing is broken:
Assistant
Now let me also test the spec test to make sure all tests pass:
Assistant
Now let me also test the entire workflow tests to make sure the rendered output is still valid:
Assistant
Let me also verify that the generated Go code is well-formatted:
Assistant
The generated Go file is well-formatted. Let me regenerate the file to verify with a fresh test:
Assistant
Let me verify the generated Go code actually compiles:
Assistant
The build errors are just because go.sum is missing. Let me check the syntax of the generated file:
Assistant
Now let me also test the build of the generated file in a fully populated project. Let me check what the test_gen approach can do:
Assistant
The generated code compiles successfully. Let me clean up:
Assistant
Let me run all the related tests one more time to make sure everything still works:
Assistant
The failure is due to a Go security vulnerability check. Let me skip that test:
Assistant
All tests pass. Let me also make sure the code I added doesn't break the existing PM workflow tests:
Assistant
Now let me also run all the tests in the spec package to make sure I haven't broken anything:
Assistant
Now let me check that we haven't broken the spec.go file with any formatting issues:
Assistant
The errors are because gofmt doesn't understand Go template syntax. The actual rendered output is valid. Let me verify with a quick test:
Assistant
Let me also verify the test for an existing spec with a different convention:
Assistant
Now let me also run the spec tests in their entirety:
Assistant
Now let me check whether there's an issue with the test for the templates being part of the test:
Assistant
Now let me verify that the templates_test.go still passes:
Assistant
Let me also verify the full list of generator tests that might be related:
Assistant
Now let me also look at the spec test for any DateTimeFieldNames tests that might have been impacted:
Assistant
Let me also verify the code in detail one more time:
Assistant
Let me verify the edge case where the spec has no date-time fields - the template should produce an empty slice:
Assistant
Both edge cases work as expected. Let me clean up:
Assistant
Now let me also test that the existing test for hardcoded fields still passes:
Assistant
All tests pass. Let me now also do a final review of the changes:
Assistant
Let me check the relevant changes:
Assistant
The .gocache files are cached build artifacts that should not be checked in. Let me check the gitignore:
Assistant
Hmm, .gocache is not in .gitignore but is in the repo. Let me check if it's tracked:
Assistant
The .gocache files were modified by my testing (using GOCACHE). Let me restore them to avoid including them in the diff:
Assistant
Now the diff is clean - only my actual changes:
Assistant
Now let me view the actual changes:
Assistant
All changes look good. Let me now do one more round of running the tests to confirm everything works:
Assistant
All tests pass. Let me also restore the .gocache once more to make sure no test artifacts are committed:
Assistant
The .gocache files are untracked now (they were created by the test runs but aren't tracked), so the diff is clean. Let me check the diff once more:
Assistant
Let me also run a final comprehensive test:
Assistant
All tests pass! Let me also restore .gocache one more time:
Assistant
Wait, the .gocache directory has untracked files. Let me check git status more carefully:
Assistant
The .gocache files are untracked, so they won't be part of the diff. The git diff will only show the modifications to the four files I'm changing. Let me verify the final state of the diff:
Assistant
Now let me run through the checklist one more time:
Checklist verification:
Assistant
The fix is complete. Let me submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.