Skip to content

Validate drive-memory disk-size syntax at compile time and suggest 100M - #54831

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-github-actions-job-another-one
Aug 22, 2026
Merged

Validate drive-memory disk-size syntax at compile time and suggest 100M#54831
pelikhan merged 4 commits into
mainfrom
copilot/fix-github-actions-job-another-one

Conversation

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

The Smoke Drive job failed post-cleanup with Invalid disk size: '1GB'. Expected a number with optional K/M/G/T suffix (e.g. '10G')tools.drive-memory.disk-size was accepted as any non-empty string, so invalid values only surfaced at runtime after the agent had already run.

Changes

  • Schema (pkg/parser/schemas/main_workflow_schema.json): disk-size now constrained by pattern: ^[0-9]+[KMGT]?$ (both the object and array forms); description suggests 100M instead of 10G.
  • Compiler (pkg/workflow/drive_memory_config.go): parser-side check with an explicit error, so the failure is reported even when a workflow bypasses schema validation.
  • Smoke workflow: .github/workflows/smoke-drive.md uses disk-size: 100M; lock file recompiled.
  • Docs: new "Drive size" section in the drive memory reference; frontmatter-full.md regenerated from the schema.
  • Tests: coverage for suffix-less values, rejected 1GB, and rejected lowercase 100m.

Compiling an invalid value now fails early with a line reference:

.github/workflows/smoke-drive.md:30:16: error: 'disk-size': '1GB' does not match pattern '^[0-9]+[KMGT]?$'

Suffixes are uppercase-only, matching the error text emitted by the GitHub Drives checkout action; lowercase (100m) is rejected rather than silently normalized.

Copilot AI and others added 2 commits August 22, 2026 14:20
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job and update allowed syntax for drive size Validate drive-memory disk-size syntax at compile time and suggest 100M Aug 22, 2026
Copilot AI requested a review from pelikhan August 22, 2026 14:29
@pelikhan
pelikhan marked this pull request as ready for review August 22, 2026 14:29
Copilot AI balanced review requested due to automatic review settings August 22, 2026 14:29
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot normalize lowercases inputs to the upper case format required by actions, time white space

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Pre-fetched diff (pr-diff.patch) only contains two generated/lock files: .github/workflows/agentic_commands.yml (regenerated slash-routing table) and .github/workflows/smoke-drive.lock.yml (recompiled lock file). Per ponytail-review skill boundaries, generated files and lock files are out of scope. The actual hand-written source changes for this PR (pkg/workflow/drive_memory_config.go, schema, docs, tests) are not present in the capped diff, so there is no reviewable content for an over-engineering pass.

Generated by Ponytail Reviewer for #54831

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #54831 does not have the 'implementation' label and has only 32 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-22T14:35:00Z
review_event: COMMENT
top_themes:
  - compile-time disk-size validation is consistent across schema, parser, docs, and tests
  - no blocking changed-line defects found
files_reviewed:
  - .github/workflows/agentic_commands.yml
  - .github/workflows/smoke-drive.md
  - docs/src/content/docs/reference/drive-memory.md
  - pkg/parser/schemas/main_workflow_schema.json
  - pkg/workflow/drive_memory_config.go
  - pkg/workflow/drive_memory_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 6.34 AIC · ⌖ 8.74 AIC · ⊞ 4.6K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

COMMENT — I don't see a blocking bug in the changed lines.

Notes

I checked the new schema regex, the parser-side fallback validation, the smoke workflow update, and the added tests. The implementation is internally consistent: uppercase-only suffixes are documented, enforced in schema and Go, and covered by tests; bare numeric sizes still remain accepted as intended.

The only open question I found is product behavior rather than a code defect: the PR discussion asks for normalizing lowercase/trimmed input, but this change intentionally rejects those forms instead of normalizing them. If that behavior is desired, it needs a follow-up design change rather than a review blocker here.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 6.34 AIC · ⌖ 8.74 AIC · ⊞ 4.6K
Comment /review to run again

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds compile-time validation for drive-memory disk sizes and updates the recommended smoke-test size.

Changes:

  • Enforces uppercase K/M/G/T disk-size syntax.
  • Adds tests and drive-size documentation.
  • Regenerates smoke workflow outputs and command routing.
Show a summary per file
File Description
pkg/workflow/schemas/github-workflow.json Reorders the Drives permission.
pkg/workflow/drive_memory_test.go Tests disk-size parsing.
pkg/workflow/drive_memory_config.go Adds parser-side validation.
pkg/parser/schemas/main_workflow_schema.json Constrains disk-size syntax.
docs/src/content/docs/reference/frontmatter-full.md Regenerates schema reference.
docs/src/content/docs/reference/drive-memory.md Documents drive sizing.
.github/workflows/smoke-drive.md Uses the suggested 100M size.
.github/workflows/smoke-drive.lock.yml Regenerates compiled workflow.
.github/workflows/agentic_commands.yml Adds smoke-drive command routing.

Review details

  • Files reviewed: 9/9 changed files
  • Comments generated: 5
  • Review effort level: Balanced

entry.Description = description
}
if diskSize, ok := raw["disk-size"].(string); ok {
if diskSize != "" && !driveDiskSizePattern.MatchString(diskSize) {
Comment on lines +17 to +18
// defaultDriveMemoryDiskSize is the suggested drive size when creating a new drive.
defaultDriveMemoryDiskSize = "100M"

## Drive size

`disk-size` sets the size used when creating a new drive; it is ignored for an existing drive. The value must be a number with an optional `K`, `M`, `G`, or `T` suffix (for example `100M`). Suffixes such as `1GB` are rejected at compile time. A drive of `100M` is enough for typical memory files:
Comment on lines +4170 to +4171
# Drive size used when creating the drive, as a number with an optional K, M, G,
# or T suffix (suggested: '100M'; ignored for an existing drive)
Comment on lines +73 to +75
name: "disk size with invalid suffix",
raw: map[string]any{"disk-size": "1GB"},
wantErr: "invalid drive-memory disk-size",

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: harden + audit

The changes are clean and well-targeted: compile-time validation of disk-size syntax using a regex, updated defaults (1GB100M), docs, schema descriptions, and test coverage.

🟡 Non-blocking suggestion

Zero-byte disk size passes validation — see inline comment on drive_memory_config.go line 152. The regex ^[0-9]+[KMGT]?$ admits "0" and "0M", which are syntactically valid but semantically meaningless (and will fail at runtime). A one-character fix ([1-9][0-9]*) closes this.

✅ What looks good

  • Regex is anchored (^...$), which prevents partial matches.
  • Error message includes the rejected value and an example of a valid one — actionable for users.
  • Lowercase suffix test case (100m) correctly rejected.
  • Schema pattern field mirrors the runtime regex — consistent.
  • Documentation prose accurately describes the constraint.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 28.5 AIC · ⌖ 9.12 AIC · ⊞ 6.2K

Comments that could not be inline-anchored

pkg/workflow/drive_memory_config.go:152

The pattern ^[0-9]+[KMGT]?$ accepts &quot;0&quot;, &quot;0K&quot;, &quot;0M&quot;, etc. — zero-byte disk sizes that pass compile-time validation but would fail at runtime when the drive is created.

Consider tightening to require at least one non-zero leading digit:

var driveDiskSizePattern = regexp.MustCompile(`^[1-9][0-9]*[KMGT]?$`)

This rejects meaningless zero sizes at compile time without changing the accepted valid-size set.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd and /diagnosing-bugs — approving with two minor suggestions.

📋 Key Themes & Highlights

Key Themes

  • Test coverage gap: happy-path tests for individual valid suffixes (K, M, G, T) are absent — only a bare number is tested as valid. A future regex typo in [KMGT] would go undetected.
  • Empty-string guard: the diskSize != "" check inside the validation branch means an explicit empty string is stored silently instead of being treated as absent or rejected.

Positive Highlights

  • ✅ Dual-layer defence: schema pattern + parser-side check catches invalid values regardless of how the config reaches the compiler.
  • ✅ Clear, actionable error message with an embedded example (100M).
  • ✅ Smoke workflow updated consistently in both the markdown and its compiled lock file.
  • ✅ Docs section added with a minimal working example — good discoverability for users hitting the new error.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 30.2 AIC · ⌖ 9.9 AIC · ⊞ 7.6K
Comment /matt to run again

wantErr: "invalid drive-memory disk-size",
},
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The new tests cover rejection cases, but there's no happy-path test for each valid suffix (K, M, G, T). Only a bare number ("500") is tested as valid, so a future regex typo in [KMGT] could break all suffix cases silently.

💡 Suggested additions
{name: "disk size K suffix", raw: map[string]any{"disk-size": "512K"}, wantDrives: 1},
{name: "disk size M suffix", raw: map[string]any{"disk-size": "100M"}, wantDrives: 1},
{name: "disk size G suffix", raw: map[string]any{"disk-size": "10G"},  wantDrives: 1},
{name: "disk size T suffix", raw: map[string]any{"disk-size": "1T"},   wantDrives: 1},

This makes the test suite a living spec for all four accepted suffixes.

@copilot please address this.

entry.Description = description
}
if diskSize, ok := raw["disk-size"].(string); ok {
if diskSize != "" && !driveDiskSizePattern.MatchString(diskSize) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] The diskSize != "" guard means an explicitly empty string passes validation and gets stored. An empty disk-size: "" in YAML is almost certainly a misconfiguration; it would be cleaner to either reject it or treat it as absent.

💡 Suggested fix
if diskSize, ok := raw["disk-size"].(string); ok && diskSize != "" {
    if !driveDiskSizePattern.MatchString(diskSize) {
        return entry, fmt.Errorf(...)
    }
    entry.DiskSize = diskSize
}

This keeps the empty-string path from silently setting a blank disk-size in the emitted YAML.

@copilot please address this.

@github-actions github-actions Bot mentioned this pull request Aug 22, 2026
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot normalize lowercases inputs to the upper case format required by actions, time white space

Addressed in a827b72's follow-up (7b5e3e0): disk-size now trims whitespace and uppercases the suffix before validating/storing, so 100m or 100M normalize to 100M instead of erroring. Schema pattern relaxed accordingly to accept the pre-normalized input.

@pelikhan
pelikhan merged commit 839520e into main Aug 22, 2026
33 checks passed
@pelikhan
pelikhan deleted the copilot/fix-github-actions-job-another-one branch August 22, 2026 14:55
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants