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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filegrc-monorepo",
"version": "0.21.9",
"version": "0.21.10",
"private": true,
"workspaces": [
"packages/filegrc",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-filegrc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-filegrc",
"version": "0.21.9",
"version": "0.21.10",
"description": "Create a filegrc workspace for a SOC 2 program",
"license": "MIT",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-filegrc/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,13 @@ async function runCombinedSetup(target, input) {
async function writeMinimalLockfile(target, name, versionRange) {
const lock = {
name,
version: "0.21.9",
version: "0.21.10",
lockfileVersion: 3,
requires: true,
packages: {
"": {
name,
version: "0.21.9",
version: "0.21.10",
dependencies: { filegrc: versionRange }
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-filegrc/template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "{{project_name}}",
"version": "0.21.9",
"version": "0.21.10",
"private": true,
"description": "filegrc workspace for a SOC 2 program",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/filegrc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filegrc",
"version": "0.21.9",
"version": "0.21.10",
"description": "Zero-dependency Git-native GRC engine",
"license": "MIT",
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions packages/filegrc/src/obligation-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ export function recordedCorrectionPopulation(loaded, occurrence, rule) {
};
}

export function retainedCorrectionSource(loaded, occurrence) {
if (occurrence?.status !== "superseded") return false;
// The successor binds the unchanged, previously open source to Git history.
// Its former cutoff must not later require a review that never governed it.
return loaded.resources.some((candidate) => {
if (candidate.type !== "obligation-occurrence" || !candidate.populationSourceRevision) return false;
const rule = loaded.resources.find((record) => record.id === candidate.ruleId);
return recordedCorrectionPopulation(loaded, candidate, rule)?.source.id === occurrence.id;
});
}

export function currentSnapshotPopulation(loaded, occurrence, rule) {
if (
!loaded.root ||
Expand Down
7 changes: 4 additions & 3 deletions packages/filegrc/src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { reviewHistoricalWorkspace, reviewHistoryContext } from "./historical-wo
import { reclassifyTemporalValidation } from "./temporal-diagnostics.js";
import { workspaceEngineVersion, runtimeCompatibilityLine } from "./runtime-version.js";
import { workflowSourceRuntimeIssues } from "./workflow-source-runtime.js";
import { recordedCorrectionPopulation, currentSnapshotPopulation, samePopulation } from "./obligation-snapshot.js";
import { recordedCorrectionPopulation, retainedCorrectionSource, currentSnapshotPopulation, samePopulation } from "./obligation-snapshot.js";
import { populationCutoffDate, wholePeriodCoverage, requiredPeriodIsFinal, wholePeriodRuleWindowIssue, wholePeriodOccurrenceWindowIssue } from "./obligation-timing.js";
import { occurrenceSelectorPopulation } from "./obligation-population.js";
import { occurrenceCompletionContext } from "./obligation-completion-context.js";
Expand Down Expand Up @@ -659,6 +659,7 @@ function validateObligationOccurrence(record, model, resources, entries, root, w
const loaded = { root, resources, model };
const correctionPopulation = recordedCorrectionPopulation(loaded, record, rule);
const snapshotPopulation = currentSnapshotPopulation(loaded, record, rule);
const retainedSource = retainedCorrectionSource(loaded, record);
if (rule?.selector?.cutoff === "review-date") {
if (!correctionPopulation && !snapshotPopulation && !record.collectionReviewId) diagnostics.push(error("missing-obligation-snapshot-source", path, "A review-date snapshot needs its exact committed scope, retained correction source or immutable temporal Collection Review."));
if (!parseCalendarDate(record.membershipCutoffAt) || record.membershipCutoffAt < record.coverage?.startsOn
Expand Down Expand Up @@ -712,13 +713,13 @@ function validateObligationOccurrence(record, model, resources, entries, root, w
"A historical occurrence must bind the exact immutable Collection Review revision, scope, cutoff coverage, and reviewed population."
));
}
} else if (rule?.selector && record.membershipCutoffAt < asOf) {
} else if (rule?.selector && record.membershipCutoffAt < asOf && !retainedSource) {
diagnostics.push(error(
"missing-obligation-population-provenance",
path,
"A historical occurrence must bind an immutable Collection Review for its exact population cutoff."
));
} else if (rule?.selector) {
} else if (rule?.selector && !retainedSource) {
const population = occurrenceSelectorPopulation({ root, resources, model }, record, rule.selector, byId.get(record.programId));
const missingRecorded = population.memberIds.some((id) => !memberIds.includes(id));
const unsupported = memberIds.some((id) => !population.expectedIds.includes(id));
Expand Down
23 changes: 23 additions & 0 deletions packages/filegrc/test/obligation-snapshot-correction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ test("reviewed successor preserves the original window, historic proof and manag
);
});

test("retained open correction sources stay valid after their former cutoff without weakening provenance", async (t) => {
const f = await fixture(t);
await snapshotSuccessor(f);
const loaded = await loadWorkspace(f.root);
const source = loaded.entries.find(({ record }) => record.id === f.occurrence.id);
const successor = loaded.entries.find(({ record }) => record.supersedesId === source.record.id);
const afterCutoff = new Date(`${addCalendarDays(source.record.membershipCutoffAt, 1)}T18:00:00Z`);
t.mock.timers.enable({ apis: ["Date"], now: afterCutoff });
const missingSource = async () => (await validateWorkspace(f.root)).diagnostics.some(
({ code, path }) => code === "missing-obligation-population-provenance" && path.endsWith(`${source.record.id}.json`),
);
assert.equal(await missingSource(), false);

await writeJson(source.path, { ...source.record, title: "Altered retained source" });
assert.equal(await missingSource(), true, "A changed historical source must not inherit the successor's proof.");
await writeJson(source.path, source.record);
await writeJson(successor.path, { ...successor.record, populationSourceRevision: "0".repeat(40) });
assert.equal(await missingSource(), true, "An unsupported successor cannot excuse missing historical provenance.");
await writeJson(successor.path, successor.record);
await rm(successor.path);
assert.equal(await missingSource(), true, "Superseded status alone must not bypass the cutoff requirement.");
});

test("snapshot correction rejects changed duties, backdating, stale confirmation and whole-period downgrades", async (t) => {
const f = await fixture(t);
let p = await scaffoldObligationRuleCorrection(f.root, { ruleId: f.rule.id });
Expand Down
Loading