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
I'll start by exploring the repository structure to understand the codebase and find the relevant files.
Assistant
I'll start by exploring the repository structure to understand the codebase.
Assistant
Let me explore the internal directory and find the stale template.
Assistant
Let me look at the stale template.
Assistant
Now let me understand the generator code and how the template is rendered.
Assistant
I need to make only one tool call at a time. Let me look at the generator code.
Assistant
Let me find how the stale template is rendered in the generator.
Assistant
Now let me look at how the template is invoked and what data is passed to it. Let me search for where pm_stale is rendered.
Assistant
Let me find where the template is actually rendered (where it writes the file).
Assistant
Let me look at the broader render loop around line 2655 to understand how workflow templates get rendered and what data they receive.
Assistant
Now I understand: the stale template is rendered with
g.Spec. To add spec-declared date-time fields, I need to pass extra data into the template. Let me look at the spec.APISpec structure and how properties are defined.Assistant
Let me look at the Resource and Property types in the spec to understand how date-time properties are declared.
Assistant
Let me look at the Property type (line 1531) and the Resource/Endpoint structures.
Assistant
Now let me look at the ResponseDef to understand how response properties are described.
Assistant
Now let me look at the existing test for stale in generator_test.go.
Assistant
Let me look at how the template helper functions like
modulePath,currentYearare set up.Assistant
Let me look at the profiler's SyncableResource structure to understand how synced resources relate to types.
Assistant
Let me look at how resource response items reference types, and how the schema builder derives tables from synced resources.
Assistant
Let me look at the other workflow templates to understand what data fields they reference.
Assistant
Let me look at the
minimalSpechelper and how the profiler is set up in tests.Assistant
Let me look at the Generate function to understand the order of operations and where the profiler runs.
Assistant
Let me check whether the profiler runs before
renderVisionAndRootFiles. Let me look atvisionRenderDataand where profile is set. The profile is set inrenderStoreFilesperhaps, or earlier. Let me checkrenderStoreFiles.Assistant
Let me check all template data references in the workflow templates to ensure a wrapper struct won't break them.
Assistant
Let me look at the full DependentResource struct and how dependent resources resolve their endpoints.
Assistant
Let me look at how the profiler builds dependent resources and resolves their endpoints.
Assistant
Let me look at the sync template and how dependent resources are resolved to their spec.Resource.
Assistant
Let me look at how the sync template resolves the dependent resource's endpoint and type. Let me look around line 948 and 1064 where DependentSyncResources are iterated and the endpoint is used.
Assistant
Let me look at
schemaWithDependentParentsand how dependent resources get their schema/tables.Assistant
So
BuildSchema(g.Spec)builds tables from top-levels.Resources. The dependent resources' tables come fromBuildSchematoo (it walkss.Resourcesincluding sub-resources? Let me check). ActuallyBuildSchemaiteratess.Resources(top-level). Let me check if it includes sub-resources.Let me look at BuildSchema more fully.
Assistant
Let me look at
buildSubResourceTableand how sub-resources/sharding resolve names.Assistant
Let me search for any tests that exercise the generated stale command behavior or content beyond the template-source test.
Assistant
Let me look at the framework_collision_test.go to understand how it uses the stale template.
Assistant
Let me look at how
detectDependentResourcessets the DependentResource Name (raw key vs sharded).Assistant
Let me look at how the store template resolves dependent resource types/accessors.
Assistant
Let me check the imports in generator.go to see if
profileris already imported.Assistant
Now let me write a reproduction test to confirm the issue. I'll create a temporary test file in the generator package.
Assistant
The Go module cache isn't set. Let me check the environment and configure it.
Assistant
I need to set GOCACHE and HOME too. Let me configure the full Go environment.
Assistant
I've confirmed the issue: the generated
pm_stale.godoes NOT includedateLastActivity. Now let me implement the fix. First, let me verify the spec package helper function names I'll need.Assistant
Now let me check
validateRenderedArtifactto ensure my generated output passes validation.Assistant
Now let me create the helper file for computing spec-declared date-time fields.
Assistant
Now let me modify
renderWorkflowFilesto pass the wrapper struct. Let me view the exact current code.Assistant
Now let me modify the template to append the spec-declared date-time fields to
staleTimestampFields. Let me open the template.Assistant
Now let me update the comment and the
staleTimestampFieldsliteral to append spec-declared date-time fields.Assistant
Now let me run the reproduction test to confirm the fix works.
Assistant
The reproduction test passes. Let me verify the generated output looks correct.
Assistant
Let me dump just the
staleTimestampFieldsslice from the generated output to confirm dedup works.Assistant
The output is correct:
dateLastActivityis added, andupdatedAt(already in the allowlist) is not duplicated. Now let me remove the temp test files and run the existing tests to ensure nothing breaks.Assistant
Now let me run the existing stale-related tests and the broader generator test suite to ensure nothing breaks.
Assistant
All targeted tests pass. Now let me write an end-to-end behavioral test to confirm the generated
stalecommand actually finds rows older than N days usingdateLastActivity. Let me first check the store API for seeding the resources table.Assistant
Let me write an end-to-end behavioral test in the generated CLI to confirm the stale command finds old rows via
dateLastActivity.Assistant
Let me fix the test (unused import and the made-up
newStaleCapture).Assistant
Let me debug by printing the generated seed file content.
Assistant
Let me rewrite the e2e test cleanly with a debug print of the seed file.
Assistant
The stale command correctly found
card-old(20 days old) and excludedcard-recent. The test only failed because I forgot--json. Let me add it and re-run.Assistant
The sed didn't match the escaped quotes in the string literal. Let me rewrite the file cleanly with
--jsonand without the debug log.Assistant
The end-to-end test passes. Now let me remove the temp test and run the broader generator test suite to ensure nothing breaks.
Assistant
Build passes. Now let me run the full generator test suite.
Assistant
The only failure is a pre-existing
govulncheckgate inTestGenerateWithNoAuthdue to a Go stdlib vulnerability (crypto/tls@go1.26.4, environment toolchain issue), unrelated to my change. Let me confirm it's pre-existing by stashing my changes and running that test.Assistant
The
TestGenerateWithNoAuthfailure is pre-existing (fails on clean checkout) — it's an environmental Go toolchain vulnerability, not my change.Important: the submit mechanism uses
git diff(unstaged tracked changes), so my new untracked filestale_fields.gomight not be submitted. To be safe, I'll move the helper code into the existing tracked fileschema_builder.goand delete the untracked file.Assistant
Now let me append the helper functions to
schema_builder.go. Let me check the end of that file and the imports.Assistant
I'll append the helper functions to
schema_builder.goand add theprofilerimport.Assistant
Now I need to add the
profilerimport toschema_builder.go.Assistant
Now let me rebuild and re-run the targeted tests plus the e2e reproduction to confirm everything still works after moving the code.
Assistant
All pass. Now let me verify the negative case (an API using
updated_atstays unchanged with no duplicates) and the dependent-resource case with a quick temp test.Assistant
The negative test passes. The dependent-resource test failed — let me debug whether the profiler detected the sub-resource as a dependent sync resource.
Assistant
The profiler didn't detect
cardsas a dependent resource with my test spec. Let me find an existing test that successfully creates a dependent sync resource to model my test correctly.Assistant
The Discord spec produces dependent resources. Let me look at the discordSpec to model a dependent resource correctly. The key is
/channels/{channel_id}/messageswhere the path paramchannel_idmatches the parentchannels. In my test, I used{board_id}for parentboards— the param nameboard_idshould resolve to parentboardsviaresolveParentResource. Let me check why it didn't.Let me look at the discordSpec helper.
Assistant
I see the issue: in real specs (like Discord), dependent resources are often top-level resources with parameterized paths (e.g.,
messagesat/channels/{channel_id}/messages), not sub-resources. My resolver only looked inparent.SubResources. Let me makeresolveDependentSpecResourcerobust by also checking top-level resources and using a path+method fallback across the whole resource tree.Assistant
Let me verify
sortedResourceNamesexists in the package.Assistant
Now let me update my dependent-resource test to use the Discord-style top-level dependent shape and re-run.
Assistant
The profiler requires specific signals (pagination, etc.) to detect dependent resources. Rather than reverse-engineer, let me test
resolveDependentSpecResourceandstaleSpecDateTimeFieldsdirectly with a manually-constructed profile, like the existing test at line 4249 does.Assistant
I see — the test at line 4249 sets
gen.profiledirectly. Let me directly unit-teststaleSpecDateTimeFieldsandresolveDependentSpecResourcewith constructed profiles covering both top-level and sub-resource dependents.Assistant
All cases work correctly: syncable, sub-resource dependent, and top-level dependent date-time fields are picked up, while
updated_at(in the allowlist) is deduplicated. Let me remove the temp test and run the full generator suite to confirm no new failures.Assistant
The only failure is the pre-existing
govulncheckgate inTestGenerateWithNoAuth(environmental Go toolchain vulnerability). Let me confirm by running the full suite excluding that one test.Assistant
All tests pass except the pre-existing environmental govulncheck failure. Let me check
git statusandgit diffto see exactly what will be submitted, and verify the.gocachepollution doesn't interfere.Assistant
Let me check if
.gocacheis gitignored, and clean up the module cache pollution to keep the working tree tidy.Assistant
.gocacheis NOT gitignored, and the new module cache files are untracked. The.gocachewas originally a tracked directory? Let me check if.gocachewas tracked originally. Actually,git statusshows the new subdirs as untracked, meaning.gocacheitself isn't tracked (or its contents aren't). Let me check if any.gocachefiles are tracked.Actually, the original
.gocachehad numbered dirs (00, 01...) which were probably the pre-populated module cache. Let me check if those are tracked.Wait — the key question: will the submit include these untracked
.gocachefiles? The submit usesgit diff, which does NOT include untracked files. So they won't be submitted. But to be safe and clean, let me restore the to its original state by removing the newly-added module download dirs.Assistant
.gocacheis a tracked build cache (2007 files). MyGOMODCACHEsetting polluted it with untracked module-download subdirs. These won't be submitted (git diff only tracks modified files), but let me clean them up to keep the tree tidy — removing only the newly-created untracked subdirs.Assistant
The working tree is now clean with only my 3 source file changes. Let me do a final review of the complete diff.
Assistant
The diff looks clean. Let me verify the insights templates (health_score, similar) aren't routed through the Workflows loop (which now passes the wrapper), and check what data they reference in case they ever are.
Assistant
There are two loops over
g.VisionSet.Workflows(lines 1897 and 2714). Let me check line 1897 to ensure I modified the right one and didn't miss a render path.Assistant
Line 1897 is just computing framework use names (not rendering), so the only Workflows render loop is the one I modified. Insights are rendered separately (still
g.Spec). Let me rungo vet ./...to be thorough across the repo.Assistant
go vet ./...passes. Let me verify the OpenAPI parser populatesFormat: "date-time"on TypeFields (so the fix works for OpenAPI-sourced specs, not just internal YAML).Assistant
The OpenAPI parser populates
Format: "date-time"on TypeFields (confirmed by parser tests), so the fix works for OpenAPI-sourced specs too. Let me clean up the.gocachepollution from the vet downloads and do a final verification.Assistant
The working tree is clean with only my 3 source file changes. Let me do a final sanity check by re-running the key stale tests after all refactoring.
Assistant
All key tests pass and the working tree is clean. Let me do a final comprehensive cleanup of any remaining untracked
.gocacheentries and confirm the final state.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.