@ai-matrx/records 0.73.0 → 0.73.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -219,6 +219,13 @@ declare function attachmentProblems(raw: TemplateSpec & {
219
219
  declare function validateTemplate(raw: TemplateSpec, options?: ValidateOptions): TemplateVerdict;
220
220
  /** Validate and throw with every problem. A waiting template does not throw — it is held, not broken. */
221
221
  declare function assertTemplate(spec: TemplateSpec, options?: ValidateOptions): TemplateVerdict;
222
+ /**
223
+ * The lowest sensitivity the store accepts for a field, by what it holds: "restricted" (kept from the AI:
224
+ * an identity or health fact about a person, a code, a card or bank number, privileged notes),
225
+ * "confidential" (it reaches a person or a home: a phone, an email, an address), or null (no floor).
226
+ * The template check refuses anything below it; the describe box fills an omitted sensitivity up to it.
227
+ */
228
+ declare function sensitivityFloorOf(table: Pick<TemplateTable, "token" | "labelSingular" | "subject" | "fields">, f: Pick<TemplateField, "key" | "label" | "parityType">): "restricted" | "confidential" | null;
222
229
 
223
230
  type Uuid = string;
224
231
  /** The binding a host writes onto the copied agent's variable (the kit `merge_field` shape). */
@@ -591,4 +598,4 @@ declare function runTemplateDoor(source: RecordsDataSource, door: TemplateFamily
591
598
  /** Tables a plan makes (for a suite): the `tables.*` refs its steps save. */
592
599
  declare function planTables(plan: TemplateInstallPlan): string[];
593
600
 
594
- export { AgentSnapshotRow, type AggregateOutcome, type CapabilityStatus, CapabilityWord, DESIGNATED_REAL_NUMBERS, type DerivedUseCase, FORMULA_FUNCTIONS, INSTALL_PLAN_VERSION, MAIN_TABLE_ROWS_MAX, MAIN_TABLE_ROWS_MIN, PUBLIC_MAIL_DOMAINS, RECORDS_UI_CALENDAR_MODES, RECORDS_UI_FIELD_SURFACES, RECORDS_UI_VIEW_LAYOUTS, SERVER_DATE_GRAMMAR, type SeedRow, SharedBlockId, TABLES_MAX, TABLES_MIN, TEMPLATE_PLAN_DOORS, TIME_BOUND_STAGE, TITLE_DISTINCT_SHARE, TemplateAgent, type TemplateAgentBinding, type TemplateAgentCopyRequest, type TemplateAssetRow, type TemplateAttachment, TemplateAutomation, TemplateBooking, type TemplateCard, TemplateChecklist, TemplateDashboard, type TemplateDeclaration, TemplateDigest, TemplateDimensions, TemplateDocument, type TemplateDoorAnswer, type TemplateDoorRun, TemplateDrillDown, type TemplateFamilyDoor, TemplateField, TemplateFootprint, TemplateForm, type TemplateHostExtras, type TemplateInstallPlan, type TemplateMadeKind, TemplateMergeBinding, TemplateNotification, type TemplatePlanAgent, type TemplatePlanBinding, type TemplatePlanDoor, type TemplatePlanExtraAgent, type TemplatePlanStep, TemplatePortal, TemplateRowAction, TemplateSpec, type TemplateSpecWithAttachments, TemplateStageRules, type TemplateStatus, TemplateTable, TemplateTryIt, type TemplateVerdict, TemplateView, TemplateWorkflow, type ValidateOptions, agentCopyRequest, allTables, anyOfWhere, assertTemplate, attachmentProblems, automationHeld, blockTable, bookingArgs, bookingColumnsProblem, capabilitiesUsed, capabilityStatus, checklistSpec, choiceDisplayFormat, compileHostExtras, compileInstallPlan, dashboardBlocks, deferredRelationFields, deferredRelations, derivedFieldSpec, digestSpec, documentBody, domainsIn, drillDownDashboard, evalFormula, extrasProblems, foreignTextProblems, formArgs, formulaFieldSpec, formulaOrder, formulaRefs, foundationTokens, isSelfDeclaredField, isTimedField, normalizeForPhones, notificationParts, numberText, numberedStreet, parseFormula, parseNumeric, peopleOf, phonesOutsideFictionalRange, planTables, portalArgs, relationFieldSpec, relationPatches, relativeHasTime, requiredCircleProblem, resolveDateToken, resolveRelativeDates, rowActionList, rowLevels, rowsFor, ruleBreak, runTemplateDoor, selfDeclaredFieldSpec, shellsPayload, stageFieldOf, stageRulesSpec, storeAggregate, storeFilterMatches, storeText, tableShellPayload, templateCard, templateDeclaration, templateText, timedFieldSpec, toUseCase, unwrap, useCaseProblemsOf, validateTemplate, viewMatches, viewSpec, zoneOffset };
601
+ export { AgentSnapshotRow, type AggregateOutcome, type CapabilityStatus, CapabilityWord, DESIGNATED_REAL_NUMBERS, type DerivedUseCase, FORMULA_FUNCTIONS, INSTALL_PLAN_VERSION, MAIN_TABLE_ROWS_MAX, MAIN_TABLE_ROWS_MIN, PUBLIC_MAIL_DOMAINS, RECORDS_UI_CALENDAR_MODES, RECORDS_UI_FIELD_SURFACES, RECORDS_UI_VIEW_LAYOUTS, SERVER_DATE_GRAMMAR, type SeedRow, SharedBlockId, TABLES_MAX, TABLES_MIN, TEMPLATE_PLAN_DOORS, TIME_BOUND_STAGE, TITLE_DISTINCT_SHARE, TemplateAgent, type TemplateAgentBinding, type TemplateAgentCopyRequest, type TemplateAssetRow, type TemplateAttachment, TemplateAutomation, TemplateBooking, type TemplateCard, TemplateChecklist, TemplateDashboard, type TemplateDeclaration, TemplateDigest, TemplateDimensions, TemplateDocument, type TemplateDoorAnswer, type TemplateDoorRun, TemplateDrillDown, type TemplateFamilyDoor, TemplateField, TemplateFootprint, TemplateForm, type TemplateHostExtras, type TemplateInstallPlan, type TemplateMadeKind, TemplateMergeBinding, TemplateNotification, type TemplatePlanAgent, type TemplatePlanBinding, type TemplatePlanDoor, type TemplatePlanExtraAgent, type TemplatePlanStep, TemplatePortal, TemplateRowAction, TemplateSpec, type TemplateSpecWithAttachments, TemplateStageRules, type TemplateStatus, TemplateTable, TemplateTryIt, type TemplateVerdict, TemplateView, TemplateWorkflow, type ValidateOptions, agentCopyRequest, allTables, anyOfWhere, assertTemplate, attachmentProblems, automationHeld, blockTable, bookingArgs, bookingColumnsProblem, capabilitiesUsed, capabilityStatus, checklistSpec, choiceDisplayFormat, compileHostExtras, compileInstallPlan, dashboardBlocks, deferredRelationFields, deferredRelations, derivedFieldSpec, digestSpec, documentBody, domainsIn, drillDownDashboard, evalFormula, extrasProblems, foreignTextProblems, formArgs, formulaFieldSpec, formulaOrder, formulaRefs, foundationTokens, isSelfDeclaredField, isTimedField, normalizeForPhones, notificationParts, numberText, numberedStreet, parseFormula, parseNumeric, peopleOf, phonesOutsideFictionalRange, planTables, portalArgs, relationFieldSpec, relationPatches, relativeHasTime, requiredCircleProblem, resolveDateToken, resolveRelativeDates, rowActionList, rowLevels, rowsFor, ruleBreak, runTemplateDoor, selfDeclaredFieldSpec, sensitivityFloorOf, shellsPayload, stageFieldOf, stageRulesSpec, storeAggregate, storeFilterMatches, storeText, tableShellPayload, templateCard, templateDeclaration, templateText, timedFieldSpec, toUseCase, unwrap, useCaseProblemsOf, validateTemplate, viewMatches, viewSpec, zoneOffset };
@@ -219,6 +219,13 @@ declare function attachmentProblems(raw: TemplateSpec & {
219
219
  declare function validateTemplate(raw: TemplateSpec, options?: ValidateOptions): TemplateVerdict;
220
220
  /** Validate and throw with every problem. A waiting template does not throw — it is held, not broken. */
221
221
  declare function assertTemplate(spec: TemplateSpec, options?: ValidateOptions): TemplateVerdict;
222
+ /**
223
+ * The lowest sensitivity the store accepts for a field, by what it holds: "restricted" (kept from the AI:
224
+ * an identity or health fact about a person, a code, a card or bank number, privileged notes),
225
+ * "confidential" (it reaches a person or a home: a phone, an email, an address), or null (no floor).
226
+ * The template check refuses anything below it; the describe box fills an omitted sensitivity up to it.
227
+ */
228
+ declare function sensitivityFloorOf(table: Pick<TemplateTable, "token" | "labelSingular" | "subject" | "fields">, f: Pick<TemplateField, "key" | "label" | "parityType">): "restricted" | "confidential" | null;
222
229
 
223
230
  type Uuid = string;
224
231
  /** The binding a host writes onto the copied agent's variable (the kit `merge_field` shape). */
@@ -591,4 +598,4 @@ declare function runTemplateDoor(source: RecordsDataSource, door: TemplateFamily
591
598
  /** Tables a plan makes (for a suite): the `tables.*` refs its steps save. */
592
599
  declare function planTables(plan: TemplateInstallPlan): string[];
593
600
 
594
- export { AgentSnapshotRow, type AggregateOutcome, type CapabilityStatus, CapabilityWord, DESIGNATED_REAL_NUMBERS, type DerivedUseCase, FORMULA_FUNCTIONS, INSTALL_PLAN_VERSION, MAIN_TABLE_ROWS_MAX, MAIN_TABLE_ROWS_MIN, PUBLIC_MAIL_DOMAINS, RECORDS_UI_CALENDAR_MODES, RECORDS_UI_FIELD_SURFACES, RECORDS_UI_VIEW_LAYOUTS, SERVER_DATE_GRAMMAR, type SeedRow, SharedBlockId, TABLES_MAX, TABLES_MIN, TEMPLATE_PLAN_DOORS, TIME_BOUND_STAGE, TITLE_DISTINCT_SHARE, TemplateAgent, type TemplateAgentBinding, type TemplateAgentCopyRequest, type TemplateAssetRow, type TemplateAttachment, TemplateAutomation, TemplateBooking, type TemplateCard, TemplateChecklist, TemplateDashboard, type TemplateDeclaration, TemplateDigest, TemplateDimensions, TemplateDocument, type TemplateDoorAnswer, type TemplateDoorRun, TemplateDrillDown, type TemplateFamilyDoor, TemplateField, TemplateFootprint, TemplateForm, type TemplateHostExtras, type TemplateInstallPlan, type TemplateMadeKind, TemplateMergeBinding, TemplateNotification, type TemplatePlanAgent, type TemplatePlanBinding, type TemplatePlanDoor, type TemplatePlanExtraAgent, type TemplatePlanStep, TemplatePortal, TemplateRowAction, TemplateSpec, type TemplateSpecWithAttachments, TemplateStageRules, type TemplateStatus, TemplateTable, TemplateTryIt, type TemplateVerdict, TemplateView, TemplateWorkflow, type ValidateOptions, agentCopyRequest, allTables, anyOfWhere, assertTemplate, attachmentProblems, automationHeld, blockTable, bookingArgs, bookingColumnsProblem, capabilitiesUsed, capabilityStatus, checklistSpec, choiceDisplayFormat, compileHostExtras, compileInstallPlan, dashboardBlocks, deferredRelationFields, deferredRelations, derivedFieldSpec, digestSpec, documentBody, domainsIn, drillDownDashboard, evalFormula, extrasProblems, foreignTextProblems, formArgs, formulaFieldSpec, formulaOrder, formulaRefs, foundationTokens, isSelfDeclaredField, isTimedField, normalizeForPhones, notificationParts, numberText, numberedStreet, parseFormula, parseNumeric, peopleOf, phonesOutsideFictionalRange, planTables, portalArgs, relationFieldSpec, relationPatches, relativeHasTime, requiredCircleProblem, resolveDateToken, resolveRelativeDates, rowActionList, rowLevels, rowsFor, ruleBreak, runTemplateDoor, selfDeclaredFieldSpec, shellsPayload, stageFieldOf, stageRulesSpec, storeAggregate, storeFilterMatches, storeText, tableShellPayload, templateCard, templateDeclaration, templateText, timedFieldSpec, toUseCase, unwrap, useCaseProblemsOf, validateTemplate, viewMatches, viewSpec, zoneOffset };
601
+ export { AgentSnapshotRow, type AggregateOutcome, type CapabilityStatus, CapabilityWord, DESIGNATED_REAL_NUMBERS, type DerivedUseCase, FORMULA_FUNCTIONS, INSTALL_PLAN_VERSION, MAIN_TABLE_ROWS_MAX, MAIN_TABLE_ROWS_MIN, PUBLIC_MAIL_DOMAINS, RECORDS_UI_CALENDAR_MODES, RECORDS_UI_FIELD_SURFACES, RECORDS_UI_VIEW_LAYOUTS, SERVER_DATE_GRAMMAR, type SeedRow, SharedBlockId, TABLES_MAX, TABLES_MIN, TEMPLATE_PLAN_DOORS, TIME_BOUND_STAGE, TITLE_DISTINCT_SHARE, TemplateAgent, type TemplateAgentBinding, type TemplateAgentCopyRequest, type TemplateAssetRow, type TemplateAttachment, TemplateAutomation, TemplateBooking, type TemplateCard, TemplateChecklist, TemplateDashboard, type TemplateDeclaration, TemplateDigest, TemplateDimensions, TemplateDocument, type TemplateDoorAnswer, type TemplateDoorRun, TemplateDrillDown, type TemplateFamilyDoor, TemplateField, TemplateFootprint, TemplateForm, type TemplateHostExtras, type TemplateInstallPlan, type TemplateMadeKind, TemplateMergeBinding, TemplateNotification, type TemplatePlanAgent, type TemplatePlanBinding, type TemplatePlanDoor, type TemplatePlanExtraAgent, type TemplatePlanStep, TemplatePortal, TemplateRowAction, TemplateSpec, type TemplateSpecWithAttachments, TemplateStageRules, type TemplateStatus, TemplateTable, TemplateTryIt, type TemplateVerdict, TemplateView, TemplateWorkflow, type ValidateOptions, agentCopyRequest, allTables, anyOfWhere, assertTemplate, attachmentProblems, automationHeld, blockTable, bookingArgs, bookingColumnsProblem, capabilitiesUsed, capabilityStatus, checklistSpec, choiceDisplayFormat, compileHostExtras, compileInstallPlan, dashboardBlocks, deferredRelationFields, deferredRelations, derivedFieldSpec, digestSpec, documentBody, domainsIn, drillDownDashboard, evalFormula, extrasProblems, foreignTextProblems, formArgs, formulaFieldSpec, formulaOrder, formulaRefs, foundationTokens, isSelfDeclaredField, isTimedField, normalizeForPhones, notificationParts, numberText, numberedStreet, parseFormula, parseNumeric, peopleOf, phonesOutsideFictionalRange, planTables, portalArgs, relationFieldSpec, relationPatches, relativeHasTime, requiredCircleProblem, resolveDateToken, resolveRelativeDates, rowActionList, rowLevels, rowsFor, ruleBreak, runTemplateDoor, selfDeclaredFieldSpec, sensitivityFloorOf, shellsPayload, stageFieldOf, stageRulesSpec, storeAggregate, storeFilterMatches, storeText, tableShellPayload, templateCard, templateDeclaration, templateText, timedFieldSpec, toUseCase, unwrap, useCaseProblemsOf, validateTemplate, viewMatches, viewSpec, zoneOffset };
@@ -4989,23 +4989,15 @@ function validateTemplate(raw, options = {}) {
4989
4989
  }
4990
4990
  }
4991
4991
  }
4992
- const RESTRICTED_KEY = /(^|_)(member_id|ssn|social_security|dob|date_of_birth|birth_date|allerg(y|ies)|diagnos(is|es)|medical_conditions?|conditions|medications?|current_medications|gate_code|access_code|door_code|alarm_code|password|passcode|pin|clinical_notes?|visit_notes?|progress_notes?|soap_notes?|case_notes?|legal_notes?|privileged_notes?|bank(_\w+)?|routing(_number)?|account_number|iban|swift(_code)?|card(_number|_on_file)?|credit_card|cvv|cvc)($|_)/;
4993
- const RESTRICTED_LABEL = /\b(bank|routing number|iban|card on file|credit card|card number|cvv|medical conditions?|medications?|diagnos[ie]s|case notes|legal notes|privileged)\b/;
4994
- const PERSONAL_ONLY = /(^|_)(dob|date_of_birth|birth_date|allerg(y|ies)|diagnos(is|es)|medical_conditions?|conditions|medications?|current_medications|clinical_notes?|visit_notes?|progress_notes?|soap_notes?|member_id|ssn|social_security)($|_)/;
4995
- const holdsPeople = (t) => t.subject ? t.subject === "person" : t.fields.some((f) => /name/.test(f.key)) && t.fields.some((f) => f.parityType === "phone" || f.parityType === "email");
4996
4992
  for (const t of own) {
4997
4993
  for (const f of t.fields) {
4998
4994
  const at = `tables (${t.token}).fields (${f.key})`;
4999
4995
  const text2 = `${f.key} ${norm(f.label)}`;
5000
4996
  const e = effective(t.token, f);
5001
- const billingTable = /(invoice|bill|statement|receipt|payment|charge|fee|order|account)/i.test(`${t.token} ${t.labelSingular}`);
5002
- const criminalCharges = /(^|_)charges?($|_)/.test(f.key) && behaviorOf(f) === "text" && !billingTable;
5003
- const phoneLike = behaviorOf(f) === "text" && /\b(cell|mobile|phone)\b/.test(norm(f.label));
5004
- const personal = PERSONAL_ONLY.test(f.key) || /\b(medical conditions?|medications?|diagnos[ie]s)\b/.test(norm(f.label));
5005
- const floored = (RESTRICTED_KEY.test(f.key) || RESTRICTED_LABEL.test(norm(f.label)) || criminalCharges) && (!personal || holdsPeople(t));
5006
- if (floored && !(e.sensitivity === "restricted" && e.contextPolicy === "exclude")) {
4997
+ const floor = sensitivityFloorOf(t, f);
4998
+ if (floor === "restricted" && !(e.sensitivity === "restricted" && e.contextPolicy === "exclude")) {
5007
4999
  say(at, `"${f.label}" is the kind of value that is restricted and kept from the AI (restricted + exclude).`);
5008
- } else if ((f.parityType === "phone" || phoneLike || f.parityType === "email" || /address|street/.test(text2)) && SENSITIVITY_RANK.indexOf(e.sensitivity) < 2) {
5000
+ } else if (floor === "confidential" && SENSITIVITY_RANK.indexOf(e.sensitivity) < 2) {
5009
5001
  say(at, `"${f.label}" reaches a person or a home, so it is at least confidential.`);
5010
5002
  } else if (/note/.test(text2) && e.sensitivity === "public") {
5011
5003
  say(at, `"${f.label}" is somebody's notes; notes are never public.`);
@@ -5859,6 +5851,21 @@ function assertTemplate(spec, options = {}) {
5859
5851
  throw new Error(`The template "${spec.id}" is not ready \u2014 ${verdict.problems.length} problem(s):
5860
5852
  ${verdict.problems.map((p) => ` \xB7 ${p.at}: ${p.says}`).join("\n")}`);
5861
5853
  }
5854
+ var RESTRICTED_KEY = /(^|_)(member_id|ssn|social_security|dob|date_of_birth|birth_date|allerg(y|ies)|diagnos(is|es)|medical_conditions?|conditions|medications?|current_medications|gate_code|access_code|door_code|alarm_code|password|passcode|pin|clinical_notes?|visit_notes?|progress_notes?|soap_notes?|case_notes?|legal_notes?|privileged_notes?|bank(_\w+)?|routing(_number)?|account_number|iban|swift(_code)?|card(_number|_on_file)?|credit_card|cvv|cvc)($|_)/;
5855
+ var RESTRICTED_LABEL = /\b(bank|routing number|iban|card on file|credit card|card number|cvv|medical conditions?|medications?|diagnos[ie]s|case notes|legal notes|privileged)\b/;
5856
+ var PERSONAL_ONLY = /(^|_)(dob|date_of_birth|birth_date|allerg(y|ies)|diagnos(is|es)|medical_conditions?|conditions|medications?|current_medications|clinical_notes?|visit_notes?|progress_notes?|soap_notes?|member_id|ssn|social_security)($|_)/;
5857
+ var holdsPeople = (t) => t.subject ? t.subject === "person" : t.fields.some((f) => /name/.test(f.key)) && t.fields.some((f) => f.parityType === "phone" || f.parityType === "email");
5858
+ function sensitivityFloorOf(table, f) {
5859
+ const text = `${f.key} ${norm(f.label)}`;
5860
+ const billingTable = /(invoice|bill|statement|receipt|payment|charge|fee|order|account)/i.test(`${table.token} ${table.labelSingular ?? ""}`);
5861
+ const criminalCharges = /(^|_)charges?($|_)/.test(f.key) && behaviorOf(f) === "text" && !billingTable;
5862
+ const phoneLike = behaviorOf(f) === "text" && /\b(cell|mobile|phone)\b/.test(norm(f.label));
5863
+ const personal = PERSONAL_ONLY.test(f.key) || /\b(medical conditions?|medications?|diagnos[ie]s)\b/.test(norm(f.label));
5864
+ const floored = (RESTRICTED_KEY.test(f.key) || RESTRICTED_LABEL.test(norm(f.label)) || criminalCharges) && (!personal || holdsPeople(table));
5865
+ if (floored) return "restricted";
5866
+ if (f.parityType === "phone" || phoneLike || f.parityType === "email" || /address|street/.test(text)) return "confidential";
5867
+ return null;
5868
+ }
5862
5869
 
5863
5870
  // src/templates/plan.ts
5864
5871
  var INSTALL_PLAN_VERSION = 1;
@@ -6388,6 +6395,7 @@ export {
6388
6395
  ruleBreak,
6389
6396
  runTemplateDoor,
6390
6397
  selfDeclaredFieldSpec,
6398
+ sensitivityFloorOf,
6391
6399
  shellsPayload,
6392
6400
  stageFieldOf,
6393
6401
  stageRulesSpec,