Make the agent's scope a line of its own: Only roles in Europe, chosen countries or Everywhere, read and written as the require gate on country

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 15:31:40 +02:00
1 parent 1c7bc72198
commit 888586c29b
5 files changed
+179 -95

No files matched your search

+56 -32
View File
@@ -31,22 +31,15 @@ test("the badge leaves the other words as they are, and a role with none blank",
assert.equal(rh.remoteBadge(null), "");
});
test("a suggestion is offered to the remote line as a country, a region or Anywhere", () => {
test("a suggestion is offered to the remote line as a country or a region only", () => {
assert.equal(rh.fromSuggestion({ token: "country:DK", kind: "country" }), "country:DK");
assert.equal(rh.fromSuggestion({ token: "country:EU", kind: "country" }), "country:EU");
assert.equal(rh.fromSuggestion({ token: "region:oresund", kind: "region" }), "region:oresund");
assert.equal(rh.fromSuggestion({ token: "remote:anywhere", kind: "remote" }), "anywhere");
assert.equal(rh.fromSuggestion({ token: "remote:any", kind: "remote" }), null);
assert.equal(rh.fromSuggestion({ token: "remote:country:DK", kind: "remote" }), null);
assert.equal(rh.fromSuggestion({ token: "place:1", kind: "place" }), null);
});
test("Anywhere is offered for the words that start it", () => {
assert.equal(rh.offersAnywhere("any"), true);
assert.equal(rh.offersAnywhere(" World"), true);
assert.equal(rh.offersAnywhere("den"), false);
assert.equal(rh.offersAnywhere(""), false);
});
test("a value has a label before the server has said it", () => {
assert.equal(label("anywhere"), "Anywhere");
assert.equal(label("country:DK"), "Denmark");
@@ -65,46 +58,77 @@ test("the sentence lists the areas, and says anywhere in lower case", () => {
const older = { field: "remote", values: ["remote"], mode: "any" };
const from = (...values) => ({ field: "remote_from", values, mode: "any" });
const hybrid = { field: "remote", values: ["hybrid"], mode: "prefer", weight: 0.05 };
const europe = { field: "country", values: ["DK", "SE", "EU"], mode: "require" };
const dk = { field: "country", values: ["DK"], mode: "any" };
const must = (...values) => ({ field: "country", values, mode: "require" });
const europe = must(...rh.EUROPE);
test("no remote gate: the remote line is empty", () => {
const { where, rest } = rh.distribute([{ field: "country", values: ["DK"], mode: "any" }, hybrid]);
assert.equal(where.remote, null);
assert.equal(where.hybrid, hybrid);
test("no gates: everywhere, no remote", () => {
const { where, rest } = rh.distribute([]);
assert.deepEqual(where.scope, { kind: "everywhere", values: [] });
assert.deepEqual(where.remote, { mode: "none", values: [] });
assert.deepEqual(rest, []);
});
test("a remote_from gate loads into the remote line", () => {
const { where, rest } = rh.distribute([from("country:DK", "anywhere")]);
assert.deepEqual(where.remote, { values: ["country:DK", "anywhere"] });
test("the Europe list is the Europe scope", () => {
const { where, rest } = rh.distribute([europe, dk, older]);
assert.equal(where.scope.kind, "europe");
assert.equal(where.countries.values[0], "DK");
assert.deepEqual(rest, []);
});
test("the older remote gate loads as remote from Anywhere", () => {
const { where, rest } = rh.distribute([older]);
assert.deepEqual(where.remote, { values: ["anywhere"] });
test("Europe with the countries line added is still the Europe scope", () => {
const us = { field: "country", values: ["US"], mode: "any" };
const { where } = rh.distribute([must(...rh.europeWith(["US"])), us]);
assert.equal(where.scope.kind, "europe");
// The same gate without the line's country is not exactly Europe: chips.
assert.equal(rh.distribute([europe, us]).where.scope.kind, "countries");
});
test("any other require gate on country is the scope with its codes as chips", () => {
const { where, rest } = rh.distribute([must("DK", "SE"), dk]);
assert.deepEqual(where.scope, { kind: "countries", values: ["DK", "SE"] });
assert.deepEqual(rest, []);
});
test("a remote_from gate wins over the older one, which stays a row", () => {
test("a second or weighted require gate on country stays a row", () => {
const second = must("NO");
const weighted = { ...must("DE"), weight: 2 };
const { where, rest } = rh.distribute([europe, second, weighted]);
assert.equal(where.scope.kind, "europe");
assert.deepEqual(rest, [second, weighted]);
});
test("a require gate on another field is a row and leaves the scope everywhere", () => {
const level = { field: "seniority", values: ["senior"], mode: "require" };
const { where, rest } = rh.distribute([level]);
assert.equal(where.scope.kind, "everywhere");
assert.deepEqual(rest, [level]);
});
test("remote, three modes: the plain gate is within the scope", () => {
const scope = rh.distribute([older, hybrid]);
assert.deepEqual(scope.where.remote, { mode: "scope", values: [] });
assert.equal(scope.where.hybrid, hybrid);
assert.deepEqual(scope.rest, []);
assert.deepEqual(rh.distribute([hybrid]).where.remote, { mode: "none", values: [] });
const named = rh.distribute([from("country:DK", "region:oresund")]);
assert.deepEqual(named.where.remote, { mode: "from", values: ["country:DK", "region:oresund"] });
assert.deepEqual(named.rest, []);
});
test("a remote_from gate wins over the plain one, which stays a row", () => {
for (const gates of [[older, from("country:DK")], [from("country:DK"), older]]) {
const { where, rest } = rh.distribute(gates);
assert.deepEqual(where.remote, { values: ["country:DK"] });
assert.deepEqual(where.remote, { mode: "from", values: ["country:DK"] });
assert.deepEqual(rest, [older]);
}
});
test("the within Europe must is a row, kept whole", () => {
const { where, rest } = rh.distribute([europe, older]);
assert.deepEqual(where.remote, { values: ["anywhere"] });
assert.deepEqual(rest, [europe]);
});
test("a second remote_from gate, a weighted one or a must stays a row", () => {
const second = from("country:SE");
const weighted = { ...from("country:DE"), weight: 2 };
const must = { field: "remote_from", values: ["country:DK"], mode: "require" };
const { where, rest } = rh.distribute([from("country:DK"), second, weighted, must]);
assert.deepEqual(where.remote, { values: ["country:DK"] });
assert.deepEqual(rest, [second, weighted, must]);
const required = { field: "remote_from", values: ["country:DK"], mode: "require" };
const { where, rest } = rh.distribute([from("country:DK"), second, weighted, required]);
assert.deepEqual(where.remote, { mode: "from", values: ["country:DK"] });
assert.deepEqual(rest, [second, weighted, required]);
});