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 first locate the stale-command template and the generator’s spec metadata flow, then reproduce the generated allowlist behavior with the relevant tests or fixtures before making the smallest additive change.
- Assistant
ripgrepis unavailable, so I’ll use recursivegrepand inspect the matching generator/template files and nearby tests. - Assistant
The implementation is entirely template-driven and existing tests already assert the hardcoded entries. I’ll inspect the template data model, workflow inclusion logic, and the surrounding stale tests to determine where date-time properties should be collected for only synced resources.
- Assistant
Next I’ll trace generation from parsed schemas to template execution. The key design choice is whether to compute a deterministic deduplicated field slice in Go (preferred) or iterate schemas in the template; computing it in Go will make additive union and stable output easier to guarantee.
- Assistant
I found the central template-data constructor. I’ll inspect its fields and the spec’s resource/schema representation, along with syncability determination, so the collector exactly follows the resources that can populate the mirror.
- Assistant
The spec does not have a separate schema registry in the shown resource type; response fields likely live on endpoints. I’ll inspect endpoint response metadata and profiler sync records, then the workflow renderer to see what data it currently passes to
pm_stale.go.tmpl. - Assistant
Response fields preserve
Format, and the generator already hascollectResponseFields, which resolves inline and named response types. I’ll reuse that resolver rather than duplicate OpenAPI shape logic, filtering it by profiler syncable and dependent resource names. - Assistant
visionRenderDatais passed to workflow templates and already contains both classes of synced resources. I’ll inspect dependent-resource naming (including nested resources) and workflow rendering, then implement a collector that handles top-level and nested synced resources and preserves the historical allowlist first. - Assistant
The workflow renderer currently passes only the raw spec, despite already having sync profile data. I’ll add a template-only
SpecDateTimeFieldsslice tovisionRenderData, compute it from recursively resolved synced resources, and pass that richer data only to the stale template. The template will retain every literal historical entry and append only deduplicated spec additions, satisfying the additive guard and preserving existing generated output when no new date-time fields exist. - Assistant
Before editing, I’ll verify
ResponseDefreferences only named item types (as assumed by the existing resolver), then patch the data structure, collector, renderer selection, and template append block. - Assistant
I’ll now apply the implementation. The collector sorts the final additions for deterministic generation, excludes blank names and historical duplicates, treats
formatcase-insensitively, and recursively indexes subresources so dependent sync resources are covered too. - Assistant
The first review exposed a subtle determinism issue: recursive map traversal could let a same-named nested resource shadow a top-level resource despite the comment. I’ll fix indexing in two passes (all top-level resources first, then descendants), then run the existing stale-template test and generator package tests.
- Assistant
Tests are blocked by this shell’s unset
GOPATH/GOMODCACHE, not by compilation. I’ll inspect the available Go cache locations and rerun with an isolated writable GOPATH while retaining the repository build cache. - Assistant
The existing static regression test passes. To reproduce the reported behavior end-to-end without modifying tests, I’ll create a temporary in-repository program that builds a minimal syncable card spec with
dateLastActivity, forces the stale workflow if needed, generates a CLI, and inspects/executes its stale command against seeded old JSON. First I’ll confirm howGeneratehandles an explicitly supplied vision set. - Assistant
An explicit
VisionSetis honored, butGeneraterelies on a profile initialized inNew’s continuation. I’ll create the temporary repro program and generate a complete CLI. The runtime seed can use the generated store’s publicUpsert, avoiding direct schema assumptions. - Assistant
Generation now shows the desired union exactly once: historical
updated_atremains anddateLastActivityis appended. I’ll complete the positive behavioral reproduction by seeding an old card into the generated store and running the generatedstale --days 14; then I’ll seed anupdated_atrow too to verify the negative compatibility case at runtime. - Assistant
The generated runtime check is blocked only because fresh output has not run its normal
go mod tidystep. I’ll tidy that temporary generated module, rerun the seed and stale command, then return to the repository before running its test suite. - Assistant
The end-to-end generated CLI finds both the Trello-specific old row and the unchanged
updated_atrow. I’ll now run the full generator package tests and then the repository-wide suite. I’ll also inspect final diffs/status for accidental temporary files and review edge cases after test results. - Assistant
The full generator suite reached a single unrelated environment failure: its generated-project gate ran
govulncheck, which rejects the installed Go 1.26.4 standard library for GO-2026-5856 (fixed in 1.26.5). No code assertion failed. During edge-case review, I noted sync discriminator dispatch can write mapped concrete resource rows; I’ll include those mapped resource names in the same collector so “synced resources” is complete, then rerun generator tests while skipping only the environment-dependent no-auth gate and run all other repository packages. - Assistant
The rerun command had two harness issues: the generator log’s actual failure scrolled above the warning-heavy tail, and
go listran before the inline Go environment assignment, producing an invalid package list. I’ll extract the precise generator failures and rerun the repository suite inside a child shell where the Go environment applies to both listing and testing. - Assistant
The remaining failures are again environment/harness-related:
$HOMEis unset (breaking cache-path and pressauth tests), and one CLI integration race/cross-spec build failure appears amid highly parallel tests. I’ll rerun withHOME=/root, which is the expected environment for these tests, and isolate generator tests that invoke the known-vulnerable externalgovulncheckgate. First I’ll identify exactly which generator test invokes that gate so only it is excluded. - Assistant
The
FAIL govulncheckline in the second run is expected output from a test of gate failure handling; the only generator assertions were$HOME-related. I’ll rerun generator withHOMEset and skip onlyTestGenerateWithNoAuth(the real external vulnerability scan), then rerun the previously failinginternal/cliandinternal/pressauthpackages in isolation before a final all-packages pass if they succeed. - Assistant
All affected generator tests pass with the single external-scan test excluded, and the previously noisy packages pass in isolation with the correct home environment. I’ll run the full repository suite under that same environment with only the known Go-toolchain vulnerability gate skipped, then inspect status and the complete diff.
- Assistant
The full suite passes, but Go’s cache trimming modified the repository’s tracked
.gocachefixture files. These are test-environment artifacts, not part of the fix, so I’ll restore that directory from Git and verify only the two intended source files remain changed. - Assistant
Restoring tracked cache files leaves newly created untracked cache entries and a test-created
.localdirectory. I’ll remove only untracked files in those two artifact paths withgit clean, then recheck concise status. - Assistant
One final compatibility review is needed because templates are also exposed through
TemplateFSto patch/regeneration callers. I’ll check whether any path renders workflow templates directly with rawAPISpec; if so, the new template field must be supplied through a function or a universally embedded data wrapper to avoid introducing a template-data contract break.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.