diff --git a/.zed/rules b/.zed/rules index 83fdcec30..0073a536a 100644 --- a/.zed/rules +++ b/.zed/rules @@ -547,7 +547,8 @@ algorithm produced it.** - A label names the algorithm that produced a digest (the whole procedure: canonical form, preparation, encoding, digest function) and nothing else. Format `_v`, integer `N`: `semantic_v1`, `arrow_v1`, `arrow_ordered_v1`, `directory_v1`, `ndarray_v1`, - `polars_expr_v1`, `batch_v1`, `group_v1`. The file content hash keeps `sha256`, the only + `polars_expr_v1`, `batch_v1`, `group_v1`, `function_signature_v1`, `function_content_v1`. + The file content hash keeps `sha256`, the only exception. A logical type's implementer picks its label. - Change a label only when its algorithm would give an existing input a different digest. - Define each label in exactly one place, as a constant beside its algorithm. Never write a diff --git a/CLAUDE.md b/CLAUDE.md index 9473e07b7..0a38943bf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -558,7 +558,8 @@ algorithm produced it.** - A label names the algorithm that produced a digest (the whole procedure: canonical form, preparation, encoding, digest function) and nothing else. Format `_v`, integer `N`: `semantic_v1`, `arrow_v1`, `arrow_ordered_v1`, `directory_v1`, `ndarray_v1`, - `polars_expr_v1`, `batch_v1`, `group_v1`. The file content hash keeps `sha256`, the only + `polars_expr_v1`, `batch_v1`, `group_v1`, `function_signature_v1`, `function_content_v1`. + The file content hash keeps `sha256`, the only exception. A logical type's implementer picks its label. - Change a label only when its algorithm would give an existing input a different digest. - Define each label in exactly one place, as a constant beside its algorithm. Never write a diff --git a/changelog.d/ITL-1256.md b/changelog.d/ITL-1256.md new file mode 100644 index 000000000..2aca4544c --- /dev/null +++ b/changelog.d/ITL-1256.md @@ -0,0 +1,13 @@ +### Changed + +- The record a function result row keeps about its function (`python.function.v1`, + `rev1`; ITL-1256): a new column `function_module` (the function's `__module__`); + `function_signature_hash` is now the hash of the declared interface (each input with its + effective type and default, by name; the outputs with their types in declared order; + label `function_signature_v1`), so two pods whose output keys differ only in order record + different values; `function_content_hash` is the hash of the source text from the `def` + line on, decorator lines excluded (label `function_content_v1`), and is null when the + source cannot be read (a function typed into a plain REPL or made with `exec`) or, for + a function other than a lambda, does not start at a `def` statement (the module file + changed after the import); a lambda's hash covers its enclosing lines. See + `docs/reference/data-function-types.md`. diff --git a/docs/reference/data-function-types.md b/docs/reference/data-function-types.md index eb9ab87cc..8880c5432 100644 --- a/docs/reference/data-function-types.md +++ b/docs/reference/data-function-types.md @@ -99,8 +99,9 @@ Each result row holds these columns about the function (`__pf_var_` prefix): |---|---|---|---|---| | `function_name` | `str` | `large_string` | yes | the function's name, as in the uri | | `function_version` | `str` | `large_string` | yes | the full version string the function was declared with (`v3.7`) | -| `function_signature_hash` | `bytes` | `large_binary` | yes | the hash of the function used as a value | -| `function_content_hash` | `bytes` | `large_binary` | yes | the hash of the function's code | +| `function_module` | `str \| None` | `large_string` | yes | the function's module (`__module__`) | +| `function_signature_hash` | `bytes` | `large_binary` | yes | the hash of the function's declared interface | +| `function_content_hash` | `bytes \| None` | `large_binary` | yes | the hash of the function as written (a lambda: its enclosing lines); absent when its source cannot be read (a plain REPL, `python -c`, `exec`) or, for a function other than a lambda, does not start at a `def` statement | | `git_hash` | `str` | `large_string` | yes | the git commit of the function's file or working directory, with `-dirty`, `-untracked` and `-` suffixes; `unknown` outside git | and these about how it was computed (`__pf_exec_` prefix): @@ -116,8 +117,8 @@ The two hashes, each stored as `