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 hardcoded stale timestamp allowlist, then inspect how spec metadata is passed into templates and identify relevant tests or fixtures.
- Assistant
rgis unavailable, so I’ll use recursivegrepand narrow results by source/template file types. - Assistant
I found the workflow template and existing generator tests around this exact behavior. Next I’ll inspect the template, template-data model/render path, and nearby test conventions to determine the smallest durable additive implementation.
- Assistant
The template currently has no spec-derived input. I’ll inspect
generator.goaround the render dispatch, the central template data type, and OpenAPI schema representation to see where date-time properties can be collected for only synced resources. - Assistant
I need to establish which spec field list corresponds to hydrated/synced response objects and how workflow templates are rendered. I’ll inspect the core data types and vision rendering sections in detail.
- Assistant
The spec exposes response
TypeswithTypeField.Format, while syncability comes from the profiler. I’ll retrieve the fullvisionRenderData, workflow rendering loop, and resource/endpoint response links so the collector follows the actual synced resource type rather than indiscriminately adding every API date field. - Assistant
I’ll inspect the exact
APISpec,Resource, and profiler sync records, plus examples of generated specs linking endpoint responses toTypes. This determines handling for list arrays, aliases, and dependent synced resources. - Assistant
A safe design is to preserve the literal historical allowlist and template-append only deduplicated spec-derived fields, making the additive guard structurally explicit. Before editing, I’ll inspect profiler endpoint selection and dependent resource metadata so the collector covers all records that sync can hydrate, including dependent syncs, without pulling unrelated request schemas.
- Assistant
The profiles retain chosen path/method, allowing an exact match back to response endpoints (including dependent and enum-expanded paths, where query suffix needs normalization). The schema builder already solves a related “response types only” problem; I’ll inspect it for reusable traversal/lookup conventions before implementing a focused helper.
- Assistant
I’ll implement a deterministic collector that:
- Builds the set of endpoint path/method pairs selected by flat and dependent sync profiling.
- Walks top-level and nested resources, resolving only matched endpoint response types.
- Selects fields whose format is case-insensitively
date-time. - Excludes historical allowlist entries and deduplicates/sorts additions.
Then I’ll pass those additions to workflow rendering and append them in the template while leaving every existing literal untouched.
- Assistant
The implementation is in place. I’ll now reproduce the reported shape end-to-end using a temporary Trello-like internal spec and the actual generator CLI, first discovering the command syntax and required vision settings from existing fixtures/docs.
- Assistant
There are existing workflow-generation tests that construct generators directly; I’ll inspect those helpers and use the project’s CLI help to choose the fastest end-to-end reproduction without modifying tests.
- Assistant
The Go tool needs explicit cache environment variables in this sandbox. I’ll inspect the preloaded cache layout, then run focused generator tests with
GOMODCACHE/GOCACHEconfigured. This will also expose template execution regressions from changing workflow data. - Assistant
Focused existing tests pass. To confirm the issue and fix behavior, I’ll create a temporary (non-repository) generation harness with a syncable
cardslist response containingdateLastActivity: date-time, generate the project, verify the emitted union, and then add a temporary test only inside that generated/tmpproject to seed old card JSON and executestale --days 14. The temporary artifacts will not be submitted. - Assistant
minimalSpecis likely in another test helper file. I’ll locate it, then write the temporary harness with the minimum required metadata and run generation. - Assistant
I have the minimal required spec shape. I’ll generate to
/tmp/trello-repro, inspect the rendered field list, and remove the harness immediately afterward. - Assistant
The generated union now includes
dateLastActivitywhile retaining all defaults. I’ll exercise actual stale detection against a real generated SQLite store. I’ll inspect generated store/root APIs, then place a temporary generated-project test that inserts both an old and recent card and asserts only the old row is returned. - Assistant
The generated command accepts a direct
--dbpath and JSON output, so the runtime test can invokenewStaleCmdwithout the full root. I’ll create and run that test only under/tmp/trello-repro. - Assistant
The generated runtime test did not compile yet because generated projects intentionally start without
go.sum; this is environment/setup, not a code failure. I’ll rungo mod tidywith the now-populated module cache, then rerun the temporary runtime test. - Assistant
The actual command found exactly the old Trello-style card and excluded the recent card; the assertion failed only because the command correctly prepended an unsynced-store hint before JSON. I’ll make the temporary harness parse JSON after that hint and rerun to obtain a clean passing confirmation.
- Assistant
Positive behavior is confirmed end-to-end. For the negative guard, the collector explicitly filters all historical names against
defaultStaleTimestampFields, so a spec-declaredupdated_atcannot be appended or duplicated; the literal remains unchanged. I’ll now run the full generator package tests, then broader repository tests if practical, and inspect formatting/diff/status. - Assistant
The full generator suite ran broadly but failed on pre-existing environment/toolchain conditions:
$HOMEwas unset for cache-path tests, andgovulncheckrejects this sandbox’s Go 1.26.4 standard library (fixed only in 1.26.5). No stale-related failure appeared. I’ll rerun compile-only and focused affected tests withHOMEset, then check the final diff. - Assistant
Tests created untracked cache/local directories because I pointed module cache into the repository and some generator tests use a local output path. I’ll remove only those untracked artifacts, preserving source changes, then reconsider one robustness detail: response type lookup should tolerate normalized/case variants just as the profiler does.
- Assistant
To minimize blast radius, I’ll pass enriched
visionRenderDataonly topm_stale.go.tmpl; all other workflow templates will continue receiving the exact original*APISpecdata type. Then I’ll rerun focused tests and final checks. - Assistant
I’ll explicitly verify the negative case rather than relying only on code inspection: generate a second temporary CLI whose synced response declares
updated_atasdate-time, then assert the emitted allowlist contains exactly oneupdated_atentry (the historical literal, with no additive duplicate). - Assistant
Final checklist:
- If an error was reported, I successfully reproduced it. A generated Trello-like CLI originally lacked spec-derived support by construction; using the reported
dateLastActivityshape, I generated the affected stale workflow and seeded its real SQLite store with old/recent cards. - If an error was reported, I confirmed the fix resolves it. The generated allowlist contains
dateLastActivity, and the actual generatedstale --days 14command returned the old card while excluding the recent card. - I thought about edge cases. The collector is limited to response types of flat/dependent endpoints actually selected for sync, handles enum-expanded query paths, recursively visits subresources, trims and case-insensitively checks , deduplicates and deterministically sorts additions, and never removes defaults. An explicit negative generation confirmed exactly one unchanged historical entry.
- If an error was reported, I successfully reproduced it. A generated Trello-like CLI originally lacked spec-derived support by construction; using the reported
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.