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 then find the relevant files related to the stale detection timestamp-field allowlist.
Assistant
I'll explore the repository structure first.
Assistant
Now let me look at the generator code to understand how the template is rendered.
Assistant
Let me look at the spec structure to understand what's available.
Assistant
Let me look at the
Resourcetype and property definitions.Assistant
Now let me look at the
Resourcetype definition.Assistant
Let me look at how date-time format is used in specs and the profiler's SyncableResources.
Assistant
Now let me understand how the template renders
staleTimestampFields. The template has the hardcoded list. I need to look at how the template currently renders it, and add spec-declared date-time fields. Let me look at the test file to understand expectations.Assistant
Now let me understand how the template is rendered. The template renders with
g.Specas data. Let me look at what helpers are available in templates.Assistant
Let me look at how the spec stores response properties and how date-time fields might be derived.
Assistant
Let me look at how the OpenAPI parser populates date-time format fields in types.
Assistant
Let me check the golden testdata for pm_stale.go files and how golden tests work.
Assistant
No golden files contain staleTimestampFields. Let me check how the golden tests are structured - whether they include workflow templates like pm_stale.
Assistant
Let me check how golden tests verify output and whether pm_stale.go is expected in golden fixtures.
Assistant
Let me look at how the golden tests are run. Let me search the test files for golden test logic.
Assistant
Let me look at the existing tests that render the pm_stale workflow template.
Assistant
Let me look at the
minimalSpechelper to understand the test spec structure.Assistant
Let me examine how response item types are registered in Types, to confirm date-time fields are accessible.
Assistant
Let me check the tests that use created_at with date-time format to ensure my change won't break them.
Assistant
Now I have a good understanding. Let me reproduce the issue first by creating a test script that generates a CLI with a date-time field like
dateLastActivityand checks the generatedpm_stale.go.Assistant
Let me write a reproduction script to confirm the issue. I'll create a temporary test file.
Assistant
I've reproduced the issue. Now let me look at the enclosing function of the FuncMap to understand the scope.
Assistant
Now let me implement the fix. First, let me check the imports in generator.go.
Assistant
Now let me add the helper function. I'll place it near
commandConstructorForTemplate.Assistant
Now let me insert this snippet into generator.go. I'll insert it right before
func commandConstructorForTemplate. Let me use the edit command on the file.Let me open the file at the right location.
Assistant
Now let me register the helper in the FuncMap. Let me find a good spot near the
enumLiteralregistration.Let me open the file around the
enumLiteralregistration:Assistant
Now let me update the template to append the spec-derived fields. Let me open the template file.
Assistant
Let me update the template. First the comment, then the slice.
Assistant
Let me check the line after the closing brace (there seems to be a double blank line).
Assistant
The template looks good. Now let me run the reproduction test again to confirm the fix works.
Assistant
The fix works. Now let me test the negative case and edge cases. Let me update my repro test to cover them.
Assistant
All edge cases pass. Now let me run the existing tests related to the stale template to make sure I didn't break anything.
Assistant
All existing tests pass. Let me verify the generated
pm_stale.gocompiles by generating a full CLI and building it. Let me check how other tests build generated CLIs.Assistant
Let me add a build smoke test to confirm the generated CLI compiles. Let me update my repro test file.
Assistant
The build failure is an environment issue (missing go.sum entries), not a syntax problem with pm_stale.go. Let me check how the generator handles go.sum and how existing build smoke tests succeed.
Assistant
Let me update the smoke test to run
go mod tidyfirst (like plan_generate does), with the module cache set.Assistant
go mod tidysucceeded but the build has a module path issue. Let me inspect the generated go.mod.Assistant
The build error is an environment/module-mode issue with the MCP main package, unrelated to pm_stale.go. Let me check the environment and build just the
internal/clipackage (which contains pm_stale.go).Assistant
Let me change the smoke test to build just the
internal/clipackage (where pm_stale.go lives), avoiding the unrelated MCP module issue.Assistant
The generated
internal/clipackage compiles. Now let me do a runtime test to verify thestalecommand actually finds rows older than N days usingdateLastActivity. Let me check the store schema and DB path.Assistant
Let me check if sqlite3 CLI is available for the runtime test.
Assistant
No sqlite3 CLI. Let me write a small Go helper using the printing-press's store package to seed a DB, then run the generated CLI's stale command. First let me check the store package.
Assistant
Let me inspect the generated store's API to write a seeding helper within the generated module.
Assistant
Let me check what the CLI binary's main.go imports, to see if it pulls in mcp-go (which caused the earlier build issue).
Assistant
The CLI binary doesn't need mcp-go. Now I need to understand how the
resourcestable (which stale reads) gets populated. Let me check the store's Upsert logic.Assistant
Let me check the Upsert and UpsertBatch logic to understand whether typed tables also write to
resources. Let me look at the store template's Upsert and upsertGenericResourceTx, and how sync writes. The key: does theresourcestable get the data, or only typed tables?Let me look at the upsert functions.
Assistant
Upsertwrites to theresourcestable that stale reads. Now let me write a full runtime test that builds the CLI, seeds old/recent cards, and runsstale.Assistant
The runtime test confirms the fix works —
stalefound the old card (dateLastActivity 2020, days_since 2390) and did NOT flag the recent future-dated card. The test only "failed" because the sync hint went to stderr and mixed with stdout (CombinedOutput). Let me fix the test to capture stdout separately.Assistant
The runtime test passes — the fix is confirmed at runtime. Now let me check the other file that referenced staleTimestampFields (scorecard.go) and run the broader test suite.
Assistant
The scorecard only checks for the
"limit"flag which I didn't touch. Now let me run the full generator test suite to ensure no breakage.Assistant
The whole module builds. Now let me run the generator test suite (the most relevant package) to ensure no regressions.
Assistant
The only failure is
TestGenerateWithNoAuth, which fails due to agovulncheckgate detecting a Go stdlib vulnerability (GO-2026-5856 in crypto/tls@go1.26.4, fixed in 1.26.5). This is an environment/Go-version issue unrelated to my change. Let me confirm it's pre-existing by stashing my changes and running that test.Assistant
Confirmed —
TestGenerateWithNoAuthfails identically on the original code (govulncheck/Go-stdlib vuln, environmental). My change isn't responsible.I notice
go.modgot modified by the build process. Let me check and revert it since I didn't intend to change it.Assistant
The go.mod change is an incidental build artifact (cdproto moved between require blocks). Let me revert it.
Assistant
Now only my intended changes remain. Let me clean up my temporary test files and check that build artifacts are gitignored.
Assistant
Let me check .gitignore and clean up the build cache artifacts I created.
Assistant
The
.gocacheis a tracked build cache. My test runs created untracked subdirs (buildcache, module cache). These won't be submitted (submit usesgit diff), but let me remove them to keep the repo clean.Assistant
Now only my intended changes remain. Let me do a final review of the complete diff.
Assistant
The diff looks correct. Let me verify there's no other code path rendering
pm_stale.go.tmplwith different data, and run the key stale-related tests once more to confirm everything passes.Assistant
Only
renderWorkflowFilesrenders it withg.Spec. Let me run the key stale-related tests once more to confirm everything passes after cleanup.Assistant
Let me also run the pipeline/scorecard tests and the framework collision test that reference pm_stale.
Assistant
Let me find and run the framework collision test that references pm_stale.
Assistant
All relevant tests pass. Let me run
go veton the generator package to confirm the code is clean.Assistant
go vetpasses. Let me do a final regression check: confirm that for a minimal spec (no date-time types), the generatedpm_stale.gois byte-identical to the original output.Assistant
Byte-identical for minimal specs — confirming the no-regression guarantee. Let me clean up the temp test file and build artifacts.
Assistant
All changes are clean and complete. Let me do a final review of the complete diff before submitting.
Assistant
Build and vet pass. Let me clean up the build artifacts once more before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.