@suss/resolution 0.34.1 → 0.35.1

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.
package/dist/index.d.cts CHANGED
@@ -296,6 +296,47 @@ declare class FactLog {
296
296
  changedValues(changed: ReadonlySet<string>, previous: ReadonlyMap<string, StoredFacts>): Set<number>;
297
297
  }
298
298
 
299
+ /**
300
+ * What a call may run when it takes its function out of a table, or
301
+ * picks a member by a name it works out at run time: `COMMANDS[name](args)`,
302
+ * `handlers.get(kind)(event)`, `getattr(self, kind)()`, Ruby's `send(kind)`.
303
+ *
304
+ * The rules list every function such a call may run. Whether it runs
305
+ * exactly one is a count, which a rule cannot make, so it is decided
306
+ * here: the source has to narrow the read to one name, and the entry
307
+ * under that name has to be one function. Every other call may run any
308
+ * of the functions listed, and a caller records them as possible rather
309
+ * than as the one the call runs. DESIGN.md says which entries a read can
310
+ * come back with.
311
+ */
312
+
313
+ /** What a call that takes its function from a table may run. */
314
+ interface DispatchOutcome {
315
+ /** Every function the call may run, each once. */
316
+ readonly functions: readonly string[];
317
+ /** True when the source narrows the call to one entry that comes to one function. */
318
+ readonly certain: boolean;
319
+ /** How many entries came to no function this run read, any of which the call may run instead. */
320
+ readonly unresolved: number;
321
+ /** What each of `functions` calls in its own body, for an entry no summary describes, such as a lambda. */
322
+ readonly through: ReadonlyMap<string, readonly string[]>;
323
+ /** The tables and objects the call takes its function out of, for an adapter that reads their writes lazily. */
324
+ readonly containers: readonly string[];
325
+ }
326
+ /**
327
+ * The outcome for each of these calls that takes its function from a
328
+ * table. A call that does not is left out of the map. One question for
329
+ * the batch, so the rules are evaluated once.
330
+ */
331
+ declare function dispatchOutcomes(db: Database, calls: readonly string[], program?: OnDemandRules): Map<string, DispatchOutcome>;
332
+ /** What a caller asks through to learn what each call may run. */
333
+ declare const DISPATCH_QUESTION = "wantedDispatch";
334
+ /**
335
+ * The outcomes the rules derived for calls already asked about through
336
+ * `DISPATCH_QUESTION`, for a store that evaluates the rules itself.
337
+ */
338
+ declare function readDispatchOutcomes(db: Database, calls: readonly string[]): Map<string, DispatchOutcome>;
339
+
299
340
  /**
300
341
  * Which records of a stored cache entry a run can replay, for an adapter
301
342
  * that stores one record per file: what the file's discovery depended
@@ -589,6 +630,14 @@ interface SpannedNode<N> {
589
630
  readonly parent: N | null;
590
631
  descendantForIndex(start: number, end: number): N | null;
591
632
  }
633
+ /** Where a node key's node is written. */
634
+ interface KeySpan {
635
+ readonly file: string;
636
+ readonly start: number;
637
+ readonly end: number;
638
+ }
639
+ /** The file and byte span of a node key, or null for a key that is not a node. */
640
+ declare function spanOfKey(key: string): KeySpan | null;
592
641
  /**
593
642
  * The node a key refers to: the smallest node over the span, walked up
594
643
  * to the one whose span matches. A key that is not a node, such as a
@@ -1031,6 +1080,41 @@ declare function writtenValueUnder(db: Database, key: string, site: string, ask:
1031
1080
  */
1032
1081
  declare function allocationSitesOf(db: Database, cls: string): string[];
1033
1082
 
1083
+ /**
1084
+ * Where each piece of a value written out in source goes: the entries of
1085
+ * a list or an object, and the parts and holes of a template string.
1086
+ *
1087
+ * Every adapter states these rows from its own syntax, and a reader puts
1088
+ * the value back together from them in any language. So the numbering
1089
+ * is written once, here, and a list, an f-string and a Ruby interpolated
1090
+ * symbol all count their pieces the same way.
1091
+ */
1092
+ /** The last column of `writtenEntryAt` for an entry written in place. */
1093
+ declare const VALUE_ENTRY = "value";
1094
+ /** The last column of `writtenEntryAt` for a spread, which puts every entry of its collection at that one position. */
1095
+ declare const SPREAD_ENTRY = "spread";
1096
+ /** One entry of a list or an object: the key of its value, or of the collection a spread unpacks. */
1097
+ interface WrittenEntry {
1098
+ readonly key: string;
1099
+ readonly form: typeof VALUE_ENTRY | typeof SPREAD_ENTRY;
1100
+ }
1101
+ /** One piece of a template string: text it writes, or the key of a value it puts there. */
1102
+ type TemplatePiece = {
1103
+ readonly text: string;
1104
+ } | {
1105
+ readonly hole: string;
1106
+ };
1107
+ /** Adds one row to a relation, through whatever buffer the adapter keeps. */
1108
+ type AddRow = (relation: string, row: string[]) => void;
1109
+ /** `writtenEntryAt` for each entry of a list or an object, numbered in the order they are written. */
1110
+ declare function addEntryRows(add: AddRow, container: string, entries: readonly WrittenEntry[]): void;
1111
+ /**
1112
+ * `partAt` and `holeAt` for a template's pieces, numbered together in
1113
+ * source order. Text that writes nothing gets no row, so `${a}${b}` has
1114
+ * two holes, at 0 and 1, and no parts.
1115
+ */
1116
+ declare function addTemplateRows(add: AddRow, template: string, pieces: readonly TemplatePiece[]): void;
1117
+
1034
1118
  /**
1035
1119
  * What a name written more than once comes down to.
1036
1120
  *
@@ -1203,4 +1287,4 @@ declare const ANSWER_RELATIONS: string[];
1203
1287
  */
1204
1288
  declare const UNDER_ANSWER_RELATIONS: string[];
1205
1289
 
1206
- export { ANSWER_RELATIONS, ASKING_RELATIONS, type AskUnder, type AssociationConstructor, BASE_CLASS_RULE, type CalleeOutcome, type CaseFiles, type ChainReads, type Changes, type ContractCase, type ContractOptions, DEFAULT_IMPORT_NAME, type Dependencies, DependencyLedger, type DescribeAtom, type EntersAsSelf, EntryReuse, type ExplainOptions, type ExplainResolvedKeyOptions, type ExplainStats, FACT_CONTRACT_CASES, FactLog, type FactsOf, GLOBAL_MODULE, type GivesBackOne, type GivesBackOneOfArgument, type GivesBackOneOfImport, INSTANCE_STEP, type MountEdge, type MountEdges, NAMED_STORE_NAME, NAMESPACE_IMPORT, NAMESPACE_IMPORT_NAME, NAMESPACE_MEMBER_RULE, NAME_HOP_RULE, NO_CONTEXT, NO_CONTEXT_NAME, type NameReads, type NameWrite, type OrderedWrite, type PackWords, RECEIVER_STORE_NAME, RESOLUTION_QUESTIONS, RESOLUTION_RULES, RESULT_STEP, type ReadNode, type ResolutionExplanation, type ResolutionStep, type SourceEnd, type SourceLeaf, type SourceQuestion, type SpannedNode, type StepContext, type StepPhrase, type StoredDependencies, type StoredFacts, type StoredFileRecord, type StoredWalkRecord, type SuppliesParameter, UNDER_ANSWER_RELATIONS, UNDER_QUESTION_ROW_BUDGET, UNDER_RUN_ROW_BUDGET, UNPLACED_STORE_NAME, USES_QUESTION, type UnderOutcome, type UnwrapsByName, VALUE_STEP, type ValueLocation, type ValueUses, WatchedMap, type WhyExplained, addPackWords, agreedMountPrefix, allocationSitesOf, alsoSteps, answersFor, answersFromTestsLeftOut, askResolution, askResolutionUnder, askSources, calleeOutcomeOf, calleeOutcomes, checkFactContract, classMemberName, classMemberOf, comesToUnder, couldBeSettled, declaredTypesOf, exitCodeFunctions, explainResolutionProof, explainResolvedKey, fallbackWrittenAs, fileOfKey, hashString, importedFilesByFile, isObserved, isWrittenAsUnder, joinMountedPath, mergeStoredDependencies, mountPathsOf, noDependencies, nodeOfKey, noteKeyRead, noteLookup, objectOfUnder, observeDemand, packHashes, proofRules, queryFacts, readUses, recordsToReplay, renderExplanation, resolutionProgram, resolutionUnderProgram, resolvedFunctions, settledFunction, sourceLeavesOf, startsAtName, staysInItsFunction, stillValid, underQuestionSpend, unpackHashes, valueLeftByWrites, walkRecordsByFile, writesRunInOrder, writtenAnswersFor, writtenSourcesOf, writtenValueOf, writtenValueUnder, writtenValuesByKey, writtenValuesOf };
1290
+ export { ANSWER_RELATIONS, ASKING_RELATIONS, type AddRow, type AskUnder, type AssociationConstructor, BASE_CLASS_RULE, type CalleeOutcome, type CaseFiles, type ChainReads, type Changes, type ContractCase, type ContractOptions, DEFAULT_IMPORT_NAME, DISPATCH_QUESTION, type Dependencies, DependencyLedger, type DescribeAtom, type DispatchOutcome, type EntersAsSelf, EntryReuse, type ExplainOptions, type ExplainResolvedKeyOptions, type ExplainStats, FACT_CONTRACT_CASES, FactLog, type FactsOf, GLOBAL_MODULE, type GivesBackOne, type GivesBackOneOfArgument, type GivesBackOneOfImport, INSTANCE_STEP, type KeySpan, type MountEdge, type MountEdges, NAMED_STORE_NAME, NAMESPACE_IMPORT, NAMESPACE_IMPORT_NAME, NAMESPACE_MEMBER_RULE, NAME_HOP_RULE, NO_CONTEXT, NO_CONTEXT_NAME, type NameReads, type NameWrite, type OrderedWrite, type PackWords, RECEIVER_STORE_NAME, RESOLUTION_QUESTIONS, RESOLUTION_RULES, RESULT_STEP, type ReadNode, type ResolutionExplanation, type ResolutionStep, SPREAD_ENTRY, type SourceEnd, type SourceLeaf, type SourceQuestion, type SpannedNode, type StepContext, type StepPhrase, type StoredDependencies, type StoredFacts, type StoredFileRecord, type StoredWalkRecord, type SuppliesParameter, type TemplatePiece, UNDER_ANSWER_RELATIONS, UNDER_QUESTION_ROW_BUDGET, UNDER_RUN_ROW_BUDGET, UNPLACED_STORE_NAME, USES_QUESTION, type UnderOutcome, type UnwrapsByName, VALUE_ENTRY, VALUE_STEP, type ValueLocation, type ValueUses, WatchedMap, type WhyExplained, type WrittenEntry, addEntryRows, addPackWords, addTemplateRows, agreedMountPrefix, allocationSitesOf, alsoSteps, answersFor, answersFromTestsLeftOut, askResolution, askResolutionUnder, askSources, calleeOutcomeOf, calleeOutcomes, checkFactContract, classMemberName, classMemberOf, comesToUnder, couldBeSettled, declaredTypesOf, dispatchOutcomes, exitCodeFunctions, explainResolutionProof, explainResolvedKey, fallbackWrittenAs, fileOfKey, hashString, importedFilesByFile, isObserved, isWrittenAsUnder, joinMountedPath, mergeStoredDependencies, mountPathsOf, noDependencies, nodeOfKey, noteKeyRead, noteLookup, objectOfUnder, observeDemand, packHashes, proofRules, queryFacts, readDispatchOutcomes, readUses, recordsToReplay, renderExplanation, resolutionProgram, resolutionUnderProgram, resolvedFunctions, settledFunction, sourceLeavesOf, spanOfKey, startsAtName, staysInItsFunction, stillValid, underQuestionSpend, unpackHashes, valueLeftByWrites, walkRecordsByFile, writesRunInOrder, writtenAnswersFor, writtenSourcesOf, writtenValueOf, writtenValueUnder, writtenValuesByKey, writtenValuesOf };
package/dist/index.d.ts CHANGED
@@ -296,6 +296,47 @@ declare class FactLog {
296
296
  changedValues(changed: ReadonlySet<string>, previous: ReadonlyMap<string, StoredFacts>): Set<number>;
297
297
  }
298
298
 
299
+ /**
300
+ * What a call may run when it takes its function out of a table, or
301
+ * picks a member by a name it works out at run time: `COMMANDS[name](args)`,
302
+ * `handlers.get(kind)(event)`, `getattr(self, kind)()`, Ruby's `send(kind)`.
303
+ *
304
+ * The rules list every function such a call may run. Whether it runs
305
+ * exactly one is a count, which a rule cannot make, so it is decided
306
+ * here: the source has to narrow the read to one name, and the entry
307
+ * under that name has to be one function. Every other call may run any
308
+ * of the functions listed, and a caller records them as possible rather
309
+ * than as the one the call runs. DESIGN.md says which entries a read can
310
+ * come back with.
311
+ */
312
+
313
+ /** What a call that takes its function from a table may run. */
314
+ interface DispatchOutcome {
315
+ /** Every function the call may run, each once. */
316
+ readonly functions: readonly string[];
317
+ /** True when the source narrows the call to one entry that comes to one function. */
318
+ readonly certain: boolean;
319
+ /** How many entries came to no function this run read, any of which the call may run instead. */
320
+ readonly unresolved: number;
321
+ /** What each of `functions` calls in its own body, for an entry no summary describes, such as a lambda. */
322
+ readonly through: ReadonlyMap<string, readonly string[]>;
323
+ /** The tables and objects the call takes its function out of, for an adapter that reads their writes lazily. */
324
+ readonly containers: readonly string[];
325
+ }
326
+ /**
327
+ * The outcome for each of these calls that takes its function from a
328
+ * table. A call that does not is left out of the map. One question for
329
+ * the batch, so the rules are evaluated once.
330
+ */
331
+ declare function dispatchOutcomes(db: Database, calls: readonly string[], program?: OnDemandRules): Map<string, DispatchOutcome>;
332
+ /** What a caller asks through to learn what each call may run. */
333
+ declare const DISPATCH_QUESTION = "wantedDispatch";
334
+ /**
335
+ * The outcomes the rules derived for calls already asked about through
336
+ * `DISPATCH_QUESTION`, for a store that evaluates the rules itself.
337
+ */
338
+ declare function readDispatchOutcomes(db: Database, calls: readonly string[]): Map<string, DispatchOutcome>;
339
+
299
340
  /**
300
341
  * Which records of a stored cache entry a run can replay, for an adapter
301
342
  * that stores one record per file: what the file's discovery depended
@@ -589,6 +630,14 @@ interface SpannedNode<N> {
589
630
  readonly parent: N | null;
590
631
  descendantForIndex(start: number, end: number): N | null;
591
632
  }
633
+ /** Where a node key's node is written. */
634
+ interface KeySpan {
635
+ readonly file: string;
636
+ readonly start: number;
637
+ readonly end: number;
638
+ }
639
+ /** The file and byte span of a node key, or null for a key that is not a node. */
640
+ declare function spanOfKey(key: string): KeySpan | null;
592
641
  /**
593
642
  * The node a key refers to: the smallest node over the span, walked up
594
643
  * to the one whose span matches. A key that is not a node, such as a
@@ -1031,6 +1080,41 @@ declare function writtenValueUnder(db: Database, key: string, site: string, ask:
1031
1080
  */
1032
1081
  declare function allocationSitesOf(db: Database, cls: string): string[];
1033
1082
 
1083
+ /**
1084
+ * Where each piece of a value written out in source goes: the entries of
1085
+ * a list or an object, and the parts and holes of a template string.
1086
+ *
1087
+ * Every adapter states these rows from its own syntax, and a reader puts
1088
+ * the value back together from them in any language. So the numbering
1089
+ * is written once, here, and a list, an f-string and a Ruby interpolated
1090
+ * symbol all count their pieces the same way.
1091
+ */
1092
+ /** The last column of `writtenEntryAt` for an entry written in place. */
1093
+ declare const VALUE_ENTRY = "value";
1094
+ /** The last column of `writtenEntryAt` for a spread, which puts every entry of its collection at that one position. */
1095
+ declare const SPREAD_ENTRY = "spread";
1096
+ /** One entry of a list or an object: the key of its value, or of the collection a spread unpacks. */
1097
+ interface WrittenEntry {
1098
+ readonly key: string;
1099
+ readonly form: typeof VALUE_ENTRY | typeof SPREAD_ENTRY;
1100
+ }
1101
+ /** One piece of a template string: text it writes, or the key of a value it puts there. */
1102
+ type TemplatePiece = {
1103
+ readonly text: string;
1104
+ } | {
1105
+ readonly hole: string;
1106
+ };
1107
+ /** Adds one row to a relation, through whatever buffer the adapter keeps. */
1108
+ type AddRow = (relation: string, row: string[]) => void;
1109
+ /** `writtenEntryAt` for each entry of a list or an object, numbered in the order they are written. */
1110
+ declare function addEntryRows(add: AddRow, container: string, entries: readonly WrittenEntry[]): void;
1111
+ /**
1112
+ * `partAt` and `holeAt` for a template's pieces, numbered together in
1113
+ * source order. Text that writes nothing gets no row, so `${a}${b}` has
1114
+ * two holes, at 0 and 1, and no parts.
1115
+ */
1116
+ declare function addTemplateRows(add: AddRow, template: string, pieces: readonly TemplatePiece[]): void;
1117
+
1034
1118
  /**
1035
1119
  * What a name written more than once comes down to.
1036
1120
  *
@@ -1203,4 +1287,4 @@ declare const ANSWER_RELATIONS: string[];
1203
1287
  */
1204
1288
  declare const UNDER_ANSWER_RELATIONS: string[];
1205
1289
 
1206
- export { ANSWER_RELATIONS, ASKING_RELATIONS, type AskUnder, type AssociationConstructor, BASE_CLASS_RULE, type CalleeOutcome, type CaseFiles, type ChainReads, type Changes, type ContractCase, type ContractOptions, DEFAULT_IMPORT_NAME, type Dependencies, DependencyLedger, type DescribeAtom, type EntersAsSelf, EntryReuse, type ExplainOptions, type ExplainResolvedKeyOptions, type ExplainStats, FACT_CONTRACT_CASES, FactLog, type FactsOf, GLOBAL_MODULE, type GivesBackOne, type GivesBackOneOfArgument, type GivesBackOneOfImport, INSTANCE_STEP, type MountEdge, type MountEdges, NAMED_STORE_NAME, NAMESPACE_IMPORT, NAMESPACE_IMPORT_NAME, NAMESPACE_MEMBER_RULE, NAME_HOP_RULE, NO_CONTEXT, NO_CONTEXT_NAME, type NameReads, type NameWrite, type OrderedWrite, type PackWords, RECEIVER_STORE_NAME, RESOLUTION_QUESTIONS, RESOLUTION_RULES, RESULT_STEP, type ReadNode, type ResolutionExplanation, type ResolutionStep, type SourceEnd, type SourceLeaf, type SourceQuestion, type SpannedNode, type StepContext, type StepPhrase, type StoredDependencies, type StoredFacts, type StoredFileRecord, type StoredWalkRecord, type SuppliesParameter, UNDER_ANSWER_RELATIONS, UNDER_QUESTION_ROW_BUDGET, UNDER_RUN_ROW_BUDGET, UNPLACED_STORE_NAME, USES_QUESTION, type UnderOutcome, type UnwrapsByName, VALUE_STEP, type ValueLocation, type ValueUses, WatchedMap, type WhyExplained, addPackWords, agreedMountPrefix, allocationSitesOf, alsoSteps, answersFor, answersFromTestsLeftOut, askResolution, askResolutionUnder, askSources, calleeOutcomeOf, calleeOutcomes, checkFactContract, classMemberName, classMemberOf, comesToUnder, couldBeSettled, declaredTypesOf, exitCodeFunctions, explainResolutionProof, explainResolvedKey, fallbackWrittenAs, fileOfKey, hashString, importedFilesByFile, isObserved, isWrittenAsUnder, joinMountedPath, mergeStoredDependencies, mountPathsOf, noDependencies, nodeOfKey, noteKeyRead, noteLookup, objectOfUnder, observeDemand, packHashes, proofRules, queryFacts, readUses, recordsToReplay, renderExplanation, resolutionProgram, resolutionUnderProgram, resolvedFunctions, settledFunction, sourceLeavesOf, startsAtName, staysInItsFunction, stillValid, underQuestionSpend, unpackHashes, valueLeftByWrites, walkRecordsByFile, writesRunInOrder, writtenAnswersFor, writtenSourcesOf, writtenValueOf, writtenValueUnder, writtenValuesByKey, writtenValuesOf };
1290
+ export { ANSWER_RELATIONS, ASKING_RELATIONS, type AddRow, type AskUnder, type AssociationConstructor, BASE_CLASS_RULE, type CalleeOutcome, type CaseFiles, type ChainReads, type Changes, type ContractCase, type ContractOptions, DEFAULT_IMPORT_NAME, DISPATCH_QUESTION, type Dependencies, DependencyLedger, type DescribeAtom, type DispatchOutcome, type EntersAsSelf, EntryReuse, type ExplainOptions, type ExplainResolvedKeyOptions, type ExplainStats, FACT_CONTRACT_CASES, FactLog, type FactsOf, GLOBAL_MODULE, type GivesBackOne, type GivesBackOneOfArgument, type GivesBackOneOfImport, INSTANCE_STEP, type KeySpan, type MountEdge, type MountEdges, NAMED_STORE_NAME, NAMESPACE_IMPORT, NAMESPACE_IMPORT_NAME, NAMESPACE_MEMBER_RULE, NAME_HOP_RULE, NO_CONTEXT, NO_CONTEXT_NAME, type NameReads, type NameWrite, type OrderedWrite, type PackWords, RECEIVER_STORE_NAME, RESOLUTION_QUESTIONS, RESOLUTION_RULES, RESULT_STEP, type ReadNode, type ResolutionExplanation, type ResolutionStep, SPREAD_ENTRY, type SourceEnd, type SourceLeaf, type SourceQuestion, type SpannedNode, type StepContext, type StepPhrase, type StoredDependencies, type StoredFacts, type StoredFileRecord, type StoredWalkRecord, type SuppliesParameter, type TemplatePiece, UNDER_ANSWER_RELATIONS, UNDER_QUESTION_ROW_BUDGET, UNDER_RUN_ROW_BUDGET, UNPLACED_STORE_NAME, USES_QUESTION, type UnderOutcome, type UnwrapsByName, VALUE_ENTRY, VALUE_STEP, type ValueLocation, type ValueUses, WatchedMap, type WhyExplained, type WrittenEntry, addEntryRows, addPackWords, addTemplateRows, agreedMountPrefix, allocationSitesOf, alsoSteps, answersFor, answersFromTestsLeftOut, askResolution, askResolutionUnder, askSources, calleeOutcomeOf, calleeOutcomes, checkFactContract, classMemberName, classMemberOf, comesToUnder, couldBeSettled, declaredTypesOf, dispatchOutcomes, exitCodeFunctions, explainResolutionProof, explainResolvedKey, fallbackWrittenAs, fileOfKey, hashString, importedFilesByFile, isObserved, isWrittenAsUnder, joinMountedPath, mergeStoredDependencies, mountPathsOf, noDependencies, nodeOfKey, noteKeyRead, noteLookup, objectOfUnder, observeDemand, packHashes, proofRules, queryFacts, readDispatchOutcomes, readUses, recordsToReplay, renderExplanation, resolutionProgram, resolutionUnderProgram, resolvedFunctions, settledFunction, sourceLeavesOf, spanOfKey, startsAtName, staysInItsFunction, stillValid, underQuestionSpend, unpackHashes, valueLeftByWrites, walkRecordsByFile, writesRunInOrder, writtenAnswersFor, writtenSourcesOf, writtenValueOf, writtenValueUnder, writtenValuesByKey, writtenValuesOf };