fix(#1459): user-owned consent store gates third-party capability activation; env/cwd in disclosure; loader validator parity (#1473)
This commit is contained in:
@@ -139,3 +139,25 @@ export function findProjectRoot(startDir: string): string {
|
||||
|
||||
return startDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* #1459 (IC-01 / CB-4): THE single canonical derivation of the PROJECT ROOT used to bind/lookup a
|
||||
* project-scope consent record. Install (the CLI/lifecycle RECORD site), the loader (the LOOKUP
|
||||
* site), and `trust revoke` (CB-4) MUST all derive the consent root through this one helper so the
|
||||
* recorded key always matches the looked-up key — otherwise installing from a SUBDIR records consent
|
||||
* at `realpath(subdir)` while the loader looks it up at `realpath(findProjectRoot)` and the freshly
|
||||
* installed cap is immediately INACTIVE (install-then-inactive).
|
||||
*
|
||||
* The rule: `realpath(findProjectRoot(cwd))` (findProjectRoot is total — it returns `cwd` itself when
|
||||
* no project root is found, so there is no null branch), falling back to `path.resolve(cwd)` when the
|
||||
* resolved root cannot be realpath'd (e.g. it does not exist yet). The consent store realpaths
|
||||
* whatever it is given, so passing the SAME logical root from every site is what guarantees the match.
|
||||
*/
|
||||
export function consentProjectRoot(cwd: string): string {
|
||||
const root = findProjectRoot(cwd);
|
||||
try {
|
||||
return fs.realpathSync(root);
|
||||
} catch {
|
||||
return path.resolve(root);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user