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 first map the generator/template structure and locate the stale allowlist and spec metadata flow. Then I’ll reproduce the generated-output behavior, implement an additive union of defaults and relevant
date-timeproperties, and run focused plus broader tests. - Assistant
rgis unavailable, so I’ll use recursivegrepand inspect the likely generator packages and templates with standard tools. - Assistant
The current implementation is entirely template-local, while generation has a template-data switch. I’ll inspect both and the workflow tests to determine whether date-time fields are already represented in template data or need to be derived from the OpenAPI model.
- Assistant
I need the exact rendering path and core spec types. I’ll inspect the stale case,
APISpec/resource representations, and existing helpers that walk schemas or identify date-time formats, so the implementation follows repository conventions. - Assistant
The template is currently rendered with generic spec data. I’ll locate the workflow render loop and inspect
APISpec,Resource, endpoint response fields, and sync-resource derivation to define “for the synced resources” precisely rather than including unrelated request parameters. - Assistant
The relevant response schema is represented by
Resource.Type.Fields, and syncability appears endpoint-based. I’ll inspect generation around lines 1870/2670/2910 and the spec resource definition, then identify the canonical helper used by sync generation to select resources. - Assistant
I’ll inspect
Resource, profiler sync descriptors, and the comprehensive vision render data. The stale data can likely carry a precomputed, sorted[]string, which avoids complex template logic and guarantees deterministic output and deduplication. - Assistant
To map a sync resource name to its declared date-time properties, I’ll inspect endpoint response metadata and profiler descriptor fields. I’ll also check schema building, since it already resolves response types and may reveal aliases/subresources that should be considered.
- Assistant
collectResponseFieldsalready encapsulates response-type resolution and deduplication, exactly the schema source needed. I’ll read its complete behavior andResponseDef, then implement a helper that filters these fields toformat: date-timeonly for names present in either syncable or dependent profiler resources. - Assistant
Before editing, I’ll establish the regression in generated output using any Trello fixture/spec already in the repository. If none exists, I’ll use a temporary spec through the public CLI. This will confirm that
dateLastActivityis declared but absent frompm_stale.go. - Assistant
No Trello fixture is present. The Go environment has caches in-repo but lacks
GOMODCACHE/GOPATH; I’ll identify the command package and configure an external temporary Go cache (without changing repository files) before building a temporary reproduction spec. - Assistant
I’ll run the CLI with
GOPATH=/tmp/gopathand the existing build cache. If dependencies must download, Go can populate only/tmp, preserving the repository. - Assistant
A raw spec alone may not select the PM workflow; the generator tests construct a
Generatorwith a project-management visionary plan. I’ll inspect that test setup and public constructor so a/tmpreproduction program can generate the exact stale file without adding repository tests. - Assistant
I’ll create a short-lived root-level Go program (removed immediately afterward) that constructs a valid minimal card API with
dateLastActivity, forces stale workflow generation, and checks the output. This uses generator APIs directly and does not alter or add tests. - Assistant
The helper location wasn’t captured, but a direct spec only needs basic metadata, one list endpoint, and its response type. I’ll run that reproduction and report the generated allowlist result.
- Assistant
The reproduction confirms the silent omission. I’ll now add a deterministic derivation helper that:
- starts from the existing defaults as a deduplication guard (so the union is additive),
- considers only response fields from profiler-confirmed top-level or dependent sync resources,
- accepts
date-timecase-insensitively, - emits only additional names in sorted order,
- safely Go-quotes property names in the generated slice.
The template’s existing literals remain intact, preserving current APIs such as
updated_at. - Assistant
The implementation is in place. I’ll rerun the same temporary generation reproduction and inspect the exact generated slice around
dateLastActivity; this also verifies the profiler recognizescardsas syncable and the new template data is wired correctly. - Assistant
Presence in generated source fixes the root cause, but the requested positive test is behavioral. I’ll inspect the generated store API and existing generated-command test conventions, then use a generated temporary project (outside the repository) to seed one old card and execute
stale --days 14. I’ll also seed anupdated_atrow to verify the legacy negative/control path remains unchanged. - Assistant
I’ll generate
/tmp/stale-behavior, add a test only inside that disposable generated project, and run it. The test will assert:- an old
dateLastActivitycard is returned, - an old
updated_atcard is still returned, - a recent card is not returned,
yielding
total_count: 2.
- an old
- Assistant
The behavioral test did not compile yet because generated projects intentionally lack populated
go.sumentries; this is dependency setup, not a code failure. I’ll rungo mod tidyin the disposable project and rerun the focused test. - Assistant
The disposable end-to-end test passes both the Trello-specific and legacy
updated_atpaths while excluding a recent row. I’ll return to the repository, remove disposable artifacts, run focused generator tests (template invariant and PM generation/compilation), then run the full generator package if those pass. - Assistant
Focused tests pass. Before the full suite, I’m tightening one edge case:
collectResponseFieldsintentionally prefers GET schemas for SQL table design, but sync can use a POST list endpoint alongside a GET detail endpoint. Reusing that helper could then miss a date-time field declared only by the POST response. Since this union is additive, the safest interpretation is to scan all response schemas attached to each synced resource (still excluding request and unsynced schemas). I’ll adjust the helper accordingly, including discriminator-mapped response types. - Assistant
The repository tracks
.gocache, and Go’s automatic cache trimming modified many tracked cache entries during testing. Those are unrelated artifacts and must not be submitted. I’ll restore only.gocachefrom Git, then verify the working tree contains exactly the two intended source/template changes. Future tests will use/tmp/gocacheto avoid recurrence. - Assistant
git checkoutrestored tracked entries but left newly created untracked cache objects. I’ll clean only untracked files under.gocache(not the repository generally), then confirm status succinctly. - Assistant
The tree is clean apart from intended files. I’ll rerun focused tests against a fresh
/tmp/gocache, then run the entireinternal/generatorpackage. - Assistant
The focused affected tests pass. The full generator suite reached unrelated pre-existing/environment failures:
$HOMEis unset in cache-path tests,- generated-project
govulncheckrejects the installed Go 1.26.4 standard library vulnerability fixed only in 1.26.5. Neither failure touches stale generation, and the focused compile/generation tests passed.
I’ll do a final diff/status review and verify no cache or temporary artifacts remain.
- Assistant
The full suite created an untracked
internal/generator/.local/test artifact. I’ll remove it and perform the final status check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.