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 locate the stale-command template and the generator’s spec/resource metadata flow, then reproduce the generated allowlist behavior before making an additive union change. Afterward I’ll run the focused generator tests and broader relevant suite, and inspect generated output for both
dateLastActivityand existingupdated_atbehavior. - Assistant
rgis unavailable, so I’ll use recursivegrepand inspect the repository guidance plus matching files. - Assistant
The hardcoded slice lives directly in
pm_stale.go.tmpl, and existing tests currently assert only its fixed contents. I’ll inspect the template, its render registration/data type, resource/schema models, and nearby tests to determine the cleanest way to expose only date-time fields belonging to synced resources. - Assistant
Next I need the exact template context and sync-resource selection. I’ll inspect generator initialization/rendering,
APISpec/Resource/field definitions, and the workflow eligibility logic around the stale template. - Assistant
The spec model carries response field formats, while sync eligibility is profiler-derived. I’ll inspect those structures and the central render loop to see whether workflow templates currently receive raw
APISpecor a richer context, then trace how response schemas are represented for list endpoints (including nested/array responses). - Assistant
Workflow rendering likely already uses
visionRenderData; I’ll verify that block and inspect endpoint response fields plus profiler sync metadata. This will establish whether a helper can derive a deterministic deduplicated slice in generator code without widening public interfaces. - Assistant
Domain workflows currently receive only
APISpec, so I’ll add a private template-data field specifically for the derived timestamp names. Before coding, I’ll inspectResponseDef, how profiler chooses a list endpoint, and schema derivation conventions to ensure the same endpoint/resource selection is used and dependent synced resources are included as requested. - Assistant
A reusable
collectResponseFieldsalready resolves declared response types and format upgrades, making it the right source. I’ll inspect its full implementation and resource flattening helpers, then implement a deterministic helper that selects profile syncable + dependent resource names, gathersformat: date-time, deduplicates against the historical allowlist in the template, and passes the additions only to workflow rendering. - Assistant
I’ll implement the union in generated code so duplicates are removed without coupling generator logic to the template’s historical list. The generator will provide sorted, exact wire property names from date-time response fields of syncable and dependent resources; the template will feed those into an order-preserving union whose historical entries remain first and can never be removed.
- Assistant
The implementation is in place. I’ll first run the focused generator tests to catch template parsing/rendering regressions. Then I’ll use an existing generation pathway with a temporary spec outside the repository (not a test file) to reproduce the Trello-style field in actual generated Go and execute the generated command against a hydrated SQLite row.
- Assistant
The focused test did not start because this shell has neither
GOMODCACHEnorGOPATHconfigured. The repository includes a local.gocache; I’ll inspect Go environment and configure repository-local cache/module paths for test execution without changing tracked files. - Assistant
HOMEis unset andGOENV=off, explaining the empty defaults. I’ll rerun with explicit temporary GOPATH/module cache and the repository’s build cache; dependencies may already be available in the standard root cache. - Assistant
The broad regex unintentionally selected expensive
TestGenerate*ship-gate tests; the stale/template tests passed, while one unrelated generated-projectgovulncheckfailed because the installed Go 1.26.4 standard library is flagged and requires 1.26.5. I’ll rerun the exact stale test, then inspect the generator CLI usage and choose a small internal YAML fixture shape for an end-to-end print. - Assistant
I’ll create a temporary OpenAPI document with a listable
cardsresource whose item schema declares bothdateLastActivityandupdated_atas date-time. The project-management profile should selectpm_stale; generated output will show whether both the new spec-derived name and historical name survive the union. I’ll keep temporary output under the repository and remove it after verification. - Assistant
Validation correctly rejected the reserved repro host before generation. I’ll switch only the temporary server URL to a real-shaped API host and rerun; no network call is needed for local spec generation.
- Assistant
The minimal API is syncable but does not meet the profiler’s threshold for selecting the project-management workflow set, so no stale file was expected. For a controlled repro, I’ll use a temporary Go driver inside the module that constructs the same spec model and explicitly selects the exported
pm_stalevision template, then remove the driver. This exercises the actual profiler/generator/template path without altering tests. - Assistant
I can avoid rebuilding the spec manually by calling the repository’s OpenAPI parser from the temporary driver. I’ll find its entry point, force
Store,Sync, and the stale workflow, generate to the temporary directory, and inspect/compile the generated stale package. - Assistant
I’ll now run that driver. In addition to checking rendered source, I’ll inject a small temporary generated-package test (outside the repository’s tracked tests and deleted with the whole generated directory) that opens the generated store, inserts one old
dateLastActivityrow and one oldupdated_atrow, invokesstale --days 14, and asserts both IDs appear. This directly covers the requested positive and negative runtime cases. - Assistant
Go ignores files beginning with
./_, so the temporary driver was not compiled. The failed chainedcdalso moved the persistent shell to/; I’ll return to the repository, use a normal temporary filename, guard directory changes in a subshell, and rerun the same reproduction safely. - Assistant
The actual generated source now demonstrates the intended union:
dateLastActivityis emitted from the spec,updated_atremains in the historical list, and the duplicate spec declaration is deduplicated at initialization. I’ll inspect the generated store API signature, create the temporary runtime check accordingly, and run it in a subshell. - Assistant
UpsertBatchaccepts raw JSON and returns counters, so I’ll use that API and run the generated CLI package test. This verifies SQLite predicate construction and Go-side timestamp extraction for both field styles, not merely source emission. - Assistant
The generated project was intentionally produced without validation, so its
go.sumwas not populated; the runtime test therefore did not compile yet. I also see the generated module path isstale-repro-pp-cli, so I’ll correct the temporary test import, rungo mod tidyin the generated project, and rerun. - Assistant
The end-to-end runtime repro passes: the generated stale command finds both the Trello-style spec-derived row and the existing
updated_atrow. I’ll remove all temporary artifacts, inspect tracked changes, then run the mandated golden verification because a generator template changed. - Assistant
Golden verification could not start because
jqis missing. Its setup also ran Go cache cleanup against the repository’s unusually tracked.gocache, creating a large cache-only status diff. I’ll restore that directory exactly from Git and remove only untracked cache files, then install/usejqif the package manager is available and rerun golden verification with a cache outside the tracked tree to prevent recurrence. - Assistant
Tracked status is clean apart from the two intended source files. I’ll install the missing golden harness dependency, then rerun with
/root/.cache/go-buildrather than the tracked cache directory. - Assistant
Golden verification ran but reports 16 fixture cases with widespread unrelated drift (many files that this two-file change cannot affect, plus schema stdout). I’ll inspect representative diffs and search specifically for
pm_stale.goin the golden actuals to distinguish baseline/environment drift from an intentional stale golden update. - Assistant
Representative diffs confirm an environment-specific normalization bug: the absolute repository path
/cli-printing-pressis naively replaced inside the canonical GitHub URL suffix, producingmvanhorn<REPO>in nearly every generated file. The generated golden fixture does includepm_stale.gobut did not report it changed, likely because that artifact is not in the fixture’s comparison manifest. I’ll compare it manually, remove golden/build artifacts, and run package-level tests using a cache outside the repository. - Assistant
Focused generator/schema tests pass and the working tree contains only intended changes. Before finalizing, I’ll list workflow-related tests and run the relevant rendering/compilation group (avoiding the known unrelated
TestGenerateWithNoAuthvulnerability gate), then review the final diff for edge cases such as unsynced resources, duplicate names, and deterministic ordering. - Assistant
I’ll run the project-management workflow generation tests plus stale and schema response-field tests. These exercise the changed workflow render context and confirm existing templates still resolve embedded
APISpecfields. - Assistant
All relevant workflow generation tests pass. I’ll perform one final diff/status review and verify no temporary files or cache changes remain. I’ll also confirm the derived-field helper only includes exact
date-timeformats from syncable/dependent response schemas, while sorted output and runtime union handle nondeterminism and duplicates.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.