FreeExam

Artifact and Manifest Utilities

Thirty original Python problems on artifact integrity, deterministic manifests, reference and provenance support, bundle storage, packing, conversion and repair planning. Implement explicit finite models while preserving missing, ambiguous and inconsistent evidence.

These problems are original practice. They are not questions from a named employer or a live hiring loop.

  1. 1.Audit restricted bundle paths and indexed duplicate evidence

    Write path_inventory(paths). Valid path: nonempty relative slash-separated text; no empty, . or .. component, NUL, backslash or colon. Do not normalize names or touch the filesystem. Return [invalid_input_indices,duplicates], duplicates [path,all_valid_occurrence_indices] for valid paths appearing >1 time, sorted by exact path. Invalid occurrences do not enter duplicate groups. No mutation.

  2. 2.Audit file and directory ownership of bundle names

    Write namespace_conflicts(entries), [canonical_relative_path,file/dir]. Repeated dirs coalesce. Return [duplicate_file_paths,mixed_file_dir_paths,blocked_descendant_paths], each sorted distinct. Duplicate file means >=2 file declarations. ANY file blocks listed proper descendants by whole components, even if it also declares dir. Ancestor dirs may be implicit. No mutation.

  3. 3.Check supplied UTF-8 size and SHA-256 evidence independently

    Write verify_payloads(rows), [name,text,declared_bytes,expected_sha256]. Text is valid Unicode; size nonnegative integer; digest 64 lowercase hex. Encode exact UTF-8 bytes without newline/Unicode normalization. Return [name,actual_byte_count,size_matches,digest_matches] per occurrence. SHA-256 is computed from those bytes; no file access or authenticity claim. No mutation.

  4. 4.Serialize the supplied whole-number manifest JSON model

    Write canonical_manifest(value), JSON with valid Unicode strings. Permit null/bool/strings and finite whole numbers with abs<=2**53-1; serialize numbers as integers. Recursively sort object keys by Unicode code point, compact separators, ensure_ascii=False. Return text, or None for unsupported numbers anywhere. Arrays retain order. Supplied model, not RFC 8785. No mutation.

  5. 5.Reject duplicate and nonfinite JSON manifest evidence

    Write parse_manifest(text). Parse one JSON value, allowing surrounding JSON whitespace. Reject malformed text, ANY repeated object key at any depth (even equal values), NaN/Infinity/-Infinity and nonfinite decoded numbers, including overflowing exponents. Return [True,parsed_value] or [False,None]. Valid null is [True,None]. Do not use eval or mutate input. No broader schema validation.

  6. 6.Group digest references only when size evidence agrees

    Write content_groups(entries), [unique_name,string_digest,nonnegative_size]. Digests are opaque identities. Group by digest; >1 distinct declared size makes it inconsistent and excludes its group. Return [groups,sorted_inconsistent_digests], valid groups [digest,size,sorted_names], sorted by digest. Repeated zero size is supported. No authenticity inference or mutation.

  7. 7.Compare logical and physical storage of selected bundles

    Write bundle_storage(bundles,selected), bundles name->[path,digest,nonnegative_size] rows. Repeated selected names collapse. Unknown selected bundle or conflicting size for any selected digest returns None. Otherwise [logical_bytes,unique_digest_bytes,saved_bytes]. Count every selected member occurrence logically; deduplicate physical digest storage across all selected bundles. No mutation.

  8. 8.Validate indexed chunk coverage without byte expansion

    Write chunk_layout(total,parts), total>=0; rows [index,offset,positive_length], integers. Require unique indices exactly 0..n-1. In index order, first offset=0 and every next offset=previous end; final end=total. Return ordered rows, or None if invalid. total=0 with no parts returns []. Do not infer a different order from offsets or enumerate payload bytes. No mutation.

  9. 9.Fetch pages whose complete byte range is not cached

    Write resume_pages(total,page,cached), total>=0, page>0 integers, ceil(total/page)<=1000. Cached [offset,nonnegative_length]; clip to [0,total) and union overlap/adjacency. Return sorted page indices NOT completely covered; partial page needs refetch. Final short page requires only its actual bytes. Combine pieces first. No byte-by-byte expansion or mutation.

  10. 10.Hash explicitly framed path, digest and size metadata

    Write bundle_fingerprint(entries), unique Unicode [path,size,digest], 0<=size<2**64, digest 64 lowercase hex. Sort by Unicode path. Concatenate each record: 4-byte big-endian UTF-8 path BYTE length, path bytes, 32 raw digest bytes, 8-byte big-endian size. Return SHA-256 hex of concatenation. Path byte lengths<2**32. Supplied framing only, not an external standard. No mutation.

  11. 11.Traverse artifact references and report missing support

    Write reference_closure(artifacts,roots), artifacts maps string IDs to dependency-ID lists. Traverse roots and all reachable dependencies. Return [sorted_existing_reachable_IDs,sorted_missing_IDs]. Missing IDs cannot be expanded or treated as empty artifacts. Cycles and repeated references are allowed and count once. Unreachable broken references are irrelevant. No mutation or storage access.

  12. 12.Resolve artifact handles and report alias cycles

    Write resolve_handles(handles,artifacts,queries). handles maps nonempty names to either "@other_handle" or a direct artifact ID; artifact IDs never start @. Return [query,artifact_or_None,reason_or_None] per query. Follow aliases exactly; missing handle/terminal artifact gives "missing", repeated handle in that chain gives "cycle". Direct targets must exist in supplied artifact list. No mutation.

  13. 13.Resolve artifact pins only from unique declarations

    Write resolve_pins(records,queries). Records [string_name,nonnegative_integer_version,string_digest]; queries [name,version]. Return [name,version,digest_or_None,reason_or_None] per query. Exactly one matching name/version resolves; none gives "missing", >1 "ambiguous", even identical rows. Never choose latest, merge duplicates or fall back to another name/version. No mutation.

  14. 14.Apply an all-or-nothing sequential digest delta

    Write manifest_delta(base,changes), base canonical_path->nonempty_digest. Changes [put/remove,path,expected_or_None,new_digest]; put new digest nonempty, remove ignores it. Expected None requires absence, else exact current digest. Remove also requires PRESENT path. Apply sequentially to a copy; first failure returns [None,bad_index], success [result,None]. No partial output or input mutation.

  15. 15.Infer only uniquely supported digest renames

    Write infer_renames(old,new), path->digest maps. Removed/added paths are absent from the other map; modified paths exist in both with unequal digests. Infer [old_path,new_path] ONLY when digest appears once among removed and once among added. Return [sorted_rename_pairs,unpaired_removed,unpaired_added,modified_paths], all path lists sorted. No arbitrary duplicate pairing or mutation.

  16. 16.Plan safe renames with one reusable temporary slot

    Write rename_steps(moves,occupied). moves source->destination has unique destinations; names never start @. All sources must exist in occupied. Ignore identity moves; stationary occupied destinations block the plan. Use starter ordering rules with reserved "@tmp". Return [source,destination] operations or None for unsupported source/blocker. Planning only; do not move files or mutate inputs.

  17. 17.Count distinct allowed attestation issuers

    Write attestation_gaps(statements,required). Statements [subject,predicate,issuer,valid_bool], opaque strings. Requirements [subject,predicate,allowed_issuers,min_distinct], min>=0. Count distinct allowed issuers with any valid statement for EXACT subject/predicate. Return [requirement_index,supported_count] only where below minimum, by index. Supplied validity; no signature verification/mutation.

  18. 18.Audit declared producer runs and pinned artifact inputs

    Write build_link_errors(artifacts,builds), artifacts ID->[digest,producer_or_None]; None means source. Builds [run,output_ID,output_digest,input_pins]. Need one matching producer run: none ->["missing-run"], >1 ->["ambiguous-run"]. Else reasons: "output" for wrong output ID/digest, then "inputs" for any absent/mismatched pinned ID->digest. Return sorted [artifact,reasons] only errors. No mutation.

  19. 19.Choose a minimum-size bundle set for required digests

    Write choose_bundles(required,bundles). required digest strings; <=12 bundles [unique_name,nonnegative_byte_cost,digest_list]. Select a subset covering EVERY distinct required digest. Minimize total cost, then bundle count, then sorted-name list. Return [sorted_names,total_cost], or None if no cover. Empty requirement returns [[],0] even with free bundles. No downloads or mutation.

  20. 20.Pack fixed-order members using each entry’s alignment

    Write aligned_layout(entries), [unique_name,nonnegative_size,positive_alignment], integers. Cursor starts 0. Round each start UP to its alignment multiple, even for size zero; end=start+size is new cursor. Return [placements,total_bytes,total_padding], placements [name,start,end] in input order. Alignment need not be a power of two. No reordering, payload allocation or mutation.

  21. 21.Report affine byte bounds for reversed and empty axes

    Write tensor_bounds(shape,strides,itemsize,origin,buffer_size), matching-rank nonnegative shape, integer BYTE strides/origin, itemsize>0, buffer_size>=0. Element starts at origin+sum(index*stride), 0<=index<dimension, with itemsize bytes. Return [minimum_start,maximum_end_exclusive,all_within_buffer]. Empty axis gives [None,None,True]; rank zero is one scalar. No element allocation/mutation.

  22. 22.List exact unsupported manifest capabilities

    Write reader_errors(manifest,caps). manifest has format integer, codec string, dtypes/features string lists. caps has supported formats/codecs/dtypes/features lists. Return sorted distinct errors: "format" if exact format absent, "codec:NAME", "dtype:NAME", "feature:NAME" for unsupported declarations. Duplicates add no multiplicity; a larger numeric version implies no support. No mutation.

  23. 23.Separate required and optional unknown manifest extensions

    Write extension_support(declared,understood), declared name->[required_bool,JSON_value], understood name list. Return [detached_understood_values,sorted_ignored_optional_names,sorted_missing_required_names]. Unknown required extensions are errors, never ignored; understood null remains present. Do not interpret unknown payloads. Repeated understood names have no effect. No mutation.

  24. 24.Plan a minimum-cost lossless format path

    Write conversion_path(edges,start,accepted), <=8 formats; edges [from,to,nonnegative_cost,lossy_bool]. Use ONLY nonlossy directed edges. Return [format_path,total_cost] reaching any accepted format, minimizing cost, then edge count, then lexical path. Include endpoints. Start already accepted gives [[start],0]; no route None. Zero-cost cycles allowed. No conversion or mutation.

  25. 25.Audit expanded-byte totals and exact per-member ratio limits

    Write expansion_budget(entries,total_limit,ratio), [unique_name,compressed_bytes,expanded_bytes], nonnegative integers. Ratio [num,den], num>=0, den>0. Violation iff expanded*den>compressed*num. Zero/zero passes; zero compressed/positive expanded fails. Return [expanded_total,total<=total_limit,sorted_violating_names]. Equality passes. Supplied metadata only; no decompression/mutation.

  26. 26.Audit multipart receipts without interpreting opaque tags

    Write receipt_errors(expected,received). Expected [unique_positive_part,nonnegative_size]; received [positive_part,size,string_tag]. Return sorted [missing,duplicates,extras,wrong_size,empty_tag] lists. Duplicates: ANY repeated received part. Extras: absent from expected. Size/tag errors ONLY for uniquely received expected parts. Tags opaque; empty string unsupported. No mutation.

  27. 27.Group declared build metadata with explicit seed support

    Write signature_groups(runs), [unique_name,recipe,seed_or_None,ordered_input_digests,environment_map]. Strings except nonnegative seed. None seed is unsupported; report its input index. Otherwise signature=(recipe,seed,ordered inputs,sorted environment pairs). Return [groups,unsupported_indices], names sorted within groups, groups lexical. Zero seed valid. No reproducibility guarantee/mutation.

  28. 28.Plan maximal reference-safe deletion and retain blockers

    Write deletion_order(artifacts,candidates), ID->dependency-ID lists, all known; candidates unique known IDs. Noncandidates remain. Repeatedly delete lexical smallest candidate with NO reference from any remaining artifact, including itself. Return [deletion_order,sorted_blocked_candidates]. Cycles/external dependents may block. Never delete blockers/noncandidates. No real deletion/mutation.

  29. 29.Plan exact artifact repair with reusable patch bases

    Write repair_plan(artifacts,full_cost,patches,present,required), <=10 known IDs, all refs known. Costs>=0; patch [base,target,cost] needs available base and adds target. Full cost entry permits adding its ID. Nothing is consumed. Starter encodes actions. Return [minimum_cost,actions], ties fewer actions then lexical action sequence, or None. No actual downloads/mutation.

  30. 30.Minimize live-output peak across dependency-valid exports

    Write export_order(tasks,retained), <=8 ID->[nonnegative_bytes,parent_IDs]. Unknown parents/retained IDs or cycles return None. Use starter lifetime model. Choose a valid one-at-a-time export order minimizing peak bytes, ties lexical order. Return [peak,order]. Empty inventory returns [0,[]]. Parent duplicates collapse; all outputs initially absent. No allocation, execution or mutation.