Skip to content

Commit 2a8b458

Browse files
Verify CAP-004's docs against the implementation; provenance: verified
Human review (Flemming N. Larsen) re-read CAP-004/README.md, criteria.md, design.md, and C-005 against the shipped RobotData/ RobocodeFileOutputStream code. Found and fixed one carried-over inaccuracy from before the FIO-001 wording narrowed: README.md and RobotData's own Javadoc still said "absolute path" is re-rooted -- only a root-relative name is; a true drive-letter-absolute name fails the write on both engines instead, as design.md and C-005 already correctly stated. Corrected both, then promoted all four documents' provenance from inferred to verified, clearing clue validate's ADR-035 activation gate (now OK: CAP-004 covered/partial as declared, no remaining high-cost inferred blockers). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GShGLuFwRpnWNY2WL5Vz5
1 parent cb85d8c commit 2a8b458

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

docs/capabilities/CAP-004-robot-file-io-sandboxing/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ status: active
55
links: [G-001, C-005, IDR-007]
66
goal: G-001
77
title: Robot file I/O sandboxing
8-
provenance: inferred
8+
provenance: verified
99
reversal-cost: high
1010
---
1111

1212
# CAP-004 — Robot file I/O sandboxing
1313

14-
Classic Robocode confines everything a robot writes, through its own data-file API, to that robot's own data directory. A robot that opens an absolute path gets a file inside its data directory instead, and never learns the difference. This capability is that redirection, implemented at the one point the bridge controls: `RobotData.getDataFile`/`getDataDirectory`.
14+
Classic Robocode confines everything a robot writes, through its own data-file API, to that robot's own data directory. A robot that opens a root-relative path gets a file inside its data directory instead, and never learns the difference. This capability is that redirection, implemented at the one point the bridge controls: `RobotData.getDataFile`/`getDataDirectory`.
1515

1616
## Why it exists as its own capability
1717

1818
Robots depend on the redirection, and the dependency is invisible in their source. A robot that saves its learned targeting data to a root path is not misbehaving — it is a robot whose author relied on the engine to place the file, correctly, because under classic the engine always did. One such bot in the collection produced access-denied errors in the thousands over a single battle before this capability existed, and its behaviour under the bridge was not a degraded version of its classic behaviour but a different robot: one whose learning never persisted.
1919

2020
## What it covers
2121

22-
Path confinement inside `getDataFile`/`getDataDirectory` — asterisks stripped and a `java.io.File` merge used so an absolute or root-relative name is re-rooted inside the directory rather than overriding it, `..` rejected exactly as classic rejects it — plus the 200000-byte quota classic enforces on a robot's data directory.
22+
Path confinement inside `getDataFile`/`getDataDirectory` — asterisks stripped, `..` rejected in the stripped name (stricter than classic's own check order, for safety — see `design.md`), and a `java.io.File` merge used so a root-relative name is re-rooted inside the directory rather than overriding it (a true drive-letter-absolute name fails the write on both engines instead) — plus the 200000-byte quota classic enforces on a robot's data directory.
2323

2424
## What it does not cover
2525

docs/capabilities/CAP-004-robot-file-io-sandboxing/criteria.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: active
55
links: [CAP-004]
66
title: Robot file I/O sandboxing — acceptance criteria
77
ac-prefix: FIO
8-
provenance: inferred
8+
provenance: verified
99
reversal-cost: high
1010
---
1111

docs/capabilities/CAP-004-robot-file-io-sandboxing/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type: design
44
status: active
55
links: [CAP-004, IDR-002, IDR-007, ARCH-002, C-005]
66
title: Robot file I/O sandboxing — design
7-
provenance: inferred
7+
provenance: verified
88
reversal-cost: high
99
---
1010

docs/constraints/C-005-robot-file-io-confined-to-data-directory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ links: [CAP-004]
66
title: A robot reads and writes only inside its own data directory
77
source: Classic Robocode's robot sandbox, which every rumble robot was written against
88
enforcement: partial
9-
provenance: inferred
9+
provenance: verified
1010
reversal-cost: high
1111
---
1212

robocode-api/src/main/java/dev/robocode/tankroyale/bridge/RobotData.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ public static File getDataDirectory() {
4545
/**
4646
* Resolves a robot-supplied filename against the data directory, matching classic's
4747
* {@code RobotFileSystemManager.getDataFile}: asterisks are stripped, and a {@code java.io.File}
48-
* merge is used rather than {@code java.nio.file.Path#resolve} so an absolute or root-relative
49-
* name is re-rooted inside the directory instead of overriding it outright.
48+
* merge is used rather than {@code java.nio.file.Path#resolve} so a root-relative name is
49+
* re-rooted inside the directory instead of overriding it outright. A true drive-letter-absolute
50+
* name (e.g. {@code C:\...} on Windows) is not re-rooted by this merge, matching classic; the
51+
* write then fails rather than escaping the directory.
5052
*
51-
* @throws AccessControlException if filename contains "..", matching classic's
53+
* @throws AccessControlException if the name contains "..", matching classic's
5254
* {@code AdvancedRobotProxy.getDataFile}.
5355
*/
5456
public static File getDataFile(String filename) {

0 commit comments

Comments
 (0)