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 callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /cli-printing-press, current file: none) bash-$
- Positive: a spec with a
Assistant
Let me explore the repository structure to understand the codebase and find the relevant files.
Assistant
Let me explore the repository structure.
Assistant
Let me look at the internal directory and find the stale template.
Assistant
Now let me understand how the template gets executed and what data is available. Let me look at the generator code around the
pm_stale.go.tmplcase.Assistant
Now let me find where templates are rendered and what
datais passed. Let me look for the call site ofrenderTemplatefor the stale template and what data structure is used.Assistant
Let me find the data passed to the pm_stale template specifically.
Assistant
Let me find the main template rendering map (the one around line 1535) which includes pm_stale.go.tmpl.
Assistant
Let me find where pm_stale.go.tmpl is mapped to an output path and what data is passed to it.
Assistant
Let me look at vision_templates.go to understand the workflow templates and how they are rendered.
Assistant
Now let me find where workflow templates are rendered and what data is passed.
Assistant
So
g.Spec(the APISpec) is passed as data to the template. Let me understand the spec structure to know how to derive date-time property names.Assistant
Let me look at the Resource and TypeDef structures, especially properties with format date-time.
Assistant
Now let me look at the ResponseDef and Param/Property structures to understand where properties with format: date-time live.
Assistant
Now let me look at the existing tests for the stale template to understand the test format and expectations.
Assistant
Let me look at the template functions available (the FuncMap).
Assistant
Let me look at how the generator determines syncable/synced resources and their response item types.
Assistant
Let me look at how the template FuncMap is set up and what closures it has access to.
Assistant
Let me check how the OpenAPI parser populates Types and response item types, to confirm date-time fields land in
Types.Assistant
Let me look at lines 4040-4060 and 4750-4770 to confirm TypeField.Format is populated from schema.
Assistant
Let me find where helper functions like
exportableResourcesandsafeSQLNameare defined to place my new helper.Assistant
Let me look at how golden test files for pm_stale.go are structured and find an existing golden pm_stale.go.
Assistant
No golden pm_stale.go files exist. Let me search the golden fixtures more broadly.
Assistant
Let me look at how generator tests build specs and run generation, to understand the testing infrastructure.
Assistant
Let me look at the
minimalSpechelper and find how to set up a workflow/stale generation test.Assistant
Let me check if there are format constants in the spec package.
Assistant
No constant for "date-time". I'll use the literal string "date-time". Let me check if there's a constant somewhere else (openapi package).
Assistant
The codebase uses the literal string "date-time" directly (e.g., parser.go line 3741, 4671). So I'll use the literal "date-time" string. Let me check the schemaFormat function to see how it normalizes.
Assistant
Now I understand the codebase. Let me implement the fix. First, I'll add a helper function
specStaleTimestampFieldstovision_templates.go.Assistant
Now let me add the helper function after
hasBareCollectionEndpoint:Assistant
Now let me insert this helper into vision_templates.go after
hasBareCollectionEndpoint:Assistant
The helper is added. Now let me register it in the FuncMap near
exportableResources:Assistant
My edit created a duplicate
"isGraphQL"and broke indentation. Let me fix lines 286-292:Assistant
There's now a duplicate
"kebab"at lines 292-293. Let me clean up lines 286-293:Assistant
There's a duplicate
"humanName"at lines 293-294. Let me remove the duplicate:Assistant
The FuncMap is now clean. Let me check the scorecard that reads
pm_stale.gocontent to make sure my changes don't break it.Assistant
The scorecard only checks for the
"limit"flag, which my change doesn't affect. Now let me modify the template. Let me open it:Assistant
Now let me modify the template. I'll replace the hardcoded
staleTimestampFieldsvar block (lines 16-36) with the hardcoded baseline, a spec-derived slice, and a runtime union:Assistant
The template changes look good. Now let me verify the generator package compiles:
Assistant
Let me set up the Go cache environment variables:
Assistant
The build is downloading dependencies. Let me check if there's a vendor directory or if we need network. Let me wait for the build to complete.
Assistant
The generator package builds. Now let me run the existing stale template test:
Assistant
The existing test passes. Now let me write a temporary verification script. First, let me find tests that set
VisionSet.Workflowsto understand the setup pattern:Assistant
Now I understand the test pattern. Let me write a temporary verification test to confirm the fix works for both positive and negative cases:
Assistant
Both verification tests pass. Let me inspect the actual generated
pm_stale.gocontent to make sure it's valid, and verify the generated CLI compiles. Let me write a more thorough check:Assistant
The generated content is correct. The compile test failed due to environment (missing go.sum entries in the generated CLI). Let me check how the existing tests handle this with
runGoCommand:Assistant
Let me update the compile test to use the existing
runGoCommandRequiredhelper and proper env:Assistant
The compile failure is an environment issue (sumdb verification needs HOME/GOPATH). Let me check the env and set the needed vars:
Assistant
HOME and GOPATH are not set. Let me set them along with GONOSUMDB for the compile test:
Assistant
The remaining compile failure is a pre-existing module-resolution environment issue (the generated MCP main.go can't resolve local packages under
-mod=modwith incomplete go.sum), not related to my change. The generation step already runsgofmt/format.Sourceon the rendered.gofile, which validates syntax. Let me confirm there were no gofmt warnings and check that an existing compile-style test also fails the same way in this environment:Assistant
runGoCommandRequiredmakesmod tidya no-op, so go.sum isn't populated — this is an environment limitation affecting all generated-CLI compile tests here. Let me confirm by running an existing compile test to see it fails the same way (proving it's environmental, not my change):Assistant
TestGenerateShareEmittedWhenEnabledpasses — so generated CLIs CAN compile here. Let me see how it differs from my compile test. Let me look at its setup:Assistant
The share test uses a real parsed spec and default VisionSet (MCP auto-enabled). My minimal-spec compile test failed on MCP module resolution. Let me check whether
Generate()always renders MCP and how it's gated:Assistant
Found it — line 2386 always generates the MCP entrypoint
main.go, but theinternal/mcppackage (line 2951) is gated onVisionSet.MCP. Since I didn't setMCP: true, the entrypoint imports a non-existent package. Let me fix my compile test to setMCP: true:Assistant
All three verification tests pass, including the compile test. Now let me run the broader set of existing generator tests that could be affected (stale, workflows, template annotation tests):
Assistant
All pass. Now let me check whether there are golden-file or full-generation tests that could be affected by the template change (e.g., dogfood/golden fixtures that include pm_stale.go):
Assistant
No golden
pm_stale.gofiles exist. Let me check for any golden-generation test runner that regenerates full CLIs and compares:Assistant
Let me check the golden test infrastructure (
scripts/golden.sh) and whether any golden fixture uses the project-management archetype:Assistant
None of the golden fixtures use the project-management archetype, so no golden output is affected. Let me run the full generator test suite with a generous timeout to confirm nothing is broken:
Assistant
The only failure is
TestGenerateWithNoAuth, which fails due to a pre-existinggovulncheckstdlib vulnerability (crypto/tls@go1.26.4, GO-2026-5856) in the Go toolchain — completely unrelated to my stale-timestamp change. Let me confirm it's pre-existing by checking which tests run govulncheck and running the suite excluding them:Assistant
Confirmed:
TestGenerateWithNoAuthfails identically on the original (stashed) code — it's a pre-existing govulncheck stdlib-vuln issue, not caused by my change. Let me run the full generator suite excluding the govulncheck-gated tests to confirm everything else passes:Assistant
body_collision_test.goonly mentions govulncheck in a comment. So the only test running the govulncheck gate isTestGenerateWithNoAuth(and thevalidate_test.gouses a fake). Let me check which tests call the validate gate that runs govulncheck. Let me search for where the "govulncheck ./..." gate is actually invoked in tests (the real one, not the fake).Assistant
So
gen.Validate()(line 1553) is called inTestGenerateWithNoAuth.Validate()runs the govulncheck gate. This is the only test that runs the real govulncheck gate. Let me confirm the function name at line 1553.Assistant
Confirmed. Let me run the full generator suite excluding only
TestGenerateWithNoAuthto confirm everything else passes:Assistant
All generator tests pass (except the pre-existing environmental govulncheck failure). Now let me run the pipeline package tests (scorecard reads
pm_stale.gocontent) and build the whole project to be safe:Assistant
Pipeline tests pass. Now let me clean up the temporary verification test file and any cache artifacts. Let me check git status first:
Assistant
Let me remove the temporary test file and clean up the cache artifacts. First, let me check
.gitignore:Assistant
The working tree now contains only my intended changes. Let me verify there are no stray untracked files and review the final diff:
Assistant
The diff is clean and complete. Let me do a final build/vet check and re-run the key stale template test to confirm everything is solid:
Assistant
Everything passes. Let me clean up any cache artifacts created during the test run and verify a final clean git status:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →