mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 12:42:20 +00:00
fix(settings): preserve syntax guard contracts across stack integration
Retain existing merge resolutions for update modes, source-scan failures and external-reader fixtures while replaying the settings layer on the merged inventory. Preserve parent provenance, candidate counts and presentation-test resource bounds. Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 parent
1626461ec1
commit
91b11f62c9
5 files changed
+106
-7
No files matched your search
@@ -23,6 +23,7 @@ export function perCallLimitFailures(
|
||||
/** Parse static registry declarations, including external-reader provenance. */
|
||||
export function parseNumericLimitRegistry(source: string): Array<{
|
||||
name: string;
|
||||
update_mode: "restart";
|
||||
policy: "restart-only" | "per-call";
|
||||
read: "startup" | "per-call" | "construction";
|
||||
reason: string;
|
||||
|
||||
@@ -701,17 +701,20 @@ export const parseNumericLimitRegistry = (source) => {
|
||||
return array.elements.map((element) => {
|
||||
const value = fields(element);
|
||||
const name = text(value, "name");
|
||||
const update_mode = text(value, "update_mode");
|
||||
const policy = text(value, "policy");
|
||||
const read = text(value, "read");
|
||||
const reason = text(value, "reason");
|
||||
if (
|
||||
exactLimit(name) === undefined ||
|
||||
update_mode !== "restart" ||
|
||||
!["restart-only", "per-call"].includes(policy) ||
|
||||
!["startup", "per-call", "construction"].includes(read)
|
||||
)
|
||||
throw new Error(`Invalid numeric limit registry entry ${name}`);
|
||||
const source = value.get("provenance");
|
||||
if (source === undefined) return { name, policy, read, reason };
|
||||
if (source === undefined)
|
||||
return { name, update_mode, policy, read, reason };
|
||||
const provenance = fields(unwrapExpression(source));
|
||||
const kind = text(provenance, "kind");
|
||||
const producer = text(provenance, "source");
|
||||
@@ -728,6 +731,7 @@ export const parseNumericLimitRegistry = (source) => {
|
||||
throw new Error(`Invalid external provenance for ${name}`);
|
||||
return {
|
||||
name,
|
||||
update_mode,
|
||||
policy,
|
||||
read,
|
||||
reason,
|
||||
@@ -814,13 +818,26 @@ export const parseRuntimeSettingEnvironments = (source) => {
|
||||
!ts.isPropertyAssignment(property) ||
|
||||
(!ts.isIdentifier(property.name) &&
|
||||
!ts.isStringLiteral(property.name)) ||
|
||||
property.name.text === "environment",
|
||||
["environment", "updateMode"].includes(property.name.text),
|
||||
);
|
||||
})
|
||||
)
|
||||
throw new Error(
|
||||
"Analysis setting fields must be static named assignments",
|
||||
);
|
||||
const modes = definition.properties.filter(
|
||||
(field) =>
|
||||
ts.isPropertyAssignment(field) &&
|
||||
(ts.isIdentifier(field.name) || ts.isStringLiteral(field.name)) &&
|
||||
field.name.text === "updateMode",
|
||||
);
|
||||
if (
|
||||
modes.length !== 1 ||
|
||||
!["runtime", "restart"].includes(
|
||||
literalText(unwrapExpression(modes[0].initializer)),
|
||||
)
|
||||
)
|
||||
throw new Error("Analysis setting must declare a static updateMode");
|
||||
const fields = definition.properties.filter(
|
||||
(field) =>
|
||||
ts.isPropertyAssignment(field) &&
|
||||
@@ -980,6 +997,59 @@ if (direct) {
|
||||
if (failure !== undefined) failures.push(failure);
|
||||
}
|
||||
|
||||
const parameterOwners = [
|
||||
"src/artifacts/ArtifactReaderLimits.ts",
|
||||
"src/domain/artifactReaderLimits.ts",
|
||||
"src/domain/webNetworkCapture.ts",
|
||||
];
|
||||
for (const relativePath of parameterOwners) {
|
||||
const source = await readFile(join(root, relativePath), "utf8");
|
||||
if (/update_mode:\s*"runtime"/u.test(source))
|
||||
failures.push(
|
||||
`${relativePath} is a per-call parameter, so update_mode cannot be runtime`,
|
||||
);
|
||||
if (!/update_mode:\s*"parameter"/u.test(source))
|
||||
failures.push(`${relativePath} must report update_mode parameter`);
|
||||
}
|
||||
|
||||
const forbidden =
|
||||
/(?<![A-Za-z0-9_])(?:rea_restart_required|restartRequired|restart_required)(?![A-Za-z0-9_])|effect:\s*"(?:immediate|next_process)"|SettingChangeEffect/gu;
|
||||
// Docs and verification receipts keep the field names they recorded.
|
||||
// Source, tests, skills, and scripts cannot reintroduce those names.
|
||||
const scanRoots = ["src", "tests", ".agents", "scripts"].map((dir) =>
|
||||
join(root, dir),
|
||||
);
|
||||
const skipDir = new Set([
|
||||
"node_modules",
|
||||
"dist",
|
||||
".turbo",
|
||||
".cache",
|
||||
"rea-numeric-limits.mjs",
|
||||
]);
|
||||
const listText = async (dir) => {
|
||||
const output = [];
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (skipDir.has(entry.name)) continue;
|
||||
const path = join(dir, entry.name);
|
||||
if (entry.isDirectory()) output.push(...(await listText(path)));
|
||||
else if (/\.(?:ts|tsx|mjs|js|md|json|py|yml|yaml)$/u.test(entry.name))
|
||||
output.push(path);
|
||||
}
|
||||
return output;
|
||||
};
|
||||
for (const dir of scanRoots) {
|
||||
for (const path of await listText(dir)) {
|
||||
if (path.endsWith(`${sep}rea-numeric-limits.mjs`)) continue;
|
||||
const source = await readFile(path, "utf8");
|
||||
const hit = source.match(forbidden);
|
||||
if (hit)
|
||||
failures.push(
|
||||
`${relative(root, path).split(sep).join("/")} still uses ${[...new Set(hit)].join(", ")}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length > 0) {
|
||||
console.error(`Numeric REA_ limit check failed:\n${failures.join("\n")}`);
|
||||
process.exit(1);
|
||||
|
||||
Reference in new issue
Block a user