Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ would have caught the breaks before they reached main.
| Parent sprint | [[id:850C1BC8-FE02-4EE0-A5D6-6085DC34CE27][Sprint 1]] |
| Now | =compass blames=, =check= and the git hooks show the open reports, the current environment's first and marked; the folder is analysed and three checks are proposed. The service query and the environment naming remain. |
| Waiting on | Nothing. |
| Next | Serve the open reports over HTTP and MCP; unify the environment names. |
| Last touched | 2026-12-04 |
| Next | Serve the open reports over HTTP and MCP. |
| Last touched | 2026-12-05 |

* Acceptance

Expand All @@ -69,7 +69,7 @@ would have caught the breaks before they reached main.
| [[id:686B61EC-0AD8-4AEB-ADA7-1F9EAB504AC6][List the open blame reports]] | DONE | 2026-11-29 | 2026-12-04 | A compass blames command that lists the open reports of the types a project names, the current environment's first and marked, and the same short summary from check and the git hooks. |
| [[id:62A4D200-9C15-4D37-A47C-CB593BD51D64][Analyse the blame reports during the sprint]] | DONE | | 2026-12-04 | Read the blame folder at points during the sprint, class the breaks it records, and find the proactive checks that would have caught them before they reached main. |
| [[id:BFCA17AF-5BDD-4B4B-8B07-5325F191C472][Serve the open blame reports]] | BACKLOG | | | Answer the open reports over the document service, as an HTTP read route and an MCP tool generated from the route models, so agents that read compass through it see them too. |
| [[id:8DFD6766-E279-4496-AAE6-A9CD7AC6457A][Unify environment names]] | BACKLOG | | | Give an environment one name everywhere compass and its projects state one, by a migration that renames corpus.environment.name and the environment columns of activity in one transaction, not by naming it differently on the next sync. |
| [[id:8DFD6766-E279-4496-AAE6-A9CD7AC6457A][Unify environment names]] | DONE | 2026-12-05 | 2026-12-05 | Give an environment one name everywhere compass and its projects state one, by a migration that renames corpus.environment.name and the environment columns of activity in one transaction, not by naming it differently on the next sync. |

* Decisions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#+level: s1
#+filetags: :blame:db:environment:surface_the_open_blame_reports:sprint_01:v0:
#+owner: marco
#+branch:
#+pr:
#+branch: agile/unify-on-the-short-name
#+pr: 279
#+blocked_on:
#+blocked_since:
#+created: 2026-11-29
Expand Down Expand Up @@ -43,22 +43,42 @@ whether =#+owner_prefix:= then goes.

| Field | Value |
|--------------+----------------------------------------|
| State | BACKLOG |
| State | DONE |
| Parent story | [[id:1874A6CC-3640-4A89-B07F-C9A5F6AAD5F2][Surface the open blame reports]] |
| Now | Not yet started. |
| Now | Done: the short name wins, and the rename travels with the checkout on its next sync. |
| Waiting on | Nothing. |
| Next | Begin implementation. |
| Last touched | 2026-11-29 |
| Next | Nothing. |
| Last touched | 2026-12-05 |

* Acceptance

-
- An environment is named by its checkout's directory less the project's
=#+owner_prefix:=; a directory without the prefix keeps its whole name, and
a name given with =--environment= or =#+environment:= is taken as given.
- The name is computed the same way by sync, the git hooks, test export,
serve and =blames=.
- A checkout synced under its old, prefixed name is renamed to the short one
on its next sync, in one transaction, with the =activity.campaign=,
=activity.action=, =test.scenario= and =agent.agent_session= rows that
name the old environment moved with it.
- An open report is the environment's when its owner names the environment
whole; the prefix no longer bridges the two.

* Plan

(Implementation strategy. Written when work starts; key decisions
are distilled into the parent story's =* Decisions= at close, but the
plan itself stays — it is the historical record of what we did.)
1. Name the environment in =config::environment_name= as the checkout's
directory less the project's prefix, which every caller already computes
the name with; the callers that did not read the configuration file now
pass its prefix.
2. Rename in the database rather than in a migration: the schema does not
change, and a migration cannot know a project's prefix. =write_environment=
finds the row with the same =root= whose name is the new name with a
prefix, and moves the row and the four text =environment= columns to the
new name in the sync's transaction. A different name chosen for the same
checkout is left alone.
3. Drop the prefix fallback from =blames=' ownership match.
4. Test the naming, the rename across the four tables, and that a stale
long name owns nothing.

* Measurements

Expand All @@ -72,10 +92,23 @@ task and name that file in the Command column.

| What | Value | Command | Commit |
|------+-------+---------+--------|
| | | | |
| =compass.cli.tests= | 2758 assertions in 267 cases | =compass.cli.tests= | this branch |
| =compass.db.tests= | 1307 assertions in 175 cases | =compass.db.tests= | this branch |
| Naming | the directory less =#+owner_prefix:= | =config::environment_name= | this branch |

* Notes

- *The short name wins.* The product owner chose it on 2026-12-05: the
environment is =eager_maxwell=, not =ores_dev_eager_maxwell=, so it matches
the name ORE Studio's =Environment= trailer and its blame reports use.
- *A rename at sync, not a migration.* The schema does not change, and the
migration SQL cannot read a project's =#+owner_prefix:=. The sync knows both
the checkout's root and the name it computed, so it carries the record
forward in its own transaction. A migration would have needed the prefix
baked into SQL that is the same for every project.
- *The prefix stays, with one meaning.* It is how a checkout's directory maps
to its environment's name; it no longer bridges owner fields in reports.

* Test Scenarios

Manual QA scenarios (scaffolded via =compass add test_scenario=)
Expand All @@ -100,3 +133,12 @@ via its "Verifies task" field.
| | | | | |

* Result

The environment's name is the checkout directory less the project's prefix.
Sync, the hooks, test export, serve and =blames= all compute it the same way,
and =serve= renames a checkout's environment to it on its next start. The
rename moves =corpus.environment= and the four text =environment= columns in
the sync's transaction; the test seeds one row in each and asserts the single
renamed environment. Ownership in =blames= is now a whole-name match, and the
tests cover the short name, the prefix edge cases and that a stale long name
owns nothing.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void write_local_setting(const std::filesystem::path& file,
*/
[[nodiscard]] std::string environment_name(
const std::filesystem::path& checkout, const local_settings& s,
std::string_view given);
std::string_view given, std::string_view owner_prefix = {});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ inline constexpr std::string_view repository_file_name = ".compass.org";
* with other than four cells, no type or owner, a type named twice or
* another surface is an error.
*
* #+owner_prefix: is the prefix an environment's name carries that the
* owner fields of the reports leave out: with ores_dev_, an owner
* eager_maxwell is the environment ores_dev_eager_maxwell. Only the open
* reports read it; it renames no environment.
* #+owner_prefix: is the prefix a checkout's directory carries that its
* environment's name leaves out: with ores_dev_, the checkout
* ores_dev_eager_maxwell is the environment eager_maxwell. The open
* reports' owner fields name environments whole.
*/
[[nodiscard]] std::expected<types::layer, std::string> parse_repository_file(
std::string_view text, std::string_view label);
Expand Down
4 changes: 2 additions & 2 deletions projects/compass.cli/include/compass.cli/ops/open_reports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace compass::cli::ops {
* and it is not evidence. It is open when the State row of its * Status
* table holds one of the kind's open states. Its owners are the names in
* the row of the kind's owner field, and it is owned when one of them is
* @p environment, whole, or is @p environment less @p owner_prefix: with
* @p environment, whole:
* the prefix ores_dev_, the owner eager_maxwell is the environment
* ores_dev_eager_maxwell, and maxwell is neither. Without the kind's open
* states, the open states are those of every #+todo: line of the page,
Expand All @@ -77,7 +77,7 @@ namespace compass::cli::ops {
[[nodiscard]] types::open_reports select_open_reports(
std::span<const types::report_kind> kinds,
const codec::types::corpus& corpus, std::string_view environment,
std::string_view owner_prefix, std::chrono::year_month_day today);
std::chrono::year_month_day today);

}

Expand Down
3 changes: 2 additions & 1 deletion projects/compass.cli/src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ std::expected<types::options, std::vector<std::string>> options_of(
c.warnings.push_back(local.error() + "; the environment is "
"named by its directory");
environment = config::environment_name(i.checkout,
local ? *local : config::local_settings{}, i.environment);
local ? *local : config::local_settings{}, i.environment,
file->owner_prefix);
}
return types::options{.which = i.which,
.checkout = i.checkout,
Expand Down
20 changes: 16 additions & 4 deletions projects/compass.cli/src/app/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "compass.cli/app/sync.hpp"
#include "compass.cli/app/test_export.hpp"
#include "compass.cli/config/local_settings.hpp"
#include "compass.cli/config/repository_file.hpp"
#include "compass.cli/io/listing.hpp"
#include "compass.db/io/connection.hpp"
#include "compass.db/io/corpus.hpp"
Expand Down Expand Up @@ -333,6 +334,15 @@ int run_db(const types::invocation& i, std::ostream& out,
return exit_failure;
}

/**
* @brief The prefix the project's checkout directories carry, which its
* environments' names leave out.
*/
std::string owner_prefix_of(const fs::path& checkout) {
const auto layer = config::read_repository_file(checkout);
return layer ? layer->owner_prefix : std::string{};
}

int run_sync(const types::invocation& i, std::ostream& out,
std::ostream& err) {
try {
Expand All @@ -343,7 +353,7 @@ int run_sync(const types::invocation& i, std::ostream& out,
r.checkout = i.checkout;
r.threads = i.threads;
r.environment = config::environment_name(i.checkout, s,
i.environment);
i.environment, owner_prefix_of(i.checkout));
if (!i.revision.empty())
r.commit = io::resolve_commit(i.checkout, i.revision);
const auto report = sync_environment(c, r);
Expand All @@ -362,7 +372,7 @@ int run_test(const types::invocation& i, std::ostream& out,
auto c = connect(s);
db::io::require_current(c);
const auto environment = config::environment_name(i.checkout, s,
i.environment);
i.environment, owner_prefix_of(i.checkout));
const auto r = export_campaigns(c, i.checkout, environment,
i.test.story);
if (i.test.story && r.campaigns == 0 && r.skipped.empty()) {
Expand Down Expand Up @@ -400,7 +410,8 @@ void sync_after_run(const fs::path& checkout, unsigned threads, bool timings,
sync_request r;
r.checkout = checkout;
r.threads = threads;
r.environment = config::environment_name(checkout, s, {});
r.environment = config::environment_name(checkout, s, {},
owner_prefix_of(checkout));
const auto report = sync_environment(c, r);
if (timings)
write_sync(err, report, true);
Expand All @@ -421,7 +432,8 @@ void sync_after_edit(const fs::path& checkout, std::string_view path,
auto c = connect(s);
db::io::require_current(c);
const auto report = sync_file(c, checkout,
config::environment_name(checkout, s, {}), path);
config::environment_name(checkout, s, {},
owner_prefix_of(checkout)), path);
if (timings)
write_sync(err, report, false);
else
Expand Down
8 changes: 4 additions & 4 deletions projects/compass.cli/src/app/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,13 +1844,13 @@ types::check_result check(const types::options& o) {
r.blame = blame(o, r.findings, document_ids_of(p), p.run.record);
if (!o.commit)
r.open = ops::select_open_reports(o.report_kinds, p.corpus,
o.environment, o.owner_prefix, o.today);
o.environment, o.today);
return r;
}

types::open_reports open_reports(const types::options& o) {
if (o.report_kinds.empty())
return ops::select_open_reports({}, {}, o.environment, {}, o.today);
return ops::select_open_reports({}, {}, o.environment, o.today);
listing l;
list(l, o.checkout);
auto files = open_files(o.checkout,
Expand All @@ -1860,7 +1860,7 @@ types::open_reports open_reports(const types::options& o) {
load(files, o.threads);
return ops::select_open_reports(o.report_kinds,
corpus_of(files, org::types::type_registry{}), o.environment,
o.owner_prefix, o.today);
o.today);
}

types::check_result blame_one(const types::options& o,
Expand Down Expand Up @@ -2357,7 +2357,7 @@ types::ratchet_result ratchet(const types::options& o,
if (!r.current.run.failed())
r.provenance = provenance_of(p, o, r.merge_base, head);
r.current.open = ops::select_open_reports(o.report_kinds, p.corpus,
o.environment, o.owner_prefix, o.today);
o.environment, o.today);
auto at_base = o;
at_base.commit = r.merge_base;
// A codec HEAD's configuration enables may need files the merge base
Expand Down
4 changes: 3 additions & 1 deletion projects/compass.cli/src/app/serve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ http::app::environment_sync environment_sync_of(const fs::path& checkout,
sync_request r;
r.checkout = checkout;
r.threads = threads;
r.environment = config::environment_name(checkout, s, {});
const auto layer = config::read_repository_file(checkout);
r.environment = config::environment_name(checkout, s, {},
layer ? layer->owner_prefix : std::string{});
auto name = r.environment;
return {std::move(name), [r = std::move(r), database = s.database] {
db::io::connection c(database);
Expand Down
11 changes: 9 additions & 2 deletions projects/compass.cli/src/config/local_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,22 @@ void write_local_setting(const fs::path& file, std::string_view key,
}

std::string environment_name(const fs::path& checkout,
const local_settings& s, std::string_view given) {
const local_settings& s, std::string_view given,
std::string_view owner_prefix) {
if (!given.empty())
return std::string(given);
if (!s.environment.empty())
return s.environment;
auto name = checkout.filename();
if (name.empty())
name = checkout.parent_path().filename();
return name.string();
auto text = name.string();
// The directory a worktree lives in carries the project's prefix; the
// environment's name is what follows it.
if (!owner_prefix.empty() && text.size() > owner_prefix.size() &&
text.starts_with(owner_prefix))
text.erase(0, owner_prefix.size());
return text;
}

}
9 changes: 2 additions & 7 deletions projects/compass.cli/src/ops/open_reports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ std::vector<std::string> open_states(std::string_view source,
types::open_reports select_open_reports(
std::span<const types::report_kind> kinds,
const codec::types::corpus& corpus, std::string_view environment,
std::string_view owner_prefix, std::chrono::year_month_day today) {
std::chrono::year_month_day today) {
types::open_reports out;
out.environment = std::string(environment);
out.configured = !kinds.empty();
Expand Down Expand Up @@ -229,12 +229,7 @@ types::open_reports select_open_reports(
"not an environment's name; fix: write each owner bare, "
"separated by commas");
r.owned = std::ranges::any_of(r.owners,
[&](const std::string& o) {
return o == environment || (!owner_prefix.empty() &&
environment.size() == owner_prefix.size() + o.size() &&
environment.starts_with(owner_prefix) &&
environment.ends_with(o));
});
[&](const std::string& o) { return o == environment; });
if (const auto created = codec::ops::parse_date(
keyword(source, tables, "created")))
r.age = static_cast<int>((std::chrono::sys_days(today) -
Expand Down
6 changes: 3 additions & 3 deletions projects/compass.cli/tests/app_blames_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ TEST_CASE("blames says none, not 0, when this environment owns no open "
"the owners named answer their own\n"));
}

TEST_CASE("the owner prefix gives a checkout the reports of its name less "
"the prefix, and names the environment as sync does",
TEST_CASE("the owner prefix names the environment, and a report is "
"its own when the owner names it whole",
"[app][blames]") {
const blamed_repo b("#+owner_prefix: check\n" + std::string(codecs) +
std::string(open_reports));
Expand All @@ -237,7 +237,7 @@ TEST_CASE("the owner prefix gives a checkout the reports of its name less "

CHECK(r.status == app::exit_success);
CHECK(r.out ==
"open reports: 1 of the 3 open is owned by checkout, this "
"open reports: 1 of the 3 open is owned by out, this "
"environment:\n"
"* STARTED 1d doc/blame/out/blame_report.org: Blame: out of space\n"
"open reports: next: read each one marked *, answer it, and close "
Expand Down
22 changes: 22 additions & 0 deletions projects/compass.cli/tests/config_precedence_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "compass.cli/config/local_settings.hpp"
#include "compass.cli/config/precedence.hpp"

#include <array>
#include <filesystem>
#include <cstdint>
#include <string>
#include <vector>
Expand Down Expand Up @@ -130,3 +132,23 @@ TEST_CASE("a setting that matches no codec or option is a problem naming "
"'perhaps'; fix: set it to true or false");
CHECK(c.codecs[0].enabled.value == "true");
}

TEST_CASE("an environment is named by its directory less the project's "
"prefix", "[config][environment]") {
const auto checkout = std::filesystem::path("/src/ores_dev_eager_maxwell");
const config::local_settings none;
CHECK(config::environment_name(checkout, none, {}, "ores_dev_") ==
"eager_maxwell");
// A directory without the prefix keeps its whole name, as does a name
// given on the command line or in the settings.
CHECK(config::environment_name(checkout, none, {}, "") ==
"ores_dev_eager_maxwell");
CHECK(config::environment_name(checkout, none, {}, "ores_") ==
"dev_eager_maxwell");
CHECK(config::environment_name(checkout, none, "given", "ores_dev_") ==
"given");
config::local_settings stated;
stated.environment = "from_settings";
CHECK(config::environment_name(checkout, stated, {}, "ores_dev_") ==
"from_settings");
}
Loading
Loading