Skip to content

Task/10322 let the project declare its key prefix - #843

Merged
briemla merged 11 commits into
mainfrom
task/10322-let-the-project-declare-its-key-prefix
Sep 30, 2026
Merged

briemla merged 11 commits into
mainfrom
task/10322-let-the-project-declare-its-key-prefix

Conversation

@randy-seng

Copy link
Copy Markdown
Member

OP#10322

@randy-seng
randy-seng added this pull request to stack #837 September 12, 2026 07:45
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch 2 times, most recently from cbae070 to b32f839 Compare September 14, 2026 14:02
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch from b32f839 to ee076aa Compare September 14, 2026 18:37
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch 2 times, most recently from 522ddd1 to 2f254b4 Compare September 21, 2026 12:46
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch from 2f254b4 to 3e19b46 Compare September 24, 2026 09:44
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch 3 times, most recently from 5dfbf43 to 33a711a Compare September 29, 2026 09:18
Base automatically changed from task/10321-do-not-silently-rebind-otconfig-file-references to main September 29, 2026 09:44
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch from 33a711a to 51c28b4 Compare September 29, 2026 09:44
@randy-seng randy-seng self-assigned this Sep 29, 2026
@randy-seng
randy-seng requested a review from briemla September 29, 2026 14:50
An instance reads from exactly one prefix, fixed at startup by S3_KEY_PREFIX,
so every project it can open must live under that prefix. That is untenable for
the UI Worker, which is handed a different project's otconfig per lease.

The otconfig now carries a top-level `s3_key_prefix`, parsed into an
S3KeyPrefix value object on OtConfig. Reading only, so far: the key is absent
from every file written before this, so a missing key parses to None. Deciding
whether a file may be loaded with a prefix -- or without one -- belongs to
ValidateProjectLocation, which knows what this installation reads from.

The field is defaulted, and has to stay so: OTCloud rebuilds an OtConfig by
keyword and cannot name it until it bumps its OTAnalytics pin.

See docs/adr/0004-project-declares-its-key-prefix.md.
ADR 0004 gives four cases: an s3-mode load needs a prefix, a local-mode load
must not have one, and the two matching cases proceed. ValidateProjectLocation
answers all four without any code asking what the transfer mode is -- the
wiring picks RefuseAnyProjectLocation or RequireWellFormedKeyPrefix, and the
implementation is the answer.

The check sits in LoadOtconfig._begin, after the reset and parse but before
anything is published. A refusal therefore leaves the application exactly as
the reset left it, so all-or-nothing holds without _abort having to undo a
partial load.

A prefix that is absolute or bears `..` is refused too. The bucket is
environment-only, so such a prefix cannot read across buckets, but it does not
describe a location inside the configured one either.

Nothing sets the prefix on save yet, so an s3-mode deployment can currently
open no project at all.
Saving now records where the project's data lives, so a project saved in s3
mode can be reopened there. The prefix is held by CurrentKeyPrefix between
loading a project and saving it: it arrives with the project, not with the
process, and opening another project moves where this instance reads.

The holder is seeded with None and reset with the application, so a prefix
cannot outlive its project and let a save write the previous project's
location. LoadOtconfig sets it in _publish_before_tracks, after _begin's reset
cleared it and before the track files are read from under it.

serialize and convert take the prefix as a required argument, not a defaulted
one. SaveOtconfig and OtconfigHasChanged both call them and must pass the same
value: if only the save side passed it, the written file would carry the key
while convert omitted it, the comparison would never match, and every project
would report itself as permanently unsaved. A default makes that a silent
trap; requiring the argument makes both call sites decide.

A project that names no location writes no key, so a local-mode otconfig is
unchanged.
The providers now list under the prefix the loaded project declares, and
S3_KEY_PREFIX is gone from the environment. An instance is no longer pinned to
one prefix for its lifetime: opening another project moves where it reads,
within the one bucket it may authenticate to.

With no project loaded there is no prefix and nothing to list, so the time-range
dialog is refused and says to load a project first. That is a behaviour change
to slice 6, which offered the dialog at startup, and matches how the worker
runs: a lease starts when an otconfig is delivered.

The acceptance test preloads a project otconfig instead of setting
S3_KEY_PREFIX, which is the same change seen from the outside.

ADR 0003's variable list is marked as the list at the time of that ADR rather
than rewritten: the decision to configure S3 through the environment stands,
only the prefix left it.
The application is configured by environment variables only, and the test
harness started it with `subprocess.Popen` without an `env`, so it inherited
whatever the developer's shell exported. A machine set up for s3 work exports
OTA_DATA_TRANSFER_MODE=s3, which started the local mode tests in s3 mode. Since
`RequireWellFormedKeyPrefix` refuses a prefix-less otconfig, every config in
tests/data was rejected, the load aborted, and four tests timed out waiting for
a UI that never arrived -- while the same tests passed on CI, where no such
variable exists.

`local_filesystem_environment` drops the transfer mode variables and keeps the
rest, so a local mode test says which mode it wants. The s3 fixture builds on
it through `s3_environment`, which also stops a stray OTA_S3_REGION or
OTA_S3_DOWNLOAD_CONCURRENCY from reaching an application the test believes it
configured itself.
@randy-seng
randy-seng force-pushed the task/10322-let-the-project-declare-its-key-prefix branch from 640af34 to e9f2830 Compare September 29, 2026 15:40
@briemla
briemla merged commit 52934cb into main Sep 30, 2026
17 checks passed
@briemla
briemla deleted the task/10322-let-the-project-declare-its-key-prefix branch September 30, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants